diff options
Diffstat (limited to 'devices/vector/gdevxps.c')
-rw-r--r-- | devices/vector/gdevxps.c | 128 |
1 files changed, 55 insertions, 73 deletions
diff --git a/devices/vector/gdevxps.c b/devices/vector/gdevxps.c index c435cd47..c946f322 100644 --- a/devices/vector/gdevxps.c +++ b/devices/vector/gdevxps.c @@ -198,8 +198,8 @@ gs_public_st_suffix_add1_final(st_device_xps, gx_device_xps, "gx_device_xps", device_xps_enum_ptrs, device_xps_reloc_ptrs, gx_device_finalize, st_device_vector, xps_pie); -#define xps_device_body(dname, depth)\ - std_device_dci_type_body(gx_device_xps, 0, dname, &st_device_xps, \ +#define xps_device_body(dname, depth, init)\ + std_device_dci_type_body(gx_device_xps, init, dname, &st_device_xps, \ DEFAULT_WIDTH_10THS * X_DPI / 10, \ DEFAULT_HEIGHT_10THS * Y_DPI / 10, \ X_DPI, Y_DPI, \ @@ -214,63 +214,41 @@ static dev_proc_get_params(xps_get_params); static dev_proc_put_params(xps_put_params); static dev_proc_fill_path(gdev_xps_fill_path); static dev_proc_stroke_path(gdev_xps_stroke_path); -static dev_proc_finish_copydevice(xps_finish_copydevice); -static dev_proc_begin_image(xps_begin_image); - -#define xps_device_procs \ -{ \ - xps_open_device, \ - NULL, /* get_initial_matrix */\ - NULL, /* sync_output */\ - xps_output_page,\ - xps_close_device,\ - gx_default_rgb_map_rgb_color,\ - gx_default_rgb_map_color_rgb,\ - gdev_vector_fill_rectangle,\ - NULL, /* tile_rectangle */\ - NULL, /* copy_mono */\ - NULL, /* copy_color */\ - NULL, /* draw_line */\ - NULL, /* get_bits */\ - xps_get_params,\ - xps_put_params,\ - NULL, /* map_cmyk_color */\ - NULL, /* get_xfont_procs */\ - NULL, /* get_xfont_device */\ - NULL, /* map_rgb_alpha_color */\ - gx_page_device_get_page_device,\ - NULL, /* get_alpha_bits */\ - NULL, /* copy_alpha */\ - NULL, /* get_band */\ - NULL, /* copy_rop */\ - gdev_xps_fill_path,\ - gdev_xps_stroke_path,\ - NULL, /* fill_mask */\ - NULL, /* gdev_vector_fill_trapezoid, */ \ - NULL, /* gdev_vector_fill_parallelogram */ \ - NULL, /* gdev_vector_fill_triangle */ \ - NULL, /* draw_thin_line */\ - xps_begin_image, /* begin_image */ \ - NULL, /* image_data */\ - NULL, /* end_image */\ - NULL, /* strip_tile_rectangle */\ - NULL, /* strip_copy_rop */\ - NULL, /* get_clipping_box */\ - NULL, /* begin_typed_image */\ - NULL, /* get_bits_rectangle */\ - NULL, /* map_color_rgb_alpha */\ - NULL, /* create_compositor */\ - NULL, /* get_hardware_params */\ - NULL, /* text_begin */\ - xps_finish_copydevice,\ - NULL,\ -} +static dev_proc_initialize_device_procs(xps_initialize_device_procs); +static dev_proc_begin_typed_image(xps_begin_typed_image); const gx_device_xps gs_xpswrite_device = { - xps_device_body("xpswrite", 24), - xps_device_procs + xps_device_body("xpswrite", 24, xps_initialize_device_procs), }; +static int +xps_initialize_device(gx_device *dev) +{ + gx_device_xps *xps = (gx_device_xps*)dev; + + memset(xps->PrinterName, 0x00, MAXPRINTERNAME); + + return 0; +} + +static void +xps_initialize_device_procs(gx_device *dev) +{ + set_dev_proc(dev, initialize_device, xps_initialize_device); + set_dev_proc(dev, open_device, xps_open_device); + set_dev_proc(dev, output_page, xps_output_page); + set_dev_proc(dev, close_device, xps_close_device); + set_dev_proc(dev, map_rgb_color, gx_default_rgb_map_rgb_color); + set_dev_proc(dev, map_color_rgb, gx_default_rgb_map_color_rgb); + set_dev_proc(dev, fill_rectangle, gdev_vector_fill_rectangle); + set_dev_proc(dev, get_params, xps_get_params); + set_dev_proc(dev, put_params, xps_put_params); + set_dev_proc(dev, get_page_device, gx_page_device_get_page_device); + set_dev_proc(dev, fill_path, gdev_xps_fill_path); + set_dev_proc(dev, stroke_path, gdev_xps_stroke_path); + set_dev_proc(dev, begin_typed_image, xps_begin_typed_image); +} + /* Vector device procedures */ static int xps_beginpage(gx_device_vector *vdev); @@ -1321,14 +1299,6 @@ xps_put_params(gx_device *dev, gs_param_list *plist) return code; } -static int xps_finish_copydevice(gx_device *dev, const gx_device *from_dev) -{ - gx_device_xps *xps = (gx_device_xps*)dev; - - memset(xps->PrinterName, 0x00, MAXPRINTERNAME); - return 0; -} - static int set_state_color(gx_device_vector *vdev, const gx_drawing_color *pdc, gx_color_index *color) { @@ -1898,15 +1868,20 @@ xps_write_profile(const gs_gstate *pgs, char *name, cmm_profile_t *profile, gx_d } static int -xps_begin_image(gx_device *dev, const gs_gstate *pgs, - const gs_image_t *pim, gs_image_format_t format, - const gs_int_rect *prect, const gx_drawing_color *pdcolor, - const gx_clip_path *pcpath, gs_memory_t *mem, - gx_image_enum_common_t **pinfo) +xps_begin_typed_image(gx_device *dev, + const gs_gstate *pgs, + const gs_matrix *pmat, + const gs_image_common_t *pic, + const gs_int_rect *prect, + const gx_drawing_color *pdcolor, + const gx_clip_path *pcpath, + gs_memory_t *mem, + gx_image_enum_common_t **pinfo) { gx_device_vector *vdev = (gx_device_vector *)dev; gx_device_xps *xdev = (gx_device_xps *)dev; - gs_color_space *pcs = pim->ColorSpace; + const gs_image_t *pim = (const gs_image_t *)pic; + gs_color_space *pcs; xps_image_enum_t *pie = NULL; xps_icc_data_t *icc_data; gs_matrix mat; @@ -1922,6 +1897,10 @@ xps_begin_image(gx_device *dev, const gs_gstate *pgs, gsicc_rendering_param_t rendering_params; bool force8bit = false; + if (pic->type->index != 1) + goto use_default; + + pcs = pim->ColorSpace; /* No image mask yet. Also, need a color space */ if (pcs == NULL || ((const gs_image1_t *)pim)->ImageMask) goto use_default; @@ -1939,8 +1918,10 @@ xps_begin_image(gx_device *dev, const gs_gstate *pgs, if (gs_matrix_invert(&pim->ImageMatrix, &mat) < 0) goto use_default; + if (pmat == NULL) + pmat = &ctm_only(pgs); if (pgs) - gs_matrix_multiply(&mat, &ctm_only(pgs), &mat); + gs_matrix_multiply(&mat, pmat, &mat); pie = gs_alloc_struct(mem, xps_image_enum_t, &st_xps_image_enum, "xps_begin_image"); @@ -2078,7 +2059,7 @@ xps_begin_image(gx_device *dev, const gs_gstate *pgs, if (pgs == NULL) return(gs_error_invalidaccess); - code = gdev_vector_begin_image(vdev, pgs, pim, format, prect, + code = gdev_vector_begin_image(vdev, pgs, pim, pim->format, prect, pdcolor, pcpath, mem, &xps_image_enum_procs, (gdev_vector_image_enum_t *)pie); if (code < 0) @@ -2147,8 +2128,8 @@ xps_begin_image(gx_device *dev, const gs_gstate *pgs, return 0; use_default: - return gx_default_begin_image(dev, pgs, pim, format, prect, - pdcolor, pcpath, mem, pinfo); + return gx_default_begin_typed_image(dev, pgs, pmat, pic, prect, + pdcolor, pcpath, mem, pinfo); } /* Handles conversion from decoded DeviceN, Sep or Indexed space to Device color @@ -2329,6 +2310,7 @@ xps_image_end_image(gx_image_enum_common_t * info, bool draw_last) /* Add the image relationship */ code = xps_add_image_relationship(pie); + gs_free_object(pie->memory, pie, "xps_image_end_image"); exit: return code; } |