diff options
author | Robin Watts <robin.watts@artifex.com> | 2010-04-21 15:08:47 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2010-04-21 15:08:47 +0000 |
commit | d592cefc7da5e96bc9f232c8882d60d88fb61c5c (patch) | |
tree | d79941d053871799d688720730b5b099d6289abe | |
parent | d0b31d8d649cd997a5b6ea5d0a868002af3e492f (diff) |
Move CPSI_mode from being a global to living in the libctx, as part of the
efforts for bug 691207 (remove global variables).
I originally tried moving CPSI_mode into the imager state, which would have
been slightly nicer, but had to abandon this due to problems interacting
with the command list code. My first thought to make this work was to
push the value of CPSI_mode into the clist at initial clist creation time.
As the setting of CPSI_mode isn't vectored through the device, we can't
detect changes in its setting, but then changing CPSI_mode during the
lifespan of a clist would give unpredictable results anyway in many cases.
Sadly this was doomed to failure as if a page device is started up that
uses the clist code to do banding, then the command list is created before
CPSI_mode is enabled, and we'd operate with the incorrect value.
Moving CPSI_mode into libctx means we keep exactly the same behaviour as
we have now. This has required various functions throughout the code to
pass a gs_memory_t * around.
Localcluster testing reveals no problems.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11094 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/base/gdevbit.c | 2 | ||||
-rw-r--r-- | gs/base/gdevdevn.c | 2 | ||||
-rw-r--r-- | gs/base/gdevperm.c | 4 | ||||
-rw-r--r-- | gs/base/gdevpsd.c | 4 | ||||
-rw-r--r-- | gs/base/gdevpsds.c | 3 | ||||
-rw-r--r-- | gs/base/gdevrinkj.c | 12 | ||||
-rw-r--r-- | gs/base/gdevxcf.c | 6 | ||||
-rw-r--r-- | gs/base/gsdps1.c | 2 | ||||
-rw-r--r-- | gs/base/gsequivc.c | 3 | ||||
-rw-r--r-- | gs/base/gsfont.c | 6 | ||||
-rw-r--r-- | gs/base/gsfont.h | 2 | ||||
-rw-r--r-- | gs/base/gslibctx.c | 1 | ||||
-rw-r--r-- | gs/base/gslibctx.h | 4 | ||||
-rw-r--r-- | gs/base/gsmisc.c | 9 | ||||
-rw-r--r-- | gs/base/gspaint.c | 4 | ||||
-rw-r--r-- | gs/base/gsstate.c | 20 | ||||
-rw-r--r-- | gs/base/gsstate.h | 3 | ||||
-rw-r--r-- | gs/base/gxblend1.c | 2 | ||||
-rw-r--r-- | gs/base/gxcmap.c | 8 | ||||
-rw-r--r-- | gs/base/gxdcconv.c | 10 | ||||
-rw-r--r-- | gs/base/gxdcconv.h | 6 | ||||
-rw-r--r-- | gs/base/gxfill.c | 3 | ||||
-rw-r--r-- | gs/base/gxicolor.c | 2 | ||||
-rw-r--r-- | gs/base/gxstroke.c | 2 | ||||
-rw-r--r-- | gs/contrib/opvp/gdevopvp.c | 5348 | ||||
-rw-r--r-- | gs/psi/zchar.c | 7 | ||||
-rw-r--r-- | gs/psi/zcharx.c | 2 | ||||
-rw-r--r-- | gs/psi/zfont.c | 2 | ||||
-rw-r--r-- | gs/psi/zfunc3.c | 4 | ||||
-rw-r--r-- | gs/psi/zimage.c | 3 | ||||
-rw-r--r-- | gs/psi/zmisc.c | 13 | ||||
-rw-r--r-- | gs/psi/zupath.c | 10 | ||||
-rw-r--r-- | gs/psi/zusparam.c | 3 |
33 files changed, 2756 insertions, 2756 deletions
diff --git a/gs/base/gdevbit.c b/gs/base/gdevbit.c index 34b148d3c..faffcb95a 100644 --- a/gs/base/gdevbit.c +++ b/gs/base/gdevbit.c @@ -320,7 +320,7 @@ const gx_device_bit gs_bitrgbtags_device = static void cmyk_cs_to_rgb_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[]) { - color_cmyk_to_rgb(c, m, y, k, NULL, out); + color_cmyk_to_rgb(c, m, y, k, NULL, out, dev->memory); }; static void diff --git a/gs/base/gdevdevn.c b/gs/base/gdevdevn.c index c333a097d..78530eaf4 100644 --- a/gs/base/gdevdevn.c +++ b/gs/base/gdevdevn.c @@ -55,7 +55,7 @@ rgb_cs_to_devn_cm(gx_device * dev, int * map, for(; i >= 0; i--) /* Clear colors */ out[i] = frac_0; - color_rgb_to_cmyk(r, g, b, pis, cmyk); + color_rgb_to_cmyk(r, g, b, pis, cmyk, dev->memory); if ((i = map[0]) != GX_DEVICE_COLOR_MAX_COMPONENTS) out[i] = cmyk[0]; if ((i = map[1]) != GX_DEVICE_COLOR_MAX_COMPONENTS) diff --git a/gs/base/gdevperm.c b/gs/base/gdevperm.c index 61c7c6084..2ab34ccd3 100644 --- a/gs/base/gdevperm.c +++ b/gs/base/gdevperm.c @@ -217,7 +217,7 @@ static void rgb_cs_to_perm_cm_0(gx_device *dev, const gs_imager_state *pis, frac r, frac g, frac b, frac out[]) { - color_rgb_to_cmyk(r, g, b, pis, out); + color_rgb_to_cmyk(r, g, b, pis, out, dev->memory); perm_permute_cm(dev, out); } @@ -251,7 +251,7 @@ rgb_cs_to_perm_cm_1(gx_device *dev, const gs_imager_state *pis, static void cmyk_cs_to_perm_cm_1(gx_device *dev, frac c, frac m, frac y, frac k, frac out[]) { - color_cmyk_to_rgb(c, m, y, k, NULL, out); + color_cmyk_to_rgb(c, m, y, k, NULL, out, dev->memory); out[0] = frac_1 - out[0]; out[1] = frac_1 - out[1]; out[2] = frac_1 - out[2]; diff --git a/gs/base/gdevpsd.c b/gs/base/gdevpsd.c index 7940bf1b2..faaa78ea4 100644 --- a/gs/base/gdevpsd.c +++ b/gs/base/gdevpsd.c @@ -378,7 +378,7 @@ cmyk_cs_to_psdrgb_cm(gx_device * dev, { int i = ((psd_device *)dev)->devn_params.separations.num_separations; - color_cmyk_to_rgb(c, m, y, k, NULL, out); + color_cmyk_to_rgb(c, m, y, k, NULL, out, dev->memory); for(; i>0; i--) /* Clear spot colors */ out[2 + i] = 0; } @@ -475,7 +475,7 @@ rgb_cs_to_spotn_cm(gx_device * dev, const gs_imager_state *pis, } else { frac cmyk[4]; - color_rgb_to_cmyk(r, g, b, pis, cmyk); + color_rgb_to_cmyk(r, g, b, pis, cmyk, dev->memory); cmyk_cs_to_spotn_cm(dev, cmyk[0], cmyk[1], cmyk[2], cmyk[3], out); } diff --git a/gs/base/gdevpsds.c b/gs/base/gdevpsds.c index 399d7b89e..43beb8a3d 100644 --- a/gs/base/gdevpsds.c +++ b/gs/base/gdevpsds.c @@ -23,6 +23,7 @@ #include "gsdcolor.h" #include "gscspace.h" #include "gxdevcli.h" +#include "gxistate.h" /* ---------------- Convert between 1/2/4/12 and 8 bits ---------------- */ @@ -345,7 +346,7 @@ s_C2R_process(stream_state * st, stream_cursor_read * pr, frac rgb[3]; color_cmyk_to_rgb(byte2frac(bc), byte2frac(bm), byte2frac(by), - byte2frac(bk), ss->pis, rgb); + byte2frac(bk), ss->pis, rgb, ss->pis->memory); q[1] = frac2byte(rgb[0]); q[2] = frac2byte(rgb[1]); q[3] = frac2byte(rgb[2]); diff --git a/gs/base/gdevrinkj.c b/gs/base/gdevrinkj.c index 886621c92..f21061950 100644 --- a/gs/base/gdevrinkj.c +++ b/gs/base/gdevrinkj.c @@ -256,7 +256,7 @@ cmyk_cs_to_spotrgb_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[ /* TO_DO_DEVICEN This routine needs to include the effects of the SeparationOrder array */ int i = ((rinkj_device *)dev)->separation_names.num_names; - color_cmyk_to_rgb(c, m, y, k, NULL, out); + color_cmyk_to_rgb(c, m, y, k, NULL, out, dev->memory); for(; i>0; i--) /* Clear spot colors */ out[2 + i] = 0; }; @@ -282,7 +282,7 @@ rgb_cs_to_spotcmyk_cm(gx_device * dev, const gs_imager_state *pis, int n = rdev->separation_names.num_names; int i; - color_rgb_to_cmyk(r, g, b, pis, out); + color_rgb_to_cmyk(r, g, b, pis, out, dev->memory); for(i = 0; i < n; i++) /* Clear spot colors */ out[4 + i] = 0; } @@ -335,7 +335,7 @@ rgb_cs_to_spotn_cm(gx_device * dev, const gs_imager_state *pis, /* TO_DO_DEVICEN This routine needs to include the effects of the SeparationOrder array */ frac cmyk[4]; - color_rgb_to_cmyk(r, g, b, pis, cmyk); + color_rgb_to_cmyk(r, g, b, pis, cmyk, dev->memory); cmyk_cs_to_spotn_cm(dev, cmyk[0], cmyk[1], cmyk[2], cmyk[3], out); } @@ -813,7 +813,7 @@ typedef struct rinkj_lutset_s rinkj_lutset; typedef struct rinkj_lutchain_s rinkj_lutchain; struct rinkj_lutset_s { - char *plane_names; + const char *plane_names; rinkj_lutchain *lut[MAX_CHAN]; }; @@ -986,8 +986,8 @@ rinkj_write_image_data(gx_device_printer *pdev, RinkjDevice *cmyk_dev) rinkj_device *rdev = (rinkj_device *)pdev; int raster = gdev_prn_raster(rdev); byte *line; - char *plane_data[MAX_CHAN]; - const char *split_plane_data[MAX_CHAN]; + byte *plane_data[MAX_CHAN]; + const byte *split_plane_data[MAX_CHAN]; int xsb; int n_planes; int n_planes_in = pdev->color_info.num_components; diff --git a/gs/base/gdevxcf.c b/gs/base/gdevxcf.c index 36909560b..a476f090e 100644 --- a/gs/base/gdevxcf.c +++ b/gs/base/gdevxcf.c @@ -286,7 +286,7 @@ cmyk_cs_to_spotrgb_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[ /* TO_DO_DEVICEN This routine needs to include the effects of the SeparationOrder array */ int i = ((xcf_device *)dev)->separation_names.num_names; - color_cmyk_to_rgb(c, m, y, k, NULL, out); + color_cmyk_to_rgb(c, m, y, k, NULL, out, dev->memory); for(; i>0; i--) /* Clear spot colors */ out[2 + i] = 0; } @@ -312,7 +312,7 @@ rgb_cs_to_spotcmyk_cm(gx_device * dev, const gs_imager_state *pis, int n = xdev->separation_names.num_names; int i; - color_rgb_to_cmyk(r, g, b, pis, out); + color_rgb_to_cmyk(r, g, b, pis, out, dev->memory); for(i = 0; i < n; i++) /* Clear spot colors */ out[4 + i] = 0; } @@ -401,7 +401,7 @@ rgb_cs_to_spotn_cm(gx_device * dev, const gs_imager_state *pis, } else { frac cmyk[4]; - color_rgb_to_cmyk(r, g, b, pis, cmyk); + color_rgb_to_cmyk(r, g, b, pis, cmyk, dev->memory); cmyk_cs_to_spotn_cm(dev, cmyk[0], cmyk[1], cmyk[2], cmyk[3], out); } diff --git a/gs/base/gsdps1.c b/gs/base/gsdps1.c index 62abcf5f1..cb8d086d4 100644 --- a/gs/base/gsdps1.c +++ b/gs/base/gsdps1.c @@ -97,7 +97,7 @@ gs_setbbox(gs_state * pgs, floatp llx, floatp lly, floatp urx, floatp ury) static int gs_rectappend_compat(gs_state * pgs, const gs_rect * pr, uint count, bool clip) { - extern bool CPSI_mode; + bool CPSI_mode = gs_currentcpsimode(pgs->memory); for (; count != 0; count--, pr++) { floatp px = pr->p.x, py = pr->p.y, qx = pr->q.x, qy = pr->q.y; diff --git a/gs/base/gsequivc.c b/gs/base/gsequivc.c index d0aa0d7e2..a1a40009d 100644 --- a/gs/base/gsequivc.c +++ b/gs/base/gsequivc.c @@ -322,7 +322,7 @@ cmap_rgb_capture_cmyk_color(frac r, frac g, frac b, gx_device_color * pdc, int sep_num = ((color_capture_device *)dev)->sep_num; frac cmyk[4]; - color_rgb_to_cmyk(r, g, b, pis, cmyk); + color_rgb_to_cmyk(r, g, b, pis, cmyk, dev->memory); save_spot_equivalent_cmyk_color(sep_num, pparams, cmyk); } @@ -386,6 +386,7 @@ capture_spot_equivalent_cmyk_colors(gx_device * pdev, const gs_state * pgs, temp_device.color_info = pdev->color_info; temp_device.sep_num = sep_num; temp_device.pequiv_cmyk_colors = pparams; + temp_device.memory = pgs->memory; /* * Create a temp copy of the imager state. We do this so that we * can modify the color space mapping (cmap) procs. We use our diff --git a/gs/base/gsfont.c b/gs/base/gsfont.c index 3d8670667..dab8b5a1f 100644 --- a/gs/base/gsfont.c +++ b/gs/base/gsfont.c @@ -40,8 +40,6 @@ #define cmax_SMALL 500 /* cmax - # of cached chars */ #define blimit_SMALL 100 /* blimit/upper - max size of a single cached char */ -extern bool CPSI_mode; - /* Define a default procedure vector for fonts. */ const gs_font_procs gs_font_procs_default = { gs_no_define_font, /* (actually a default) */ @@ -633,8 +631,10 @@ gs_cachestatus(register const gs_font_dir * pdir, register uint pstat[7]) /* setcacheparams */ int -gs_setcachesize(gs_font_dir * pdir, uint size) +gs_setcachesize(gs_state * pgs, gs_font_dir * pdir, uint size) { /* This doesn't delete anything from the cache yet. */ + bool CPSI_mode = gs_currentcpsimode(pgs->memory); + if (CPSI_mode) { if (size < 100000) /* for CET 27-07 */ size = 100000; diff --git a/gs/base/gsfont.h b/gs/base/gsfont.h index 11eb7a871..0f5d728ea 100644 --- a/gs/base/gsfont.h +++ b/gs/base/gsfont.h @@ -76,7 +76,7 @@ void gs_cachestatus(const gs_font_dir *, uint[7]); #define gs_setcachelimit(pdir,limit) gs_setcacheupper(pdir,limit) uint gs_currentcachesize(const gs_font_dir *); -int gs_setcachesize(gs_font_dir *, uint); +int gs_setcachesize(gs_state * pgs, gs_font_dir *, uint); uint gs_currentcachelower(const gs_font_dir *); int gs_setcachelower(gs_font_dir *, uint); uint gs_currentcacheupper(const gs_font_dir *); diff --git a/gs/base/gslibctx.c b/gs/base/gslibctx.c index 3b32d3f84..5850a0e2c 100644 --- a/gs/base/gslibctx.c +++ b/gs/base/gslibctx.c @@ -83,6 +83,7 @@ int gs_lib_ctx_init( gs_memory_t *mem ) pio->screen_use_wts = false; pio->screen_min_screen_levels = 0; pio->BITTAG = GS_DEVICE_DOESNT_SUPPORT_TAGS; + pio->CPSI_mode = false; gp_get_realtime(pio->real_time_0); diff --git a/gs/base/gslibctx.h b/gs/base/gslibctx.h index cdfb0afec..8717f4ad8 100644 --- a/gs/base/gslibctx.h +++ b/gs/base/gslibctx.h @@ -69,6 +69,10 @@ typedef struct gs_lib_ctx_s /* real time clock 'bias' value. Not strictly required, but some FTS * tests work better if realtime starts from 0 at boot time. */ long real_time_0[2]; + /* True if we are emulating CPSI. Ideally this would be in the imager + * state, but this can't be done due to problems detecting changes in it + * for the clist based devices. */ + bool CPSI_mode; } gs_lib_ctx_t; /** initializes and stores itself in the given gs_memory_t pointer. diff --git a/gs/base/gsmisc.c b/gs/base/gsmisc.c index b57a41bc0..274c72941 100644 --- a/gs/base/gsmisc.c +++ b/gs/base/gsmisc.c @@ -15,15 +15,6 @@ /* Miscellaneous utilities for Ghostscript library */ -/**************************************************************************** - * This global should be put into either gs_imager_state or gs_device, - * but the "plumbing" retrofit is more than we need for things that were - * previously compile time modifications. CPSI_mode will at least make these - * dynamic (but NOT thread safe)!!! - **************************************************************************** - */ -int CPSI_mode = 0; /* false */ /* default GS behavior is 'false' */ - /* * In order to capture the original definition of sqrt, which might be * either a procedure or a macro and might not have an ANSI-compliant diff --git a/gs/base/gspaint.c b/gs/base/gspaint.c index 1c0025508..74afa5275 100644 --- a/gs/base/gspaint.c +++ b/gs/base/gspaint.c @@ -31,8 +31,6 @@ #include "gxhldevc.h" #include "gsutil.h" -extern bool CPSI_mode; - /* Define the nominal size for alpha buffers. */ #define abuf_nominal_SMALL 500 #define abuf_nominal_LARGE 2000 @@ -497,7 +495,7 @@ gs_strokepath_aux(gs_state * pgs, bool traditional) if (code < 0) return code; /* NB: needs testing with PCL */ - if (CPSI_mode && gx_path_is_void(pgs->path)) + if (gs_currentcpsimode(pgs->memory) && gx_path_is_void(pgs->path)) pgs->current_point_valid = false; else gx_setcurrentpoint(pgs, fixed2float(spath.position.x), fixed2float(spath.position.y)); diff --git a/gs/base/gsstate.c b/gs/base/gsstate.c index 91ddedf29..7e15d13e5 100644 --- a/gs/base/gsstate.c +++ b/gs/base/gsstate.c @@ -399,7 +399,6 @@ gs_grestore_only(gs_state * pgs) void *sdata; gs_transparency_state_t *tstack = pgs->transparency_stack; bool prior_overprint = pgs->overprint; - int code; if_debug2('g', "[g]grestore 0x%lx, level was %d\n", (ulong) saved, pgs->level); @@ -711,6 +710,23 @@ gs_currentoverprintmode(const gs_state * pgs) return pgs->overprint_mode; } +void +gs_setcpsimode(gs_memory_t *mem, bool mode) +{ + gs_lib_ctx_t *libctx = gs_lib_ctx_get_interp_instance(mem); + + libctx->CPSI_mode = mode; +} + +/* currentcpsimode */ +bool +gs_currentcpsimode(const gs_memory_t * mem) +{ + gs_lib_ctx_t *libctx = gs_lib_ctx_get_interp_instance(mem); + + return libctx->CPSI_mode; +} + /* setrenderingintent * * Use ICC numbers from Table 18 (section 6.1.11) rather than the PDF order @@ -997,7 +1013,6 @@ gstate_free_contents(gs_state * pgs) { gs_memory_t *mem = pgs->memory; const char *const cname = "gstate_free_contents"; - int current_col; rc_decrement(pgs->device, cname); clip_stack_rc_adjust(pgs->clip_stack, -1, cname); @@ -1156,7 +1171,6 @@ void gs_swapcolors_quick(gs_state *pgs) int gs_swapcolors(gs_state *pgs) { int prior_overprint = pgs->overprint; - int prior_mode = pgs->effective_overprint_mode; gs_swapcolors_quick(pgs); diff --git a/gs/base/gsstate.h b/gs/base/gsstate.h index 55e8d332f..486427224 100644 --- a/gs/base/gsstate.h +++ b/gs/base/gsstate.h @@ -57,6 +57,9 @@ int gs_setrenderingintent(gs_state *, int); int gs_initgraphics(gs_state *); +bool gs_currentcpsimode(const gs_memory_t *); +void gs_setcpsimode(gs_memory_t *, bool); + /* Device control */ #include "gsdevice.h" diff --git a/gs/base/gxblend1.c b/gs/base/gxblend1.c index 9ec16201e..1904f104b 100644 --- a/gs/base/gxblend1.c +++ b/gs/base/gxblend1.c @@ -556,7 +556,7 @@ pdf14_rgb_cs_to_cmyk_cm(gx_device * dev, const gs_imager_state *pis, int num_comp = dev->color_info.num_components; if (pis != 0) - color_rgb_to_cmyk(r, g, b, pis, out); + color_rgb_to_cmyk(r, g, b, pis, out, dev->memory); else { frac c = frac_1 - r, m = frac_1 - g, y = frac_1 - b; frac k = min(c, min(m, g)); diff --git a/gs/base/gxcmap.c b/gs/base/gxcmap.c index d19dbeaaf..c5b83920d 100644 --- a/gs/base/gxcmap.c +++ b/gs/base/gxcmap.c @@ -226,7 +226,7 @@ rgb_cs_to_rgb_cm(gx_device * dev, const gs_imager_state *pis, static void cmyk_cs_to_rgb_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[]) { - color_cmyk_to_rgb(c, m, y, k, NULL, out); + color_cmyk_to_rgb(c, m, y, k, NULL, out, dev->memory); } static void @@ -261,7 +261,7 @@ cmyk_cs_to_rgbk_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[]) out[3] = frac_1 - k; } else { - color_cmyk_to_rgb(c, m, y, k, NULL, rgb); + color_cmyk_to_rgb(c, m, y, k, NULL, rgb, dev->memory); rgb_cs_to_rgbk_cm(dev, NULL, rgb[0], rgb[1], rgb[2], out); } } @@ -293,7 +293,7 @@ rgb_cs_to_cmyk_cm(gx_device * dev, const gs_imager_state *pis, frac r, frac g, frac b, frac out[]) { if (pis != 0) - color_rgb_to_cmyk(r, g, b, pis, out); + color_rgb_to_cmyk(r, g, b, pis, out, dev->memory); else { frac c = frac_1 - r, m = frac_1 - g, y = frac_1 - b; frac k = min(c, min(m, y)); @@ -1549,7 +1549,7 @@ gx_default_map_cmyk_color(gx_device * dev, const gx_color_value cv[]) frac rgb[3]; gx_color_value rgb_cv[3]; color_cmyk_to_rgb(cv2frac(cv[0]), cv2frac(cv[1]), cv2frac(cv[2]), cv2frac(cv[3]), - NULL, rgb); + NULL, rgb, dev->memory); rgb_cv[0] = frac2cv(rgb[0]); rgb_cv[1] = frac2cv(rgb[1]); rgb_cv[2] = frac2cv(rgb[2]); diff --git a/gs/base/gxdcconv.c b/gs/base/gxdcconv.c index b1029a14c..d9aa060b1 100644 --- a/gs/base/gxdcconv.c +++ b/gs/base/gxdcconv.c @@ -22,8 +22,6 @@ #include "gxlum.h" #include "gxistate.h" -extern bool CPSI_mode; /* not worth polluting a header file */ - /* * The CMYK to RGB algorithms specified by Adobe are, e.g., * R = 1.0 - min(1.0, C + K) @@ -56,7 +54,7 @@ color_rgb_to_gray(frac r, frac g, frac b, const gs_imager_state * pis) /* Note that this involves black generation and undercolor removal. */ void color_rgb_to_cmyk(frac r, frac g, frac b, const gs_imager_state * pis, - frac cmyk[4]) + frac cmyk[4], gs_memory_t *mem) { frac c = frac_1 - r, m = frac_1 - g, y = frac_1 - b; frac k = (c < m ? min(c, y) : min(m, y)); @@ -77,7 +75,7 @@ color_rgb_to_cmyk(frac r, frac g, frac b, const gs_imager_state * pis, else if (ucr == frac_0) cmyk[0] = c, cmyk[1] = m, cmyk[2] = y; else { - if (! CPSI_mode) { + if (!gs_currentcpsimode(mem)) { /* C = max(0.0, min(1.0, 1 - R - UCR)), etc. */ signed_frac not_ucr = (ucr < 0 ? frac_1 + ucr : frac_1); @@ -119,7 +117,7 @@ color_cmyk_to_gray(frac c, frac m, frac y, frac k, const gs_imager_state * pis) /* Convert CMYK to RGB. */ void color_cmyk_to_rgb(frac c, frac m, frac y, frac k, const gs_imager_state * pis, - frac rgb[3]) + frac rgb[3], gs_memory_t *mem) { switch (k) { case frac_0: @@ -131,7 +129,7 @@ color_cmyk_to_rgb(frac c, frac m, frac y, frac k, const gs_imager_state * pis, rgb[0] = rgb[1] = rgb[2] = frac_0; break; default: - if (! CPSI_mode) { + if (!gs_currentcpsimode(mem)) { /* R = 1.0 - min(1.0, C + K), etc. */ frac not_k = frac_1 - k; diff --git a/gs/base/gxdcconv.h b/gs/base/gxdcconv.h index b7596123a..25cc25dc0 100644 --- a/gs/base/gxdcconv.h +++ b/gs/base/gxdcconv.h @@ -23,10 +23,12 @@ frac color_rgb_to_gray(frac r, frac g, frac b, const gs_imager_state * pis); void color_rgb_to_cmyk(frac r, frac g, frac b, - const gs_imager_state * pis, frac cmyk[4]); + const gs_imager_state * pis, frac cmyk[4], + gs_memory_t * mem); frac color_cmyk_to_gray(frac c, frac m, frac y, frac k, const gs_imager_state * pis); void color_cmyk_to_rgb(frac c, frac m, frac y, frac k, - const gs_imager_state * pis, frac rgb[3]); + const gs_imager_state * pis, frac rgb[3], + gs_memory_t * mem); #endif /* gxdcconv_INCLUDED */ diff --git a/gs/base/gxfill.c b/gs/base/gxfill.c index f356ced5b..07e100224 100644 --- a/gs/base/gxfill.c +++ b/gs/base/gxfill.c @@ -279,7 +279,6 @@ gx_general_fill_path(gx_device * pdev, const gs_imager_state * pis, bool big_path = ppath->subpath_count > 50; fill_options fo; line_list lst; - extern bool CPSI_mode; *(const fill_options **)&lst.fo = &fo; /* break 'const'. */ /* @@ -478,7 +477,7 @@ gx_general_fill_path(gx_device * pdev, const gs_imager_state * pis, init_section(lst.margin_set0.sect, 0, lst.bbox_width); init_section(lst.margin_set1.sect, 0, lst.bbox_width); } - if (CPSI_mode && is_character) { + if (gs_currentcpsimode(pis->memory) && is_character) { if (lst.contour_count > countof(lst.local_windings)) { lst.windings = (int *)gs_alloc_byte_array(pdev->memory, lst.contour_count, sizeof(int), "gx_general_fill_path"); diff --git a/gs/base/gxicolor.c b/gs/base/gxicolor.c index 4a2dcb4c7..07c7d0957 100644 --- a/gs/base/gxicolor.c +++ b/gs/base/gxicolor.c @@ -345,7 +345,7 @@ do3: if(spp == 3 && pcs->type->index == gs_color_space_index_CIEICC) color_cmyk_to_rgb(byte2frac(psrc[0]), byte2frac(psrc[1]), byte2frac(psrc[2]), byte2frac(psrc[3]), - pis, rgb); + pis, rgb, dev->memory); /* * It seems silly to do all this converting between * fracs and bytes, but that's what the current diff --git a/gs/base/gxstroke.c b/gs/base/gxstroke.c index 1c16f3378..62b63d0fa 100644 --- a/gs/base/gxstroke.c +++ b/gs/base/gxstroke.c @@ -410,7 +410,7 @@ gx_stroke_path_only_aux(gx_path * ppath, gx_path * to_path, gx_device * pdev, const gs_imager_state * pis, const gx_stroke_params * params, const gx_device_color * pdevc, const gx_clip_path * pcpath) { - extern bool CPSI_mode; + bool CPSI_mode = gs_currentcpsimode(pis->memory); bool traditional = CPSI_mode | params->traditional; stroke_line_proc_t line_proc = ((to_path == 0 && !gx_dc_is_pattern1_color_clist_based(pdevc)) diff --git a/gs/contrib/opvp/gdevopvp.c b/gs/contrib/opvp/gdevopvp.c index c391f90a9..98a616fb3 100644 --- a/gs/contrib/opvp/gdevopvp.c +++ b/gs/contrib/opvp/gdevopvp.c @@ -85,55 +85,55 @@ #include "opvp_common.h" -#define ENABLE_SIMPLE_MODE 1 -#define ENABLE_SKIP_RASTER 1 -#define ENABLE_AUTO_REVERSE 1 +#define ENABLE_SIMPLE_MODE 1 +#define ENABLE_SKIP_RASTER 1 +#define ENABLE_AUTO_REVERSE 1 /* ----- data types/macros ----- */ /* for debug */ -#ifdef printf -#undef printf +#ifdef printf +#undef printf #endif -#ifdef fprintf -#undef fprintf +#ifdef fprintf +#undef fprintf #endif /* buffer */ -#define OPVP_BUFF_SIZE 1024 +#define OPVP_BUFF_SIZE 1024 /* ROP */ -#define OPVP_0_2_ROP_S 0xCC -#define OPVP_0_2_ROP_P 0xF0 -#define OPVP_0_2_ROP_OR 0xB8 +#define OPVP_0_2_ROP_S 0xCC +#define OPVP_0_2_ROP_P 0xF0 +#define OPVP_0_2_ROP_OR 0xB8 /* paper */ -#define PS_DPI 72 -#define MMPI 25.4 -#define TOLERANCE 3.0 +#define PS_DPI 72 +#define MMPI 25.4 +#define TOLERANCE 3.0 -typedef struct { +typedef struct { const char *region; const char *name; float width; float height; } OPVP_Paper; -#define X_DPI 300 -#define Y_DPI 300 +#define X_DPI 300 +#define Y_DPI 300 /* driver */ -typedef struct gx_device_opvp_s { +typedef struct gx_device_opvp_s { gx_device_vector_common; } gx_device_opvp; -typedef struct gx_device_oprp_s { +typedef struct gx_device_oprp_s { gx_device_common; gx_prn_device_common; } gx_device_oprp; /* point (internal) */ -typedef struct { +typedef struct { floatp x; floatp y; } _fPoint; @@ -141,69 +141,69 @@ typedef struct { /* ----- private function prototypes ----- */ /* Utilities */ -static int opvp_startpage(gx_device *); -static int opvp_endpage(void); -static char *opvp_alloc_string(char **, const char *); -static char *opvp_cat_string(char **, const char *); -static char *opvp_adjust_num_string(char *); -static char **opvp_gen_dynamic_lib_name(void); -static char *opvp_to_utf8(char *); -#define opvp_check_in_page(pdev) \ - ((beginPage) || (inkjet) ? 0 \ - : (*vdev_proc(pdev, beginpage))((gx_device_vector*)pdev)) -static int opvp_get_papertable_index(gx_device *); -static char *opvp_get_sizestring(float, float); -/* not used static const char *opvp_get_papersize_region(gx_device *);*/ -/* not used static const char *opvp_get_papersize_name(gx_device *);*/ -/* not used static char *opvp_get_papersize_inch(gx_device *);*/ -/* not used static const char *opvp_get_papersize(gx_device *);*/ -static char *opvp_get_mediasize(gx_device *); -static char *opvp_gen_page_info(gx_device *); -static char *opvp_gen_doc_info(gx_device *); -static char *opvp_gen_job_info(gx_device *); -static int opvp_set_brush_color(gx_device_opvp *, gx_color_index, +static int opvp_startpage(gx_device *); +static int opvp_endpage(void); +static char *opvp_alloc_string(char **, const char *); +static char *opvp_cat_string(char **, const char *); +static char *opvp_adjust_num_string(char *); +static char **opvp_gen_dynamic_lib_name(void); +static char *opvp_to_utf8(char *); +#define opvp_check_in_page(pdev) \ + ((beginPage) || (inkjet) ? 0 \ + : (*vdev_proc(pdev, beginpage))((gx_device_vector*)pdev)) +static int opvp_get_papertable_index(gx_device *); +static char *opvp_get_sizestring(float, float); +/* not used static const char *opvp_get_papersize_region(gx_device *);*/ +/* not used static const char *opvp_get_papersize_name(gx_device *);*/ +/* not used static char *opvp_get_papersize_inch(gx_device *);*/ +/* not used static const char *opvp_get_papersize(gx_device *);*/ +static char *opvp_get_mediasize(gx_device *); +static char *opvp_gen_page_info(gx_device *); +static char *opvp_gen_doc_info(gx_device *); +static char *opvp_gen_job_info(gx_device *); +static int opvp_set_brush_color(gx_device_opvp *, gx_color_index, opvp_brush_t *); -static int opvp_draw_image(gx_device_opvp *, int, +static int opvp_draw_image(gx_device_opvp *, int, int, int, int, int, int, int, const byte *); /* load/unload vector driver */ -static int opvp_load_vector_driver(void); -static int opvp_unload_vector_driver(void); -static int prepare_open(gx_device *); +static int opvp_load_vector_driver(void); +static int opvp_unload_vector_driver(void); +static int prepare_open(gx_device *); /* driver procs */ -static int opvp_open(gx_device *); -static int oprp_open(gx_device *); -static void opvp_get_initial_matrix(gx_device *, gs_matrix *); -static int opvp_output_page(gx_device *, int, int); -static int opvp_close(gx_device *); +static int opvp_open(gx_device *); +static int oprp_open(gx_device *); +static void opvp_get_initial_matrix(gx_device *, gs_matrix *); +static int opvp_output_page(gx_device *, int, int); +static int opvp_close(gx_device *); #if GS_VERSION_MAJOR >= 8 -static gx_color_index opvp_map_rgb_color(gx_device *, const gx_color_value *); /* modified for gs 8.15 */ +static gx_color_index opvp_map_rgb_color(gx_device *, const gx_color_value *); /* modified for gs 8.15 */ #else -static gx_color_index opvp_map_rgb_color(gx_device *, gx_color_value, - gx_color_value, gx_color_value); +static gx_color_index opvp_map_rgb_color(gx_device *, gx_color_value, + gx_color_value, gx_color_value); #endif -static int opvp_map_color_rgb(gx_device *, gx_color_index, gx_color_value *); -static int opvp_copy_mono(gx_device *, const byte *, int, int, +static int opvp_map_color_rgb(gx_device *, gx_color_index, gx_color_value *); +static int opvp_copy_mono(gx_device *, const byte *, int, int, gx_bitmap_id, int, int, int, int, gx_color_index, gx_color_index); -static int opvp_copy_color(gx_device *, const byte *, int, int, +static int opvp_copy_color(gx_device *, const byte *, int, int, gx_bitmap_id, int, int, int, int); -static int _get_params(gs_param_list *); -static int opvp_get_params(gx_device *, gs_param_list *); -static int oprp_get_params(gx_device *, gs_param_list *); -static int _put_params(gs_param_list *); -static int opvp_put_params(gx_device *, gs_param_list *); -static int oprp_put_params(gx_device *, gs_param_list *); -static int opvp_fill_path(gx_device *, const gs_imager_state *, gx_path *, - const gx_fill_params *, const gx_device_color *, - const gx_clip_path *); -static int opvp_stroke_path(gx_device *, const gs_imager_state *, gx_path *, - const gx_stroke_params *, const gx_drawing_color *, - const gx_clip_path *); -static int opvp_fill_mask(gx_device *, const byte *, int, int, gx_bitmap_id, - int, int, int, int, const gx_drawing_color *, - int, gs_logical_operation_t, const gx_clip_path *); +static int _get_params(gs_param_list *); +static int opvp_get_params(gx_device *, gs_param_list *); +static int oprp_get_params(gx_device *, gs_param_list *); +static int _put_params(gs_param_list *); +static int opvp_put_params(gx_device *, gs_param_list *); +static int oprp_put_params(gx_device *, gs_param_list *); +static int opvp_fill_path(gx_device *, const gs_imager_state *, gx_path *, + const gx_fill_params *, const gx_device_color *, + const gx_clip_path *); +static int opvp_stroke_path(gx_device *, const gs_imager_state *, gx_path *, + const gx_stroke_params *, const gx_drawing_color *, + const gx_clip_path *); +static int opvp_fill_mask(gx_device *, const byte *, int, int, gx_bitmap_id, + int, int, int, int, const gx_drawing_color *, + int, gs_logical_operation_t, const gx_clip_path *); /* available color spaces */ @@ -219,75 +219,75 @@ static char cspace_available[] = { }; /* vector driver procs */ -static int opvp_beginpage(gx_device_vector *); -static int opvp_setlinewidth(gx_device_vector *, floatp); -static int opvp_setlinecap(gx_device_vector *, gs_line_cap); -static int opvp_setlinejoin(gx_device_vector *, gs_line_join); -static int opvp_setmiterlimit(gx_device_vector *, floatp); -static int opvp_setdash(gx_device_vector *, const float *, uint, floatp); -static int opvp_setflat(gx_device_vector *, floatp); -static int opvp_setlogop(gx_device_vector *, gs_logical_operation_t, - gs_logical_operation_t); +static int opvp_beginpage(gx_device_vector *); +static int opvp_setlinewidth(gx_device_vector *, floatp); +static int opvp_setlinecap(gx_device_vector *, gs_line_cap); +static int opvp_setlinejoin(gx_device_vector *, gs_line_join); +static int opvp_setmiterlimit(gx_device_vector *, floatp); +static int opvp_setdash(gx_device_vector *, const float *, uint, floatp); +static int opvp_setflat(gx_device_vector *, floatp); +static int opvp_setlogop(gx_device_vector *, gs_logical_operation_t, + gs_logical_operation_t); #if GS_VERSION_MAJOR >= 8 -static int opvp_can_handle_hl_color(gx_device_vector *, const gs_imager_state *, const gx_drawing_color *); -static int opvp_setfillcolor(gx_device_vector *, const gs_imager_state *, const gx_drawing_color *); -static int opvp_setstrokecolor(gx_device_vector *, const gs_imager_state *,const gx_drawing_color *); +static int opvp_can_handle_hl_color(gx_device_vector *, const gs_imager_state *, const gx_drawing_color *); +static int opvp_setfillcolor(gx_device_vector *, const gs_imager_state *, const gx_drawing_color *); +static int opvp_setstrokecolor(gx_device_vector *, const gs_imager_state *,const gx_drawing_color *); #else -static int opvp_setfillcolor(gx_device_vector *, const gx_drawing_color *); -static int opvp_setstrokecolor(gx_device_vector *, const gx_drawing_color *); +static int opvp_setfillcolor(gx_device_vector *, const gx_drawing_color *); +static int opvp_setstrokecolor(gx_device_vector *, const gx_drawing_color *); #endif -static int opvp_vector_dopath(gx_device_vector *, const gx_path *, - gx_path_type_t, const gs_matrix *); -static int opvp_vector_dorect(gx_device_vector *, fixed, fixed, fixed, fixed, - gx_path_type_t); -static int opvp_beginpath(gx_device_vector *, gx_path_type_t); -static int opvp_moveto(gx_device_vector *, floatp, floatp, floatp, floatp, - gx_path_type_t); -static int opvp_lineto(gx_device_vector *, floatp, floatp, floatp, floatp, - gx_path_type_t); -static int opvp_curveto(gx_device_vector *, floatp, floatp, floatp, floatp, - floatp, floatp, floatp, floatp, gx_path_type_t); -static int opvp_closepath(gx_device_vector *, floatp, floatp, floatp, floatp, - gx_path_type_t); -static int opvp_endpath(gx_device_vector *, gx_path_type_t); +static int opvp_vector_dopath(gx_device_vector *, const gx_path *, + gx_path_type_t, const gs_matrix *); +static int opvp_vector_dorect(gx_device_vector *, fixed, fixed, fixed, fixed, + gx_path_type_t); +static int opvp_beginpath(gx_device_vector *, gx_path_type_t); +static int opvp_moveto(gx_device_vector *, floatp, floatp, floatp, floatp, + gx_path_type_t); +static int opvp_lineto(gx_device_vector *, floatp, floatp, floatp, floatp, + gx_path_type_t); +static int opvp_curveto(gx_device_vector *, floatp, floatp, floatp, floatp, + floatp, floatp, floatp, floatp, gx_path_type_t); +static int opvp_closepath(gx_device_vector *, floatp, floatp, floatp, floatp, + gx_path_type_t); +static int opvp_endpath(gx_device_vector *, gx_path_type_t); /* ----- Paper definition ----- */ -OPVP_Paper paperTable[] = +OPVP_Paper paperTable[] = { #if 0 - {"jpn","hagaki",100/MMPI*PS_DPI,148/MMPI*PS_DPI}, - {"iso","a6" ,105/MMPI*PS_DPI,148/MMPI*PS_DPI}, - {"jis","b6" ,128/MMPI*PS_DPI,182/MMPI*PS_DPI}, - {"jpn","oufuku",148/MMPI*PS_DPI,200/MMPI*PS_DPI}, - {"iso","a5" ,148/MMPI*PS_DPI,210/MMPI*PS_DPI}, - {"jis","b5" ,182/MMPI*PS_DPI,257/MMPI*PS_DPI}, - {"iso","a4" ,210/MMPI*PS_DPI,297/MMPI*PS_DPI}, - {"na" ,"letter", 8.5*PS_DPI, 11*PS_DPI},/* 215.9x279.4 */ - {"na" ,"legal" , 8.5*PS_DPI, 14*PS_DPI},/* 215.9x355.6 */ - {"jis","b4" ,257/MMPI*PS_DPI,364/MMPI*PS_DPI}, - {"iso","a3" ,297/MMPI*PS_DPI,420/MMPI*PS_DPI}, + {"jpn","hagaki",100/MMPI*PS_DPI,148/MMPI*PS_DPI}, + {"iso","a6" ,105/MMPI*PS_DPI,148/MMPI*PS_DPI}, + {"jis","b6" ,128/MMPI*PS_DPI,182/MMPI*PS_DPI}, + {"jpn","oufuku",148/MMPI*PS_DPI,200/MMPI*PS_DPI}, + {"iso","a5" ,148/MMPI*PS_DPI,210/MMPI*PS_DPI}, + {"jis","b5" ,182/MMPI*PS_DPI,257/MMPI*PS_DPI}, + {"iso","a4" ,210/MMPI*PS_DPI,297/MMPI*PS_DPI}, + {"na" ,"letter", 8.5*PS_DPI, 11*PS_DPI},/* 215.9x279.4 */ + {"na" ,"legal" , 8.5*PS_DPI, 14*PS_DPI},/* 215.9x355.6 */ + {"jis","b4" ,257/MMPI*PS_DPI,364/MMPI*PS_DPI}, + {"iso","a3" ,297/MMPI*PS_DPI,420/MMPI*PS_DPI}, #else #include "opvp_media.def" #endif - {NULL ,NULL , 0, 0} + {NULL ,NULL , 0, 0} }; /* ----- Driver definition ----- */ /* Driver procedures */ -static dev_proc_open_device(opvp_open); -static dev_proc_open_device(oprp_open); -static dev_proc_output_page(opvp_output_page); -static dev_proc_print_page(oprp_print_page); -static dev_proc_close_device(opvp_close); -static dev_proc_get_params(opvp_get_params); -static dev_proc_get_params(oprp_get_params); -static dev_proc_put_params(opvp_put_params); -static dev_proc_put_params(oprp_put_params); -static dev_proc_fill_rectangle(opvp_fill_rectangle); -static dev_proc_begin_image(opvp_begin_image); -static image_enum_proc_plane_data(opvp_image_plane_data); -static image_enum_proc_end_image(opvp_image_end_image); +static dev_proc_open_device(opvp_open); +static dev_proc_open_device(oprp_open); +static dev_proc_output_page(opvp_output_page); +static dev_proc_print_page(oprp_print_page); +static dev_proc_close_device(opvp_close); +static dev_proc_get_params(opvp_get_params); +static dev_proc_get_params(oprp_get_params); +static dev_proc_put_params(opvp_put_params); +static dev_proc_put_params(oprp_put_params); +static dev_proc_fill_rectangle(opvp_fill_rectangle); +static dev_proc_begin_image(opvp_begin_image); +static image_enum_proc_plane_data(opvp_image_plane_data); +static image_enum_proc_end_image(opvp_image_end_image); gs_public_st_suffix_add0_final( st_device_opvp, @@ -299,21 +299,21 @@ gs_public_st_suffix_add0_final( st_device_vector ); -#define opvp_initial_values \ +#define opvp_initial_values \ NULL, /* *vectorDriver */\ NULL, /* *printerModel */\ NULL, /* *handle */\ NULL, /* (*OpenPrinter)() */\ NULL, /* *ErrorNo */\ - -1, /* outputFD */\ - 0, /* nApiEntry */\ + -1, /* outputFD */\ + 0, /* nApiEntry */\ NULL, /* *apiEntry */\ - -1, /* printerContext */\ + -1, /* printerContext */\ NULL, /* *jobInfo */\ NULL /* *docInfo */ /* device procs */ -#define opvp_procs \ +#define opvp_procs \ {\ opvp_open,\ opvp_get_initial_matrix,\ @@ -368,7 +368,7 @@ gs_public_st_suffix_add0_final( /* vector procs */ -static gx_device_vector_procs opvp_vector_procs = +static gx_device_vector_procs opvp_vector_procs = { /* Page management */ opvp_beginpage, @@ -382,7 +382,7 @@ static gx_device_vector_procs opvp_vector_procs = opvp_setlogop, /* Other state */ #if GS_VERSION_MAJOR >= 8 - opvp_can_handle_hl_color, /* added for gs 8.15 */ + opvp_can_handle_hl_color, /* added for gs 8.15 */ #endif opvp_setfillcolor, opvp_setstrokecolor, @@ -397,52 +397,52 @@ static gx_device_vector_procs opvp_vector_procs = opvp_endpath }; -const gx_device_opvp gs_opvp_device = +const gx_device_opvp gs_opvp_device = { std_device_dci_type_body( - gx_device_opvp, - 0, - "opvp", - &st_device_opvp, - DEFAULT_WIDTH_10THS_A4 * X_DPI / 10, - DEFAULT_HEIGHT_10THS_A4 * Y_DPI / 10, - X_DPI, - Y_DPI, - 3, - 24, - 255, - 255, - 256, - 256 + gx_device_opvp, + 0, + "opvp", + &st_device_opvp, + DEFAULT_WIDTH_10THS_A4 * X_DPI / 10, + DEFAULT_HEIGHT_10THS_A4 * Y_DPI / 10, + X_DPI, + Y_DPI, + 3, + 24, + 255, + 255, + 256, + 256 ), opvp_procs }; /* for inkjet */ -static gx_device_procs prn_oprp_procs = +static gx_device_procs prn_oprp_procs = prn_color_params_procs( - oprp_open, - opvp_output_page, - opvp_close, - opvp_map_rgb_color, - opvp_map_color_rgb, - oprp_get_params, - oprp_put_params + oprp_open, + opvp_output_page, + opvp_close, + opvp_map_rgb_color, + opvp_map_color_rgb, + oprp_get_params, + oprp_put_params ); const gx_device_oprp gs_oprp_device = { prn_device_std_margins_body( - gx_device_oprp, - prn_oprp_procs, - "oprp", - DEFAULT_WIDTH_10THS_A4, - DEFAULT_HEIGHT_10THS_A4, - X_DPI, - Y_DPI, - 0, 0, 0, 0, 0, 0, - 24, - oprp_print_page + gx_device_oprp, + prn_oprp_procs, + "oprp", + DEFAULT_WIDTH_10THS_A4, + DEFAULT_HEIGHT_10THS_A4, + X_DPI, + Y_DPI, + 0, 0, 0, 0, 0, 0, + 24, + oprp_print_page ) }; @@ -454,9 +454,9 @@ static char *printerModel = NULL; static void *handle = NULL; static opvp_dc_t (*OpenPrinter)(opvp_int_t,const opvp_char_t*, const opvp_int_t[2], - opvp_api_procs_t**) = NULL; + opvp_api_procs_t**) = NULL; static int (*OpenPrinter_0_2)(int,char*,int*, - OPVP_api_procs**) = NULL; + OPVP_api_procs**) = NULL; static opvp_int_t *ErrorNo = NULL; static opvp_int_t outputFD = -1; static opvp_int_t nApiEntry = 0; @@ -534,25 +534,25 @@ GetLastError_0_2(void) { switch(*ErrorNo) { case OPVP_FATALERROR_0_2: - return OPVP_FATALERROR; - break; + return OPVP_FATALERROR; + break; case OPVP_BADREQUEST_0_2: - return OPVP_BADREQUEST; - break; + return OPVP_BADREQUEST; + break; case OPVP_BADCONTEXT_0_2: - return OPVP_BADCONTEXT; - break; + return OPVP_BADCONTEXT; + break; case OPVP_NOTSUPPORTED_0_2: - return OPVP_NOTSUPPORTED; - break; + return OPVP_NOTSUPPORTED; + break; case OPVP_JOBCANCELED_0_2: - return OPVP_JOBCANCELED; - break; + return OPVP_JOBCANCELED; + break; case OPVP_PARAMERROR_0_2: - return OPVP_PARAMERROR; - break; + return OPVP_PARAMERROR; + break; default: - break; + break; } /* unknown error no */ /* return FATALERROR instead */ @@ -566,13 +566,13 @@ StartPageWrapper(opvp_dc_t printerContext, const opvp_char_t *pageInfo) if ((r = apiEntry_0_2->StartPage(printerContext, /* discard const */(char *)pageInfo)) != OPVP_OK) { - /* error */ - return r; + /* error */ + return r; } /* initialize ROP */ if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext, - OPVP_0_2_ROP_P); + apiEntry_0_2->SetROP(printerContext, + OPVP_0_2_ROP_P); } return OPVP_OK; } @@ -583,13 +583,13 @@ InitGSWrapper(opvp_dc_t printerContext) int r; if ((r = apiEntry_0_2->InitGS(printerContext)) != OPVP_OK) { - /* error */ - return r; + /* error */ + return r; } /* initialize ROP */ if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext, - OPVP_0_2_ROP_P); + apiEntry_0_2->SetROP(printerContext, + OPVP_0_2_ROP_P); } return OPVP_OK; } @@ -602,20 +602,20 @@ QueryColorSpaceWrapper( opvp_dc_t printerContext, opvp_int_t *pnum, int i; if ((r = apiEntry_0_2->QueryColorSpace(printerContext, - (OPVP_ColorSpace *)pcspace,pnum)) != OPVP_OK) { - /* error */ - return r; + (OPVP_ColorSpace *)pcspace,pnum)) != OPVP_OK) { + /* error */ + return r; } /* translate cspaces */ for (i = 0;i < *pnum;i++) { - if (pcspace[i] - >= sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) { - /* unknown color space */ - /* set DEVICERGB instead */ - pcspace[i] = OPVP_CSPACE_DEVICERGB; - } else { - pcspace[i] = cspace_0_2_to_1_0[pcspace[i]]; - } + if (pcspace[i] + >= sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) { + /* unknown color space */ + /* set DEVICERGB instead */ + pcspace[i] = OPVP_CSPACE_DEVICERGB; + } else { + pcspace[i] = cspace_0_2_to_1_0[pcspace[i]]; + } } return OPVP_OK; } @@ -624,15 +624,15 @@ static opvp_result_t SetColorSpaceWrapper(opvp_dc_t printerContext, opvp_cspace_t cspace) { if (cspace == OPVP_CSPACE_DEVICEKRGB) { - /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ - *ErrorNo = OPVP_NOTSUPPORTED_0_2; - return -1; + /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ + *ErrorNo = OPVP_NOTSUPPORTED_0_2; + return -1; } if (cspace - >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { - /* unknown color space */ - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { + /* unknown color space */ + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } return apiEntry_0_2->SetColorSpace(printerContext, cspace_1_0_to_0_2[cspace]); @@ -645,16 +645,16 @@ GetColorSpaceWrapper(opvp_dc_t printerContext, opvp_cspace_t *pcspace) if ((r = apiEntry_0_2->GetColorSpace(printerContext, (OPVP_ColorSpace *)pcspace)) != OPVP_OK) { - /* error */ - return r; + /* error */ + return r; } if (*pcspace - >= sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) { - /* unknown color space */ - /* set DEVICERGB instead */ - *pcspace = OPVP_CSPACE_DEVICERGB; + >= sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) { + /* unknown color space */ + /* set DEVICERGB instead */ + *pcspace = OPVP_CSPACE_DEVICERGB; } else { - *pcspace = cspace_0_2_to_1_0[*pcspace]; + *pcspace = cspace_0_2_to_1_0[*pcspace]; } return r; } @@ -665,18 +665,18 @@ SetStrokeColorWrapper(opvp_dc_t printerContext, const opvp_brush_t *brush) OPVP_Brush brush_0_2; if (brush == NULL) { - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) { - /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ - return OPVP_NOTSUPPORTED; + /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ + return OPVP_NOTSUPPORTED; } if (brush->colorSpace - >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { - /* unknown color space */ - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { + /* unknown color space */ + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace]; brush_0_2.xorg = brush->xorg; @@ -692,18 +692,18 @@ SetFillColorWrapper(opvp_dc_t printerContext, const opvp_brush_t *brush) OPVP_Brush brush_0_2; if (brush == NULL) { - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) { - /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ - return OPVP_NOTSUPPORTED; + /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ + return OPVP_NOTSUPPORTED; } if (brush->colorSpace - >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { - /* unknown color space */ - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { + /* unknown color space */ + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace]; brush_0_2.xorg = brush->xorg; @@ -719,19 +719,19 @@ SetBgColorWrapper(opvp_dc_t printerContext, const opvp_brush_t *brush) OPVP_Brush brush_0_2; if (brush == NULL) { - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) { - /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ - *ErrorNo = OPVP_NOTSUPPORTED_0_2; - return -1; + /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */ + *ErrorNo = OPVP_NOTSUPPORTED_0_2; + return -1; } if (brush->colorSpace - >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { - /* unknown color space */ - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + >= sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) { + /* unknown color space */ + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace]; brush_0_2.xorg = brush->xorg; @@ -759,28 +759,28 @@ DrawImageWrapper( int depth; if (imageFormat == OPVP_IFORMAT_MASK) { - if (apiEntry_0_2->GetPaintMode != NULL) { - apiEntry_0_2->GetPaintMode(printerContext, - &paintmode_0_2); - } - if (paintmode_0_2 != OPVP_paintModeTransparent) { - if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext, - OPVP_0_2_ROP_S); - } - } - else { - if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext, - OPVP_0_2_ROP_OR); - } - } - depth = 1; + if (apiEntry_0_2->GetPaintMode != NULL) { + apiEntry_0_2->GetPaintMode(printerContext, + &paintmode_0_2); + } + if (paintmode_0_2 != OPVP_paintModeTransparent) { + if (apiEntry_0_2->SetROP != NULL) { + apiEntry_0_2->SetROP(printerContext, + OPVP_0_2_ROP_S); + } + } + else { + if (apiEntry_0_2->SetROP != NULL) { + apiEntry_0_2->SetROP(printerContext, + OPVP_0_2_ROP_OR); + } + } + depth = 1; } else { - if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_S); - } - depth = colorDepth_0_2[colorSpace]; + if (apiEntry_0_2->SetROP != NULL) { + apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_S); + } + depth = colorDepth_0_2[colorSpace]; } OPVP_I2FIX(0,rect.p0.x); @@ -788,15 +788,15 @@ DrawImageWrapper( OPVP_I2FIX(destinationWidth,rect.p1.x); OPVP_I2FIX(destinationHeight,rect.p1.y); if (imageFormat >= sizeof(iformat_1_0_to_0_2)/sizeof(OPVP_ImageFormat)) { - /* illegal image format */ - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + /* illegal image format */ + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } iformat_0_2 = iformat_1_0_to_0_2[imageFormat]; r = apiEntry_0_2->DrawImage(printerContext,sourceWidth,sourceHeight, - depth,iformat_0_2,rect, - sourcePitch*sourceHeight, - /* remove const */ (void *)imagedata); + depth,iformat_0_2,rect, + sourcePitch*sourceHeight, + /* remove const */ (void *)imagedata); if (apiEntry_0_2->SetROP != NULL) { apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_P); @@ -822,26 +822,26 @@ StartDrawImageWrapper( int depth; if (imageFormat == OPVP_IFORMAT_MASK) { - if (apiEntry_0_2->GetPaintMode != NULL) { - apiEntry_0_2->GetPaintMode(printerContext, - &paintmode_0_2); - } - if (paintmode_0_2 != OPVP_paintModeTransparent) { - if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_S); - } - } - else { - if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_OR); - } - } - depth = 1; + if (apiEntry_0_2->GetPaintMode != NULL) { + apiEntry_0_2->GetPaintMode(printerContext, + &paintmode_0_2); + } + if (paintmode_0_2 != OPVP_paintModeTransparent) { + if (apiEntry_0_2->SetROP != NULL) { + apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_S); + } + } + else { + if (apiEntry_0_2->SetROP != NULL) { + apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_OR); + } + } + depth = 1; } else { - if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_S); - } - depth = colorDepth_0_2[colorSpace]; + if (apiEntry_0_2->SetROP != NULL) { + apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_S); + } + depth = colorDepth_0_2[colorSpace]; } OPVP_I2FIX(0,rect.p0.x); @@ -849,14 +849,14 @@ StartDrawImageWrapper( OPVP_I2FIX(destinationWidth,rect.p1.x); OPVP_I2FIX(destinationHeight,rect.p1.y); if (imageFormat >= sizeof(iformat_1_0_to_0_2)/sizeof(OPVP_ImageFormat)) { - /* illegal image format */ - *ErrorNo = OPVP_PARAMERROR_0_2; - return -1; + /* illegal image format */ + *ErrorNo = OPVP_PARAMERROR_0_2; + return -1; } iformat_0_2 = iformat_1_0_to_0_2[imageFormat]; r = apiEntry_0_2->StartDrawImage(printerContext, - sourceWidth,sourceHeight, - depth,iformat_0_2,rect); + sourceWidth,sourceHeight, + depth,iformat_0_2,rect); return r; } @@ -870,7 +870,7 @@ EndDrawImageWrapper(opvp_dc_t printerContext) /* make sure rop is pattern copy */ if (apiEntry_0_2->SetROP != NULL) { - apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_P); + apiEntry_0_2->SetROP(printerContext,OPVP_0_2_ROP_P); } return r; @@ -895,12 +895,12 @@ QueryDeviceInfoWrapper( opvp_char_t *infoBuf) { if (queryflag & OPVP_QF_MEDIACOPY) { - *ErrorNo = OPVP_NOTSUPPORTED; - return -1; + *ErrorNo = OPVP_NOTSUPPORTED; + return -1; } if (queryflag & OPVP_QF_PRINTREGION) { - queryflag &= ~OPVP_QF_PRINTREGION; - queryflag |= 0x0020000; + queryflag &= ~OPVP_QF_PRINTREGION; + queryflag |= 0x0020000; } return apiEntry_0_2->QueryDeviceInfo(printerContext,queryflag, *buflen,(char *)infoBuf); @@ -932,236 +932,236 @@ OpenPrinterWrapper( opvp_dc_t dc = -1; if (OpenPrinter != NULL) { - dc = (*OpenPrinter)(outputFD,printerModel,apiVersion,apiProcs); + dc = (*OpenPrinter)(outputFD,printerModel,apiVersion,apiProcs); } else { - /* try version 0.2 */ - - if (OpenPrinter_0_2 != NULL) { - static opvp_api_procs_t tEntry; - int nApiEntry; - - dc = (*OpenPrinter_0_2)(outputFD, - /* remove const */ - (char *)printerModel, - &nApiEntry,&apiEntry_0_2); - /* setting functions */ - tEntry.opvpClosePrinter - = apiEntry_0_2->ClosePrinter; - tEntry.opvpStartJob - = (opvp_result_t (*)(opvp_int_t, - const opvp_char_t*)) - apiEntry_0_2->StartJob; - tEntry.opvpEndJob = apiEntry_0_2->EndJob; - tEntry.opvpAbortJob = NULL; - tEntry.opvpStartDoc - = (opvp_result_t (*)(opvp_dc_t, - const opvp_char_t*)) - apiEntry_0_2->StartDoc; - tEntry.opvpEndDoc = apiEntry_0_2->EndDoc; - if (apiEntry_0_2->StartPage != NULL) { - tEntry.opvpStartPage = StartPageWrapper; - } else { - tEntry.opvpStartPage = NULL; - } - tEntry.opvpEndPage = apiEntry_0_2->EndPage; - - if (apiEntry_0_2->QueryDeviceCapability != NULL) { - tEntry.opvpQueryDeviceCapability - = QueryDeviceCapabilityWrapper; - } else { - tEntry.opvpQueryDeviceCapability = NULL; - } - - if (apiEntry_0_2->QueryDeviceInfo != NULL) { - tEntry.opvpQueryDeviceInfo = QueryDeviceInfoWrapper; - } else { - tEntry.opvpQueryDeviceInfo = NULL; - } - - tEntry.opvpResetCTM = apiEntry_0_2->ResetCTM; - tEntry.opvpSetCTM = (opvp_result_t (*)(opvp_dc_t, - const opvp_ctm_t*)) - apiEntry_0_2->SetCTM; - tEntry.opvpGetCTM = (opvp_result_t (*)(opvp_dc_t,opvp_ctm_t*)) - apiEntry_0_2->GetCTM; - if (apiEntry_0_2->InitGS != NULL) { - tEntry.opvpInitGS = InitGSWrapper; - } else { - tEntry.opvpInitGS = NULL; - } - tEntry.opvpSaveGS = apiEntry_0_2->SaveGS; - tEntry.opvpRestoreGS = apiEntry_0_2->RestoreGS; - if (apiEntry_0_2->QueryColorSpace != NULL) { - tEntry.opvpQueryColorSpace = QueryColorSpaceWrapper; - } else { - tEntry.opvpQueryColorSpace = NULL; - } - if (apiEntry_0_2->SetColorSpace != NULL) { - tEntry.opvpSetColorSpace = SetColorSpaceWrapper; - } else { - tEntry.opvpSetColorSpace = NULL; - } - if (apiEntry_0_2->GetColorSpace != NULL) { - tEntry.opvpGetColorSpace = GetColorSpaceWrapper; - } else { - tEntry.opvpGetColorSpace = NULL; - } - tEntry.opvpSetFillMode - = (opvp_result_t (*)(opvp_dc_t,opvp_fillmode_t)) - apiEntry_0_2->SetFillMode; - tEntry.opvpGetFillMode - = (opvp_result_t (*)(opvp_dc_t,opvp_fillmode_t*)) - apiEntry_0_2->GetFillMode; - tEntry.opvpSetAlphaConstant = apiEntry_0_2->SetAlphaConstant; - tEntry.opvpGetAlphaConstant = apiEntry_0_2->GetAlphaConstant; - tEntry.opvpSetLineWidth = apiEntry_0_2->SetLineWidth; - tEntry.opvpGetLineWidth = apiEntry_0_2->GetLineWidth; - if (apiEntry_0_2->SetLineDash != NULL) { - tEntry.opvpSetLineDash = SetLineDashWrapper; - } else { - tEntry.opvpSetLineDash = NULL; - } - if (apiEntry_0_2->GetLineDash != NULL) { - tEntry.opvpGetLineDash = GetLineDashWrapper; - } else { - tEntry.opvpGetLineDash = NULL; - } - tEntry.opvpSetLineDashOffset - = apiEntry_0_2->SetLineDashOffset; - tEntry.opvpGetLineDashOffset - = apiEntry_0_2->GetLineDashOffset; - tEntry.opvpSetLineStyle - = (opvp_result_t (*)(opvp_dc_t,opvp_linestyle_t)) - apiEntry_0_2->SetLineStyle; - tEntry.opvpGetLineStyle - = (opvp_result_t (*)(opvp_dc_t,opvp_linestyle_t*)) - apiEntry_0_2->GetLineStyle; - tEntry.opvpSetLineCap - = (opvp_result_t (*)(opvp_dc_t,opvp_linecap_t)) - apiEntry_0_2->SetLineCap; - tEntry.opvpGetLineCap - = (opvp_result_t (*)(opvp_dc_t,opvp_linecap_t*)) - apiEntry_0_2->GetLineCap; - tEntry.opvpSetLineJoin - = (opvp_result_t (*)(opvp_dc_t,opvp_linejoin_t)) - apiEntry_0_2->SetLineJoin; - tEntry.opvpGetLineJoin - = (opvp_result_t (*)(opvp_dc_t,opvp_linejoin_t*)) - apiEntry_0_2->GetLineJoin; - tEntry.opvpSetMiterLimit = apiEntry_0_2->SetMiterLimit; - tEntry.opvpGetMiterLimit = apiEntry_0_2->GetMiterLimit; - tEntry.opvpSetPaintMode - = (opvp_result_t (*)(opvp_dc_t,opvp_paintmode_t)) - apiEntry_0_2->SetPaintMode; - tEntry.opvpGetPaintMode - = (opvp_result_t (*)(opvp_dc_t,opvp_paintmode_t*)) - apiEntry_0_2->GetPaintMode; - if (apiEntry_0_2->SetStrokeColor != NULL) { - tEntry.opvpSetStrokeColor = SetStrokeColorWrapper; - } else { - tEntry.opvpSetStrokeColor = NULL; - } - if (apiEntry_0_2->SetFillColor != NULL) { - tEntry.opvpSetFillColor = SetFillColorWrapper; - } else { - tEntry.opvpSetFillColor = NULL; - } - if (apiEntry_0_2->SetBgColor != NULL) { - tEntry.opvpSetBgColor = SetBgColorWrapper; - } else { - tEntry.opvpSetBgColor = NULL; - } - tEntry.opvpNewPath = apiEntry_0_2->NewPath; - tEntry.opvpEndPath = apiEntry_0_2->EndPath; - tEntry.opvpStrokePath = apiEntry_0_2->StrokePath; - tEntry.opvpFillPath = apiEntry_0_2->FillPath; - tEntry.opvpStrokeFillPath = apiEntry_0_2->StrokeFillPath; - tEntry.opvpSetClipPath - = (opvp_result_t (*)(opvp_dc_t,opvp_cliprule_t)) - apiEntry_0_2->SetClipPath; - tEntry.opvpResetClipPath = apiEntry_0_2->ResetClipPath; - tEntry.opvpSetCurrentPoint = apiEntry_0_2->SetCurrentPoint; - tEntry.opvpLinePath - = (opvp_result_t (*)(opvp_dc_t, - opvp_pathmode_t,opvp_int_t, - const opvp_point_t*)) - apiEntry_0_2->LinePath; - tEntry.opvpPolygonPath - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const opvp_int_t*, - const opvp_point_t*)) - apiEntry_0_2->PolygonPath; - tEntry.opvpRectanglePath - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const opvp_rectangle_t*)) - apiEntry_0_2->RectanglePath; - tEntry.opvpRoundRectanglePath - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const opvp_roundrectangle_t*)) - apiEntry_0_2->RoundRectanglePath; - tEntry.opvpBezierPath - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const opvp_point_t*)) - apiEntry_0_2->BezierPath; - tEntry.opvpArcPath - = (opvp_result_t (*)(opvp_dc_t,opvp_arcmode_t, - opvp_arcdir_t,opvp_fix_t,opvp_fix_t,opvp_fix_t, - opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t, - opvp_fix_t))apiEntry_0_2->ArcPath; - if (apiEntry_0_2->DrawImage != NULL) { - tEntry.opvpDrawImage = DrawImageWrapper; - } else { - tEntry.opvpDrawImage = NULL; - } - if (apiEntry_0_2->StartDrawImage != NULL) { - tEntry.opvpStartDrawImage = StartDrawImageWrapper; - } else { - tEntry.opvpStartDrawImage = NULL; - } - tEntry.opvpTransferDrawImage = - (opvp_result_t (*)(opvp_dc_t,opvp_int_t,const void*)) - apiEntry_0_2->TransferDrawImage; - if (apiEntry_0_2->EndDrawImage != NULL) { - tEntry.opvpEndDrawImage = EndDrawImageWrapper; - } else { - tEntry.opvpEndDrawImage = NULL; - } - tEntry.opvpStartScanline = apiEntry_0_2->StartScanline; - tEntry.opvpScanline - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const opvp_int_t*)) - apiEntry_0_2->Scanline; - tEntry.opvpEndScanline = apiEntry_0_2->EndScanline; - tEntry.opvpStartRaster = apiEntry_0_2->StartRaster; - tEntry.opvpTransferRasterData - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const opvp_byte_t*)) - apiEntry_0_2->TransferRasterData; - tEntry.opvpSkipRaster = apiEntry_0_2->SkipRaster; - tEntry.opvpEndRaster = apiEntry_0_2->EndRaster; - tEntry.opvpStartStream = apiEntry_0_2->StartStream; - tEntry.opvpTransferStreamData - = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, - const void *)) - apiEntry_0_2->TransferStreamData; - tEntry.opvpEndStream = apiEntry_0_2->EndStream; - - *apiProcs = &tEntry; - - GetLastError = GetLastError_0_2; - } + /* try version 0.2 */ + + if (OpenPrinter_0_2 != NULL) { + static opvp_api_procs_t tEntry; + int nApiEntry; + + dc = (*OpenPrinter_0_2)(outputFD, + /* remove const */ + (char *)printerModel, + &nApiEntry,&apiEntry_0_2); + /* setting functions */ + tEntry.opvpClosePrinter + = apiEntry_0_2->ClosePrinter; + tEntry.opvpStartJob + = (opvp_result_t (*)(opvp_int_t, + const opvp_char_t*)) + apiEntry_0_2->StartJob; + tEntry.opvpEndJob = apiEntry_0_2->EndJob; + tEntry.opvpAbortJob = NULL; + tEntry.opvpStartDoc + = (opvp_result_t (*)(opvp_dc_t, + const opvp_char_t*)) + apiEntry_0_2->StartDoc; + tEntry.opvpEndDoc = apiEntry_0_2->EndDoc; + if (apiEntry_0_2->StartPage != NULL) { + tEntry.opvpStartPage = StartPageWrapper; + } else { + tEntry.opvpStartPage = NULL; + } + tEntry.opvpEndPage = apiEntry_0_2->EndPage; + + if (apiEntry_0_2->QueryDeviceCapability != NULL) { + tEntry.opvpQueryDeviceCapability + = QueryDeviceCapabilityWrapper; + } else { + tEntry.opvpQueryDeviceCapability = NULL; + } + + if (apiEntry_0_2->QueryDeviceInfo != NULL) { + tEntry.opvpQueryDeviceInfo = QueryDeviceInfoWrapper; + } else { + tEntry.opvpQueryDeviceInfo = NULL; + } + + tEntry.opvpResetCTM = apiEntry_0_2->ResetCTM; + tEntry.opvpSetCTM = (opvp_result_t (*)(opvp_dc_t, + const opvp_ctm_t*)) + apiEntry_0_2->SetCTM; + tEntry.opvpGetCTM = (opvp_result_t (*)(opvp_dc_t,opvp_ctm_t*)) + apiEntry_0_2->GetCTM; + if (apiEntry_0_2->InitGS != NULL) { + tEntry.opvpInitGS = InitGSWrapper; + } else { + tEntry.opvpInitGS = NULL; + } + tEntry.opvpSaveGS = apiEntry_0_2->SaveGS; + tEntry.opvpRestoreGS = apiEntry_0_2->RestoreGS; + if (apiEntry_0_2->QueryColorSpace != NULL) { + tEntry.opvpQueryColorSpace = QueryColorSpaceWrapper; + } else { + tEntry.opvpQueryColorSpace = NULL; + } + if (apiEntry_0_2->SetColorSpace != NULL) { + tEntry.opvpSetColorSpace = SetColorSpaceWrapper; + } else { + tEntry.opvpSetColorSpace = NULL; + } + if (apiEntry_0_2->GetColorSpace != NULL) { + tEntry.opvpGetColorSpace = GetColorSpaceWrapper; + } else { + tEntry.opvpGetColorSpace = NULL; + } + tEntry.opvpSetFillMode + = (opvp_result_t (*)(opvp_dc_t,opvp_fillmode_t)) + apiEntry_0_2->SetFillMode; + tEntry.opvpGetFillMode + = (opvp_result_t (*)(opvp_dc_t,opvp_fillmode_t*)) + apiEntry_0_2->GetFillMode; + tEntry.opvpSetAlphaConstant = apiEntry_0_2->SetAlphaConstant; + tEntry.opvpGetAlphaConstant = apiEntry_0_2->GetAlphaConstant; + tEntry.opvpSetLineWidth = apiEntry_0_2->SetLineWidth; + tEntry.opvpGetLineWidth = apiEntry_0_2->GetLineWidth; + if (apiEntry_0_2->SetLineDash != NULL) { + tEntry.opvpSetLineDash = SetLineDashWrapper; + } else { + tEntry.opvpSetLineDash = NULL; + } + if (apiEntry_0_2->GetLineDash != NULL) { + tEntry.opvpGetLineDash = GetLineDashWrapper; + } else { + tEntry.opvpGetLineDash = NULL; + } + tEntry.opvpSetLineDashOffset + = apiEntry_0_2->SetLineDashOffset; + tEntry.opvpGetLineDashOffset + = apiEntry_0_2->GetLineDashOffset; + tEntry.opvpSetLineStyle + = (opvp_result_t (*)(opvp_dc_t,opvp_linestyle_t)) + apiEntry_0_2->SetLineStyle; + tEntry.opvpGetLineStyle + = (opvp_result_t (*)(opvp_dc_t,opvp_linestyle_t*)) + apiEntry_0_2->GetLineStyle; + tEntry.opvpSetLineCap + = (opvp_result_t (*)(opvp_dc_t,opvp_linecap_t)) + apiEntry_0_2->SetLineCap; + tEntry.opvpGetLineCap + = (opvp_result_t (*)(opvp_dc_t,opvp_linecap_t*)) + apiEntry_0_2->GetLineCap; + tEntry.opvpSetLineJoin + = (opvp_result_t (*)(opvp_dc_t,opvp_linejoin_t)) + apiEntry_0_2->SetLineJoin; + tEntry.opvpGetLineJoin + = (opvp_result_t (*)(opvp_dc_t,opvp_linejoin_t*)) + apiEntry_0_2->GetLineJoin; + tEntry.opvpSetMiterLimit = apiEntry_0_2->SetMiterLimit; + tEntry.opvpGetMiterLimit = apiEntry_0_2->GetMiterLimit; + tEntry.opvpSetPaintMode + = (opvp_result_t (*)(opvp_dc_t,opvp_paintmode_t)) + apiEntry_0_2->SetPaintMode; + tEntry.opvpGetPaintMode + = (opvp_result_t (*)(opvp_dc_t,opvp_paintmode_t*)) + apiEntry_0_2->GetPaintMode; + if (apiEntry_0_2->SetStrokeColor != NULL) { + tEntry.opvpSetStrokeColor = SetStrokeColorWrapper; + } else { + tEntry.opvpSetStrokeColor = NULL; + } + if (apiEntry_0_2->SetFillColor != NULL) { + tEntry.opvpSetFillColor = SetFillColorWrapper; + } else { + tEntry.opvpSetFillColor = NULL; + } + if (apiEntry_0_2->SetBgColor != NULL) { + tEntry.opvpSetBgColor = SetBgColorWrapper; + } else { + tEntry.opvpSetBgColor = NULL; + } + tEntry.opvpNewPath = apiEntry_0_2->NewPath; + tEntry.opvpEndPath = apiEntry_0_2->EndPath; + tEntry.opvpStrokePath = apiEntry_0_2->StrokePath; + tEntry.opvpFillPath = apiEntry_0_2->FillPath; + tEntry.opvpStrokeFillPath = apiEntry_0_2->StrokeFillPath; + tEntry.opvpSetClipPath + = (opvp_result_t (*)(opvp_dc_t,opvp_cliprule_t)) + apiEntry_0_2->SetClipPath; + tEntry.opvpResetClipPath = apiEntry_0_2->ResetClipPath; + tEntry.opvpSetCurrentPoint = apiEntry_0_2->SetCurrentPoint; + tEntry.opvpLinePath + = (opvp_result_t (*)(opvp_dc_t, + opvp_pathmode_t,opvp_int_t, + const opvp_point_t*)) + apiEntry_0_2->LinePath; + tEntry.opvpPolygonPath + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const opvp_int_t*, + const opvp_point_t*)) + apiEntry_0_2->PolygonPath; + tEntry.opvpRectanglePath + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const opvp_rectangle_t*)) + apiEntry_0_2->RectanglePath; + tEntry.opvpRoundRectanglePath + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const opvp_roundrectangle_t*)) + apiEntry_0_2->RoundRectanglePath; + tEntry.opvpBezierPath + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const opvp_point_t*)) + apiEntry_0_2->BezierPath; + tEntry.opvpArcPath + = (opvp_result_t (*)(opvp_dc_t,opvp_arcmode_t, + opvp_arcdir_t,opvp_fix_t,opvp_fix_t,opvp_fix_t, + opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t, + opvp_fix_t))apiEntry_0_2->ArcPath; + if (apiEntry_0_2->DrawImage != NULL) { + tEntry.opvpDrawImage = DrawImageWrapper; + } else { + tEntry.opvpDrawImage = NULL; + } + if (apiEntry_0_2->StartDrawImage != NULL) { + tEntry.opvpStartDrawImage = StartDrawImageWrapper; + } else { + tEntry.opvpStartDrawImage = NULL; + } + tEntry.opvpTransferDrawImage = + (opvp_result_t (*)(opvp_dc_t,opvp_int_t,const void*)) + apiEntry_0_2->TransferDrawImage; + if (apiEntry_0_2->EndDrawImage != NULL) { + tEntry.opvpEndDrawImage = EndDrawImageWrapper; + } else { + tEntry.opvpEndDrawImage = NULL; + } + tEntry.opvpStartScanline = apiEntry_0_2->StartScanline; + tEntry.opvpScanline + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const opvp_int_t*)) + apiEntry_0_2->Scanline; + tEntry.opvpEndScanline = apiEntry_0_2->EndScanline; + tEntry.opvpStartRaster = apiEntry_0_2->StartRaster; + tEntry.opvpTransferRasterData + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const opvp_byte_t*)) + apiEntry_0_2->TransferRasterData; + tEntry.opvpSkipRaster = apiEntry_0_2->SkipRaster; + tEntry.opvpEndRaster = apiEntry_0_2->EndRaster; + tEntry.opvpStartStream = apiEntry_0_2->StartStream; + tEntry.opvpTransferStreamData + = (opvp_result_t (*)(opvp_dc_t,opvp_int_t, + const void *)) + apiEntry_0_2->TransferStreamData; + tEntry.opvpEndStream = apiEntry_0_2->EndStream; + + *apiProcs = &tEntry; + + GetLastError = GetLastError_0_2; + } } return dc; } /* for image */ -static const +static const gx_image_enum_procs_t opvp_image_enum_procs = { opvp_image_plane_data, opvp_image_end_image }; -typedef enum _FastImageSupportMode { +typedef enum _FastImageSupportMode { FastImageDisable, FastImageNoCTM, FastImageNoRotate, @@ -1183,17 +1183,17 @@ static bool reverse_image = false; /* added for image gamma correction */ typedef struct bbox_image_enum_s { gx_image_enum_common; -/* gs_memory_t *memory; */ +/* gs_memory_t *memory; */ gs_matrix matrix; /* map from image space to device dpace */ const gx_clip_path *pcpath; gx_image_enum_common_t *target_info; bool params_are_const; - int x0, x1; - int y, height; + int x0, x1; + int y, height; } bbox_image_enum; /* The following is already defined in stdpre.h */ -/*#define min(a, b) (((a) < (b))? (a) : (b))*/ +/*#define min(a, b) (((a) < (b))? (a) : (b))*/ /* ----- Utilities ----- */ @@ -1204,39 +1204,39 @@ static int InitGS(void) { if (apiEntry->opvpInitGS != NULL) { - if (apiEntry->opvpInitGS(printerContext) != OPVP_OK) { - return -1; - } + if (apiEntry->opvpInitGS(printerContext) != OPVP_OK) { + return -1; + } } if (apiEntry->opvpSetColorSpace != NULL) { - if (apiEntry->opvpSetColorSpace(printerContext,colorSpace) - != OPVP_OK) { - return -1; - } + if (apiEntry->opvpSetColorSpace(printerContext,colorSpace) + != OPVP_OK) { + return -1; + } } if (apiEntry->opvpSetPaintMode != NULL) { - if (apiEntry->opvpSetPaintMode(printerContext, - OPVP_PAINTMODE_TRANSPARENT) != OPVP_OK) { - return -1; - } + if (apiEntry->opvpSetPaintMode(printerContext, + OPVP_PAINTMODE_TRANSPARENT) != OPVP_OK) { + return -1; + } } if (apiEntry->opvpSetAlphaConstant != NULL) { - if (apiEntry->opvpSetAlphaConstant(printerContext,1.0) - != OPVP_OK) { - return -1; - } + if (apiEntry->opvpSetAlphaConstant(printerContext,1.0) + != OPVP_OK) { + return -1; + } } /* other properties are set by GhostScript */ return 0; } -static int +static int opvp_startpage(gx_device *dev) { - int ecode = 0; + int ecode = 0; opvp_result_t r = -1; - static char *page_info = NULL; + static char *page_info = NULL; /* page info */ page_info = opvp_alloc_string(&page_info, OPVP_INFO_PREFIX); @@ -1244,78 +1244,78 @@ opvp_startpage(gx_device *dev) /* call StartPage */ if (printerContext != -1) { - if (apiEntry->opvpStartPage) - r = apiEntry->opvpStartPage(printerContext, - (opvp_char_t *)opvp_to_utf8(page_info)); - if (r != OPVP_OK) { - ecode = -1; - } else { - ecode = InitGS(); - } + if (apiEntry->opvpStartPage) + r = apiEntry->opvpStartPage(printerContext, + (opvp_char_t *)opvp_to_utf8(page_info)); + if (r != OPVP_OK) { + ecode = -1; + } else { + ecode = InitGS(); + } } return ecode; } -static int +static int opvp_endpage(void) { - int ecode = 0; + int ecode = 0; opvp_result_t r = -1; /* call EndPage */ if (printerContext != -1) { - if (apiEntry->opvpEndPage) - r = apiEntry->opvpEndPage(printerContext); - if (r != OPVP_OK) { - ecode = -1; - } + if (apiEntry->opvpEndPage) + r = apiEntry->opvpEndPage(printerContext); + if (r != OPVP_OK) { + ecode = -1; + } } return ecode; } -static char * +static char * opvp_alloc_string(char **destin, const char *source) { if (!destin) return NULL; if (*destin) { - if (source) { - *destin = realloc(*destin, strlen(source)+1); - } else { - free(*destin); - *destin = NULL; - } + if (source) { + *destin = realloc(*destin, strlen(source)+1); + } else { + free(*destin); + *destin = NULL; + } } else { - if (source) { - *destin = malloc(strlen(source)+1); - } + if (source) { + *destin = malloc(strlen(source)+1); + } } if (*destin && source) { - if (*destin != source) { - strcpy(*destin, source); - } + if (*destin != source) { + strcpy(*destin, source); + } } return *destin; } -static char * +static char * opvp_cat_string(char **destin, const char *string) { if (!destin) return NULL; if (!(*destin)) return opvp_alloc_string(destin, string); if (string) { - *destin = realloc(*destin, strlen(*destin) +strlen(string)+1); - strcat(*destin, string); + *destin = realloc(*destin, strlen(*destin) +strlen(string)+1); + strcat(*destin, string); } return *destin; } -static char * +static char * opvp_adjust_num_string(char *num_string) { char *pp; @@ -1324,27 +1324,27 @@ opvp_adjust_num_string(char *num_string) if (!num_string) return NULL; if ((pp = strrchr(num_string, '.'))) { - for (lp = &(num_string[strlen(num_string)-1]); lp > pp; lp--) { - if (*lp == '0') { - *lp = '\0'; - } else { - break; - } - } - if (lp == pp) *lp = '\0'; + for (lp = &(num_string[strlen(num_string)-1]); lp > pp; lp--) { + if (*lp == '0') { + *lp = '\0'; + } else { + break; + } + } + if (lp == pp) *lp = '\0'; } return num_string; } -static char ** +static char ** opvp_gen_dynamic_lib_name(void) { - static char *buff[5] = {NULL,NULL,NULL,NULL,NULL}; + static char *buff[5] = {NULL,NULL,NULL,NULL,NULL}; char tbuff[OPVP_BUFF_SIZE]; if (!vectorDriver) { - return NULL; + return NULL; } memset((void*)tbuff, 0, OPVP_BUFF_SIZE); @@ -1372,48 +1372,48 @@ opvp_gen_dynamic_lib_name(void) return buff; } -static char * +static char * opvp_to_utf8(char *string) { char *locale; iconv_t cd; char *buff = NULL; size_t ib, ob; - int complete = false; + int complete = false; char *ibuff, *obuff; char *ostring = NULL; if (string) { - ib = strlen(string); - if (ib > 0) { - ob = ib * 4; - buff = malloc(ob+1); - setlocale(LC_CTYPE, ""); + ib = strlen(string); + if (ib > 0) { + ob = ib * 4; + buff = malloc(ob+1); + setlocale(LC_CTYPE, ""); #ifdef CODESET - locale = nl_langinfo(CODESET); + locale = nl_langinfo(CODESET); #else - locale = "UTF-8"; + locale = "UTF-8"; #endif /* CODESET */ - if (locale) { - if (strcmp(locale, "C") && buff) { - if ((cd = iconv_open("UTF-8", locale)) != (iconv_t)-1) { - ibuff = string; - obuff = buff; - if (iconv(cd, &ibuff, &ib, &obuff, &ob) != -1) { - *obuff = 0; - complete = true; - } - iconv_close(cd); - } - } - } - } + if (locale) { + if (strcmp(locale, "C") && buff) { + if ((cd = iconv_open("UTF-8", locale)) != (iconv_t)-1) { + ibuff = string; + obuff = buff; + if (iconv(cd, &ibuff, &ib, &obuff, &ob) != -1) { + *obuff = 0; + complete = true; + } + iconv_close(cd); + } + } + } + } } if (complete) { - ostring = opvp_alloc_string(&ostring, buff); + ostring = opvp_alloc_string(&ostring, buff); } else { - ostring = string; + ostring = string; } if (buff) free(buff); @@ -1426,20 +1426,20 @@ opvp_fabsf(float f) return (float)fabs((double)f); } -static int +static int opvp_get_papertable_index(gx_device *pdev) { - int i; + int i; float width, height; bool landscape; float paper_w, paper_h; float prev = -1; - int paper = -1; - int candidate = -1; - int smaller = -1; - int larger = -1; - int s_candi = -1; - int l_candi = -1; + int paper = -1; + int candidate = -1; + int smaller = -1; + int larger = -1; + int s_candi = -1; + int l_candi = -1; float h_delta = TOLERANCE; float sw_delta = TOLERANCE; float sh_delta = TOLERANCE; @@ -1456,98 +1456,98 @@ opvp_get_papertable_index(gx_device *pdev) height = (landscape ? pdev->MediaSize[0] : pdev->MediaSize[1]); for (i=0; paperTable[i].name != NULL; i++) { - paper_w = paperTable[i].width; - paper_h = paperTable[i].height; - if (width == paper_w) { - if (height == paper_h) { - paper = i; - match = true; - break; - } else if ((f = opvp_fabsf(height - paper_h)) < TOLERANCE) { - if (f < h_delta) { - h_delta = f; - candidate = i; - } - } - } else if (candidate != -1) { - paper = candidate; - match = true; - break; - } else if (prev != paper_w) { - prev = paper_w; - if (paper_w < width) { - if ((f = opvp_fabsf(width - paper_w)) < TOLERANCE) { - if (f < sw_delta) { - sw_delta = f; - smaller = i; - } - } - } else { - if ((f = opvp_fabsf(width - paper_w)) < TOLERANCE) { - if (f < lw_delta) { - lw_delta = f; - larger = i; - } - } - } - } + paper_w = paperTable[i].width; + paper_h = paperTable[i].height; + if (width == paper_w) { + if (height == paper_h) { + paper = i; + match = true; + break; + } else if ((f = opvp_fabsf(height - paper_h)) < TOLERANCE) { + if (f < h_delta) { + h_delta = f; + candidate = i; + } + } + } else if (candidate != -1) { + paper = candidate; + match = true; + break; + } else if (prev != paper_w) { + prev = paper_w; + if (paper_w < width) { + if ((f = opvp_fabsf(width - paper_w)) < TOLERANCE) { + if (f < sw_delta) { + sw_delta = f; + smaller = i; + } + } + } else { + if ((f = opvp_fabsf(width - paper_w)) < TOLERANCE) { + if (f < lw_delta) { + lw_delta = f; + larger = i; + } + } + } + } } if (!match) { - paper = i; - if (smaller != -1) { - paper_w = paperTable[smaller].width; - for (i = smaller; paperTable[i].width == paper_w; i++) { - paper_h = paperTable[i].height; - if (height == paper_h) { - sh_delta = 0; - s_candi = i; - break; - } else if ((f = opvp_fabsf(height - paper_h)) < TOLERANCE) { - if (f < sh_delta) { - sh_delta = f; - s_candi = i; - } - } - } - } - if (larger != -1) { - paper_w = paperTable[larger].width; - for (i = larger; paperTable[i].width == paper_w; i++) { - paper_h = paperTable[i].height; - if (height == paper_h) { - lh_delta = 0; - l_candi = i; - break; - } else if ((f = opvp_fabsf(height - paper_h)) < TOLERANCE) { - if (f < lh_delta) { - lh_delta = f; - l_candi = i; - } - } - } - } - if (s_candi != -1) { - if (l_candi != -1) { - if ((sw_delta + sh_delta) - < (lw_delta + lh_delta)) { - paper = s_candi; - } else { - paper = l_candi; - } - } else { - paper = s_candi; - } - } else { - if (l_candi != -1) { - paper = l_candi; - } - } + paper = i; + if (smaller != -1) { + paper_w = paperTable[smaller].width; + for (i = smaller; paperTable[i].width == paper_w; i++) { + paper_h = paperTable[i].height; + if (height == paper_h) { + sh_delta = 0; + s_candi = i; + break; + } else if ((f = opvp_fabsf(height - paper_h)) < TOLERANCE) { + if (f < sh_delta) { + sh_delta = f; + s_candi = i; + } + } + } + } + if (larger != -1) { + paper_w = paperTable[larger].width; + for (i = larger; paperTable[i].width == paper_w; i++) { + paper_h = paperTable[i].height; + if (height == paper_h) { + lh_delta = 0; + l_candi = i; + break; + } else if ((f = opvp_fabsf(height - paper_h)) < TOLERANCE) { + if (f < lh_delta) { + lh_delta = f; + l_candi = i; + } + } + } + } + if (s_candi != -1) { + if (l_candi != -1) { + if ((sw_delta + sh_delta) + < (lw_delta + lh_delta)) { + paper = s_candi; + } else { + paper = l_candi; + } + } else { + paper = s_candi; + } + } else { + if (l_candi != -1) { + paper = l_candi; + } + } } return paper; } -static char * +static char * opvp_get_sizestring(float width, float height) { char nbuff[OPVP_BUFF_SIZE]; @@ -1562,18 +1562,18 @@ opvp_get_sizestring(float width, float height) snprintf(nbuff1, OPVP_BUFF_SIZE / 2 - 1, "%.3f", width); snprintf(nbuff2, OPVP_BUFF_SIZE / 2 - 1, "%.3f", height); snprintf(nbuff, OPVP_BUFF_SIZE - 1, "%sx%s", - opvp_adjust_num_string(nbuff1), - opvp_adjust_num_string(nbuff2)); + opvp_adjust_num_string(nbuff1), + opvp_adjust_num_string(nbuff2)); return opvp_alloc_string(&buff, nbuff); } -static char * +static char * opvp_get_mediasize(gx_device *pdev) { - int i; + int i; char wbuff[OPVP_BUFF_SIZE]; - static char *buff = NULL; + static char *buff = NULL; const char *region; const char *name; float width; @@ -1584,59 +1584,59 @@ opvp_get_mediasize(gx_device *pdev) i = opvp_get_papertable_index(pdev); if (paperTable[i].name) { - region = paperTable[i].region; - name = paperTable[i].name; - width = paperTable[i].width / PS_DPI; - height = paperTable[i].height / PS_DPI; - if((strcmp(region, "na" ) == 0) || - (strcmp(region, "asme") == 0) || - (strcmp(region, "roc" ) == 0) || - (strcmp(region, "oe" ) == 0)) { - unit = "in"; - } else { - width *= MMPI; - height *= MMPI; - unit = "mm"; - } + region = paperTable[i].region; + name = paperTable[i].name; + width = paperTable[i].width / PS_DPI; + height = paperTable[i].height / PS_DPI; + if((strcmp(region, "na" ) == 0) || + (strcmp(region, "asme") == 0) || + (strcmp(region, "roc" ) == 0) || + (strcmp(region, "oe" ) == 0)) { + unit = "in"; + } else { + width *= MMPI; + height *= MMPI; + unit = "mm"; + } } else { - landscape = (pdev->MediaSize[0] < pdev->MediaSize[1] ? - false : true); - region = "custom"; - name = "opvp"; - width = (landscape ? pdev->MediaSize[1] : pdev->MediaSize[0]) - / PS_DPI; - height = (landscape ? pdev->MediaSize[0] : pdev->MediaSize[1]) - / PS_DPI; - unit = "in"; + landscape = (pdev->MediaSize[0] < pdev->MediaSize[1] ? + false : true); + region = "custom"; + name = "opvp"; + width = (landscape ? pdev->MediaSize[1] : pdev->MediaSize[0]) + / PS_DPI; + height = (landscape ? pdev->MediaSize[0] : pdev->MediaSize[1]) + / PS_DPI; + unit = "in"; } memset((void*)wbuff, 0, OPVP_BUFF_SIZE); snprintf(wbuff, OPVP_BUFF_SIZE - 1, "%s_%s_%s%s", region, name, - opvp_get_sizestring(width, height), - unit); + opvp_get_sizestring(width, height), + unit); buff = opvp_alloc_string(&buff, wbuff); return buff; } -static char * +static char * opvp_gen_page_info(gx_device *dev) { - static char *buff = NULL; + static char *buff = NULL; int num_copies = 1; bool landscape; char tbuff[OPVP_BUFF_SIZE]; /* copies */ if (!inkjet) { - if (dev->IgnoreNumCopies) { - num_copies = 1; - } else if (dev->NumCopies_set > 0) { - num_copies = dev->NumCopies; - } + if (dev->IgnoreNumCopies) { + num_copies = 1; + } else if (dev->NumCopies_set > 0) { + num_copies = dev->NumCopies; + } } landscape = (dev->MediaSize[0] < dev->MediaSize[1] ? false - : true); + : true); memset((void*)tbuff, 0, OPVP_BUFF_SIZE); snprintf(tbuff, OPVP_BUFF_SIZE - 1, "MediaCopy=%d;DeviceResolution=deviceResolution_%s;" @@ -1651,19 +1651,19 @@ opvp_gen_page_info(gx_device *dev) return buff; } -static char * +static char * opvp_gen_doc_info(gx_device *dev) { return opvp_gen_page_info(dev); } -static char * +static char * opvp_gen_job_info(gx_device *dev) { return opvp_gen_doc_info(dev); } -static int +static int opvp_set_brush_color(gx_device_opvp *pdev, gx_color_index color, opvp_brush_t *brush) { @@ -1673,47 +1673,47 @@ opvp_set_brush_color(gx_device_opvp *pdev, gx_color_index color, code = opvp_map_color_rgb((gx_device *)pdev, color, rgb); if (code) { - ecode = -1; + ecode = -1; } else { #if ENABLE_SIMPLE_MODE - brush->colorSpace = colorSpace; + brush->colorSpace = colorSpace; #else - opvp_result_t r = -1; - /* call GetColorSpace */ - if (apiEntry->opvpGetColorSpace) { - r = apiEntry->opvpGetColorSpace(printerContext, - &(brush->colorSpace)); - } - if (r != OPVP_OK) { - brush->colorSpace = OPVP_CSPACE_DEVICEKRGB; - } + opvp_result_t r = -1; + /* call GetColorSpace */ + if (apiEntry->opvpGetColorSpace) { + r = apiEntry->opvpGetColorSpace(printerContext, + &(brush->colorSpace)); + } + if (r != OPVP_OK) { + brush->colorSpace = OPVP_CSPACE_DEVICEKRGB; + } #endif - brush->pbrush = NULL; - brush->xorg = brush->yorg = 0; - brush->color[3] = (color == gx_no_color_index ? -1 : 0); - brush->color[2] = rgb[0]; - brush->color[1] = rgb[1]; - brush->color[0] = rgb[2]; + brush->pbrush = NULL; + brush->xorg = brush->yorg = 0; + brush->color[3] = (color == gx_no_color_index ? -1 : 0); + brush->color[2] = rgb[0]; + brush->color[1] = rgb[1]; + brush->color[0] = rgb[2]; } return ecode; } -static int +static int opvp_draw_image( gx_device_opvp *pdev, - int depth, - int sw, - int sh, - int dw, - int dh, - int raster, - int mask, + int depth, + int sw, + int sh, + int dw, + int dh, + int raster, + int mask, const byte *data) { - opvp_result_t r = -1; - int ecode = 0; - int count; + opvp_result_t r = -1; + int ecode = 0; + int count; /* check page-in */ if (opvp_check_in_page(pdev)) return -1; @@ -1723,41 +1723,41 @@ opvp_draw_image( /* call DrawImage */ if (apiEntry->opvpDrawImage) { - r = apiEntry->opvpDrawImage(printerContext, - sw,sh, - raster, - mask ? OPVP_IFORMAT_MASK : OPVP_IFORMAT_RAW, - dw,dh, - /* discard 'const' qualifier */ - (void *)data); + r = apiEntry->opvpDrawImage(printerContext, + sw,sh, + raster, + mask ? OPVP_IFORMAT_MASK : OPVP_IFORMAT_RAW, + dw,dh, + /* discard 'const' qualifier */ + (void *)data); } if (r != OPVP_OK) { - /* call StartDrawImage */ - if (apiEntry->opvpStartDrawImage) { - r = apiEntry->opvpStartDrawImage(printerContext, - sw,sh, - raster, - mask ? OPVP_IFORMAT_MASK : OPVP_IFORMAT_RAW, - dw,dh); - } - if (r == OPVP_OK) { - /* call TansferDrawImage */ - if (apiEntry->opvpTransferDrawImage) { - r = apiEntry->opvpTransferDrawImage( - printerContext, - count, - /* discard 'const' qualifier */ - (void *)data); - } - if (r != OPVP_OK) ecode = -1; - - /* call EndDrawImage */ - if (apiEntry->opvpEndDrawImage) { - apiEntry->opvpEndDrawImage(printerContext); - } - } else { - ecode = 0; /* continue... */ - } + /* call StartDrawImage */ + if (apiEntry->opvpStartDrawImage) { + r = apiEntry->opvpStartDrawImage(printerContext, + sw,sh, + raster, + mask ? OPVP_IFORMAT_MASK : OPVP_IFORMAT_RAW, + dw,dh); + } + if (r == OPVP_OK) { + /* call TansferDrawImage */ + if (apiEntry->opvpTransferDrawImage) { + r = apiEntry->opvpTransferDrawImage( + printerContext, + count, + /* discard 'const' qualifier */ + (void *)data); + } + if (r != OPVP_OK) ecode = -1; + + /* call EndDrawImage */ + if (apiEntry->opvpEndDrawImage) { + apiEntry->opvpEndDrawImage(printerContext); + } + } else { + ecode = 0; /* continue... */ + } } return ecode; @@ -1768,65 +1768,65 @@ opvp_draw_image( /* * load vector-driver */ -static int +static int opvp_load_vector_driver(void) { char **list = NULL; - int i; + int i; void *h; if (handle) { - opvp_unload_vector_driver(); + opvp_unload_vector_driver(); } if (vectorDriver) { - list = opvp_gen_dynamic_lib_name(); + list = opvp_gen_dynamic_lib_name(); } if (list) { - i = 0; - while (list[i]) { - if ((h = dlopen(list[i],RTLD_NOW))) { - OpenPrinter = dlsym(h,"opvpOpenPrinter"); - ErrorNo = dlsym(h,"opvpErrorNo"); - if (OpenPrinter && ErrorNo) { - handle = h; - break; - } - OpenPrinter = NULL; - ErrorNo = NULL; - /* try version 0.2 driver */ - OpenPrinter_0_2 = dlsym(h,"OpenPrinter"); - ErrorNo = dlsym(h,"errorno"); - if (OpenPrinter_0_2 && ErrorNo) { - handle = h; - break; - } - OpenPrinter_0_2 = NULL; - ErrorNo = NULL; - } - i++; - } + i = 0; + while (list[i]) { + if ((h = dlopen(list[i],RTLD_NOW))) { + OpenPrinter = dlsym(h,"opvpOpenPrinter"); + ErrorNo = dlsym(h,"opvpErrorNo"); + if (OpenPrinter && ErrorNo) { + handle = h; + break; + } + OpenPrinter = NULL; + ErrorNo = NULL; + /* try version 0.2 driver */ + OpenPrinter_0_2 = dlsym(h,"OpenPrinter"); + ErrorNo = dlsym(h,"errorno"); + if (OpenPrinter_0_2 && ErrorNo) { + handle = h; + break; + } + OpenPrinter_0_2 = NULL; + ErrorNo = NULL; + } + i++; + } } if (handle) { - return 0; + return 0; } else { - return -1; + return -1; } } /* * unload vector-driver */ -static int +static int opvp_unload_vector_driver(void) { if (handle) { - dlclose(handle); - handle = NULL; - OpenPrinter = NULL; - ErrorNo = NULL; + dlclose(handle); + handle = NULL; + OpenPrinter = NULL; + ErrorNo = NULL; } return 0; } @@ -1834,7 +1834,7 @@ opvp_unload_vector_driver(void) /* * prepare open */ -static int +static int prepare_open(gx_device *dev) { int ecode = 0; @@ -1852,113 +1852,113 @@ prepare_open(gx_device *dev) /* load vector driver */ if (!ecode) { - if ((code = opvp_load_vector_driver())) { - ecode = code; - } + if ((code = opvp_load_vector_driver())) { + ecode = code; + } } /* prepare array of function pointer for PDAPI */ if (!ecode) { - if (!apiEntry) { - if (!(apiEntry = calloc(sizeof(opvp_api_procs_t), 1))) { - ecode = -1; - } - } else { - memset(apiEntry, 0, sizeof(opvp_api_procs_t)); - } + if (!apiEntry) { + if (!(apiEntry = calloc(sizeof(opvp_api_procs_t), 1))) { + ecode = -1; + } + } else { + memset(apiEntry, 0, sizeof(opvp_api_procs_t)); + } } /* call opvpOpenPrinter as dummy */ if (!ecode) { - opvp_dc_t dc; - opvp_int_t apiVersion[2]; + opvp_dc_t dc; + opvp_int_t apiVersion[2]; - /* require version 1.0 */ - apiVersion[0] = 1; - apiVersion[1] = 0; - dc = OpenPrinterWrapper(dumFD, (opvp_char_t *)printerModel, - apiVersion,&api_entry); - if (dc == -1) { - ecode = -1; - } else { - dumContext = dc; - } + /* require version 1.0 */ + apiVersion[0] = 1; + apiVersion[1] = 0; + dc = OpenPrinterWrapper(dumFD, (opvp_char_t *)printerModel, + apiVersion,&api_entry); + if (dc == -1) { + ecode = -1; + } else { + dumContext = dc; + } } /* set apiEntry */ if (!ecode) { - nApiEntry = sizeof(opvp_api_procs_t)/sizeof(void *); - memcpy(apiEntry, api_entry, nApiEntry*sizeof(void *)); + nApiEntry = sizeof(opvp_api_procs_t)/sizeof(void *); + memcpy(apiEntry, api_entry, nApiEntry*sizeof(void *)); } else { - if (apiEntry) free(apiEntry); - apiEntry = NULL; + if (apiEntry) free(apiEntry); + apiEntry = NULL; } /* check vector fucntion */ if (apiEntry) { - if (!inkjet) { - if (!(apiEntry->opvpNewPath) || - !(apiEntry->opvpEndPath) || - !(apiEntry->opvpStrokePath) || - !(apiEntry->opvpSetCurrentPoint) || - !(apiEntry->opvpLinePath) || - !(apiEntry->opvpBezierPath)) { - /* NOT avail vector drawing mode */ - vector = false; - } - } - /* call GetColorSpace */ - if (apiEntry->opvpGetColorSpace) { - r = apiEntry->opvpGetColorSpace(dumContext, &cspace); - } - if (cspace == OPVP_CSPACE_BW) { - /* mono-color */ - colorSpace = cspace; - dev->color_info.num_components = 1; - dev->color_info.depth = 1; - dev->color_info.max_gray = 0; - dev->color_info.max_color = 0; - dev->color_info.dither_grays = 1; - dev->color_info.dither_colors = 1; - } else if (cspace == OPVP_CSPACE_DEVICEGRAY) { - /* gray-scale */ - colorSpace = cspace; - dev->color_info.num_components = 1; - dev->color_info.depth = 8; - dev->color_info.max_gray = 255; - dev->color_info.max_color = 255; - dev->color_info.dither_grays = 256; - dev->color_info.dither_colors = 256; - } else { - /* rgb color */ - colorSpace = OPVP_CSPACE_STANDARDRGB; - dev->color_info.num_components = 3; - dev->color_info.depth = 24; - dev->color_info.max_gray = 255; - dev->color_info.max_color = 255; - dev->color_info.dither_grays = 256; - dev->color_info.dither_colors = 256; - } + if (!inkjet) { + if (!(apiEntry->opvpNewPath) || + !(apiEntry->opvpEndPath) || + !(apiEntry->opvpStrokePath) || + !(apiEntry->opvpSetCurrentPoint) || + !(apiEntry->opvpLinePath) || + !(apiEntry->opvpBezierPath)) { + /* NOT avail vector drawing mode */ + vector = false; + } + } + /* call GetColorSpace */ + if (apiEntry->opvpGetColorSpace) { + r = apiEntry->opvpGetColorSpace(dumContext, &cspace); + } + if (cspace == OPVP_CSPACE_BW) { + /* mono-color */ + colorSpace = cspace; + dev->color_info.num_components = 1; + dev->color_info.depth = 1; + dev->color_info.max_gray = 0; + dev->color_info.max_color = 0; + dev->color_info.dither_grays = 1; + dev->color_info.dither_colors = 1; + } else if (cspace == OPVP_CSPACE_DEVICEGRAY) { + /* gray-scale */ + colorSpace = cspace; + dev->color_info.num_components = 1; + dev->color_info.depth = 8; + dev->color_info.max_gray = 255; + dev->color_info.max_color = 255; + dev->color_info.dither_grays = 256; + dev->color_info.dither_colors = 256; + } else { + /* rgb color */ + colorSpace = OPVP_CSPACE_STANDARDRGB; + dev->color_info.num_components = 3; + dev->color_info.depth = 24; + dev->color_info.max_gray = 255; + dev->color_info.max_color = 255; + dev->color_info.dither_grays = 256; + dev->color_info.dither_colors = 256; + } #if GS_VERSION_MAJOR >= 8 - dev->procs.get_color_mapping_procs = NULL; - dev->procs.get_color_comp_index = NULL; - gx_device_fill_in_procs(dev); + dev->procs.get_color_mapping_procs = NULL; + dev->procs.get_color_comp_index = NULL; + gx_device_fill_in_procs(dev); #endif } /* call Closerinter as dummy */ if (dumContext != -1) { - /* call ClosePrinter */ - if (apiEntry->opvpClosePrinter) { - apiEntry->opvpClosePrinter(dumContext); - } - dumContext = -1; + /* call ClosePrinter */ + if (apiEntry->opvpClosePrinter) { + apiEntry->opvpClosePrinter(dumContext); + } + dumContext = -1; } /* close device for dummy */ if (dumFD != -1) { - close(dumFD); - dumFD = -1; + close(dumFD); + dumFD = -1; } /* un-load vector driver */ @@ -1971,7 +1971,7 @@ prepare_open(gx_device *dev) /* * open device */ -static int +static int opvp_open(gx_device *dev) { gx_device_opvp *pdev = (gx_device_opvp *)dev; @@ -1992,95 +1992,95 @@ opvp_open(gx_device *dev) /* prepare open : load and open as dummy */ code = prepare_open(dev); if (code) { - ecode = code; - return ecode; + ecode = code; + return ecode; } /* set margins */ if (zoomAuto) { - margin_width = (margins[0] + margins[2]) - * dev->HWResolution[0]; - margin_height = (margins[1] + margins[3]) - * dev->HWResolution[1]; - zoom[0] = (dev->width - margin_width) / dev->width; - zoom[1] = (dev->height - margin_height) / dev->height; - if (zoom[0] < zoom[1]) { - zoom[1] = zoom[0]; - } else { - zoom[0] = zoom[1]; - } + margin_width = (margins[0] + margins[2]) + * dev->HWResolution[0]; + margin_height = (margins[1] + margins[3]) + * dev->HWResolution[1]; + zoom[0] = (dev->width - margin_width) / dev->width; + zoom[1] = (dev->height - margin_height) / dev->height; + if (zoom[0] < zoom[1]) { + zoom[1] = zoom[0]; + } else { + zoom[0] = zoom[1]; + } } if (inkjet) { - if ((margins[0] != 0) || - (margins[1] != 0) || (margins[3] != 0)) { - shift[0] = margins[0] * dev->HWResolution[0]; - shift[1] = (margins[1] + margins[3]) - * dev->HWResolution[1]; - zooming = true; - } - dev->width -= margins[2] * dev->HWResolution[0]; - dev->height -= margins[1] * dev->HWResolution[1]; + if ((margins[0] != 0) || + (margins[1] != 0) || (margins[3] != 0)) { + shift[0] = margins[0] * dev->HWResolution[0]; + shift[1] = (margins[1] + margins[3]) + * dev->HWResolution[1]; + zooming = true; + } + dev->width -= margins[2] * dev->HWResolution[0]; + dev->height -= margins[1] * dev->HWResolution[1]; } else { - if ((margins[0] != 0) || (margins[1] != 0)) { - shift[0] = margins[0] * dev->HWResolution[0]; - shift[1] = margins[3] * dev->HWResolution[1]; - zooming = true; - } - adj_margins[0] = 0; - adj_margins[3] = 0; - adj_margins[1] = dev->height * zoom[1] / dev->HWResolution[1] - - (dev->MediaSize[1] / PS_DPI - - (margins[1] + margins[3])); - if (adj_margins[1] < 0) adj_margins[0] = 0; - adj_margins[2] = dev->width * zoom[0] / dev->HWResolution[0] - - (dev->MediaSize[0] / PS_DPI - - (margins[0] + margins[2])); - if (adj_margins[2] < 0) adj_margins[2] = 0; - gx_device_set_margins(dev, adj_margins, true); + if ((margins[0] != 0) || (margins[1] != 0)) { + shift[0] = margins[0] * dev->HWResolution[0]; + shift[1] = margins[3] * dev->HWResolution[1]; + zooming = true; + } + adj_margins[0] = 0; + adj_margins[3] = 0; + adj_margins[1] = dev->height * zoom[1] / dev->HWResolution[1] + - (dev->MediaSize[1] / PS_DPI + - (margins[1] + margins[3])); + if (adj_margins[1] < 0) adj_margins[0] = 0; + adj_margins[2] = dev->width * zoom[0] / dev->HWResolution[0] + - (dev->MediaSize[0] / PS_DPI + - (margins[0] + margins[2])); + if (adj_margins[2] < 0) adj_margins[2] = 0; + gx_device_set_margins(dev, adj_margins, true); } if ((zoom[0] != 1) || (zoom[1] != 1)) zooming = true; /* open file for output device */ if (!inkjet) { - pdev->v_memory = gs_memory_stable(pdev->memory); - /* open output stream */ - code = gdev_vector_open_file_options((gx_device_vector*)dev, - 512, - (VECTOR_OPEN_FILE_SEQUENTIAL - |VECTOR_OPEN_FILE_BBOX - )); - if (code < 0) { - ecode = code; - return ecode; - } + pdev->v_memory = gs_memory_stable(pdev->memory); + /* open output stream */ + code = gdev_vector_open_file_options((gx_device_vector*)dev, + 512, + (VECTOR_OPEN_FILE_SEQUENTIAL + |VECTOR_OPEN_FILE_BBOX + )); + if (code < 0) { + ecode = code; + return ecode; + } #if GS_VERSION_MAJOR >= 8 - if (pdev->bbox_device != NULL) { - if (pdev->bbox_device->memory == NULL) { - pdev->bbox_device->memory = gs_memory_stable(dev->memory); - } - } + if (pdev->bbox_device != NULL) { + if (pdev->bbox_device->memory == NULL) { + pdev->bbox_device->memory = gs_memory_stable(dev->memory); + } + } #endif - outputFD = fileno(pdev->file); + outputFD = fileno(pdev->file); } else { - /* open printer device */ - code = gdev_prn_open(dev); - if (code < 0) { - ecode = ecode; - return ecode; - } - /* open output stream */ - code = gdev_prn_open_printer_seekable(dev, true, false); - if (code < 0) { - ecode = code; - return ecode; - } - outputFD = fileno(rdev->file); + /* open printer device */ + code = gdev_prn_open(dev); + if (code < 0) { + ecode = ecode; + return ecode; + } + /* open output stream */ + code = gdev_prn_open_printer_seekable(dev, true, false); + if (code < 0) { + ecode = code; + return ecode; + } + outputFD = fileno(rdev->file); } /* RE-load vector driver */ if ((code = opvp_load_vector_driver())) { - ecode = code; - return ecode; + ecode = code; + return ecode; } /* call opvpOpenPrinter */ @@ -2090,20 +2090,20 @@ opvp_open(gx_device *dev) dc = OpenPrinterWrapper(outputFD,(opvp_char_t *)printerModel, apiVersion,&api_entry); if (!apiEntry) { - if (!(apiEntry = calloc(sizeof(opvp_api_procs_t), 1))) { - ecode = -1; - } + if (!(apiEntry = calloc(sizeof(opvp_api_procs_t), 1))) { + ecode = -1; + } } else { - memset(apiEntry, 0, sizeof(opvp_api_procs_t)); + memset(apiEntry, 0, sizeof(opvp_api_procs_t)); } if (dc == -1) { - ecode = -1; - if (apiEntry) free(apiEntry); - apiEntry = NULL; - opvp_unload_vector_driver(); - if (inkjet) gdev_prn_close(dev); - else gdev_vector_close_file((gx_device_vector *)pdev); - return ecode; + ecode = -1; + if (apiEntry) free(apiEntry); + apiEntry = NULL; + opvp_unload_vector_driver(); + if (inkjet) gdev_prn_close(dev); + else gdev_vector_close_file((gx_device_vector *)pdev); + return ecode; } printerContext = dc; nApiEntry = sizeof(opvp_api_procs_t)/sizeof(void *); @@ -2111,92 +2111,92 @@ opvp_open(gx_device *dev) /* initialize */ if ((!ecode) && (!inkjet)) { - pdev->vec_procs = &opvp_vector_procs; - if (vector) gdev_vector_init((gx_device_vector *)pdev); + pdev->vec_procs = &opvp_vector_procs; + if (vector) gdev_vector_init((gx_device_vector *)pdev); } if (apiEntry->opvpQueryColorSpace) { - int n = sizeof(cspace_available); - int nn = n; - opvp_cspace_t *p = malloc(n*sizeof(opvp_cspace_t)); - - if ((r = apiEntry->opvpQueryColorSpace(printerContext,&nn,p)) - == OPVP_PARAMERROR && nn > n) { - /* realloc buffer and retry */ - p = realloc(p,nn*sizeof(opvp_cspace_t)); - r = apiEntry->opvpQueryColorSpace(printerContext,&nn,p); - } - if (r == OPVP_OK) { - int i; - - for (i = 0;i < nn;i++) { - if (p[i] < sizeof(cspace_available)) { - cspace_available[p[i]] = 1; - } - } - } - free(p); + int n = sizeof(cspace_available); + int nn = n; + opvp_cspace_t *p = malloc(n*sizeof(opvp_cspace_t)); + + if ((r = apiEntry->opvpQueryColorSpace(printerContext,&nn,p)) + == OPVP_PARAMERROR && nn > n) { + /* realloc buffer and retry */ + p = realloc(p,nn*sizeof(opvp_cspace_t)); + r = apiEntry->opvpQueryColorSpace(printerContext,&nn,p); + } + if (r == OPVP_OK) { + int i; + + for (i = 0;i < nn;i++) { + if (p[i] < sizeof(cspace_available)) { + cspace_available[p[i]] = 1; + } + } + } + free(p); } /* start job */ if (!ecode) { - /* job info */ - if (jobInfo) { - if (strlen(jobInfo) > 0) { - job_info = opvp_alloc_string(&job_info,jobInfo); - } - } - tmp_info = opvp_alloc_string(&tmp_info,opvp_gen_job_info(dev)); - if (tmp_info) { - if (strlen(tmp_info) > 0) { - if (job_info) { - if (strlen(job_info) > 0) { - opvp_cat_string(&job_info, ";"); - } - } - job_info = opvp_cat_string(&job_info,OPVP_INFO_PREFIX); - job_info = opvp_cat_string(&job_info,tmp_info); - } - } - - /* call StartJob */ - if (apiEntry->opvpStartJob) { - r = apiEntry->opvpStartJob(printerContext, - (opvp_char_t *)opvp_to_utf8(job_info)); - } - if (r != OPVP_OK) { - ecode = -1; - } + /* job info */ + if (jobInfo) { + if (strlen(jobInfo) > 0) { + job_info = opvp_alloc_string(&job_info,jobInfo); + } + } + tmp_info = opvp_alloc_string(&tmp_info,opvp_gen_job_info(dev)); + if (tmp_info) { + if (strlen(tmp_info) > 0) { + if (job_info) { + if (strlen(job_info) > 0) { + opvp_cat_string(&job_info, ";"); + } + } + job_info = opvp_cat_string(&job_info,OPVP_INFO_PREFIX); + job_info = opvp_cat_string(&job_info,tmp_info); + } + } + + /* call StartJob */ + if (apiEntry->opvpStartJob) { + r = apiEntry->opvpStartJob(printerContext, + (opvp_char_t *)opvp_to_utf8(job_info)); + } + if (r != OPVP_OK) { + ecode = -1; + } } /* start doc */ if (!ecode) { - /* doc info */ - if (docInfo) { - if (strlen(docInfo) > 0) { - doc_info = opvp_alloc_string(&doc_info,docInfo); - } - } - tmp_info = opvp_alloc_string(&tmp_info, opvp_gen_doc_info(dev)); - if (tmp_info) { - if (strlen(tmp_info) > 0) { - if (doc_info) { - if (strlen(doc_info) > 0) { - opvp_cat_string(&doc_info, ";"); - } - } - doc_info = opvp_cat_string(&doc_info,OPVP_INFO_PREFIX); - doc_info = opvp_cat_string(&doc_info,tmp_info); - } - } - - /* call StartDoc */ - if (apiEntry->opvpStartDoc) { - r = apiEntry->opvpStartDoc(printerContext, - (opvp_char_t *)opvp_to_utf8(doc_info)); - } - if (r != OPVP_OK) { - ecode = -1; - } + /* doc info */ + if (docInfo) { + if (strlen(docInfo) > 0) { + doc_info = opvp_alloc_string(&doc_info,docInfo); + } + } + tmp_info = opvp_alloc_string(&tmp_info, opvp_gen_doc_info(dev)); + if (tmp_info) { + if (strlen(tmp_info) > 0) { + if (doc_info) { + if (strlen(doc_info) > 0) { + opvp_cat_string(&doc_info, ";"); + } + } + doc_info = opvp_cat_string(&doc_info,OPVP_INFO_PREFIX); + doc_info = opvp_cat_string(&doc_info,tmp_info); + } + } + + /* call StartDoc */ + if (apiEntry->opvpStartDoc) { + r = apiEntry->opvpStartDoc(printerContext, + (opvp_char_t *)opvp_to_utf8(doc_info)); + } + if (r != OPVP_OK) { + ecode = -1; + } } if (tmp_info) opvp_alloc_string(&tmp_info, NULL); @@ -2209,7 +2209,7 @@ opvp_open(gx_device *dev) /* * open device for inkjet */ -static int +static int oprp_open(gx_device *dev) { /* set inkjet mode */ @@ -2224,7 +2224,7 @@ oprp_open(gx_device *dev) /* * get initial matrix */ -static void +static void opvp_get_initial_matrix(gx_device *dev, gs_matrix *pmat) { gx_device_opvp *pdev = (gx_device_opvp *)dev; @@ -2232,31 +2232,31 @@ opvp_get_initial_matrix(gx_device *dev, gs_matrix *pmat) gx_default_get_initial_matrix(dev,pmat); if (zooming) { - /* gs matrix */ - pmat->xx *= zoom[0]; - pmat->xy *= zoom[1]; - pmat->yx *= zoom[0]; - pmat->yy *= zoom[1]; - pmat->tx = pmat->tx * zoom[0] + shift[0]; - pmat->ty = pmat->ty * zoom[1] + shift[1]; + /* gs matrix */ + pmat->xx *= zoom[0]; + pmat->xy *= zoom[1]; + pmat->yx *= zoom[0]; + pmat->yy *= zoom[1]; + pmat->tx = pmat->tx * zoom[0] + shift[0]; + pmat->ty = pmat->ty * zoom[1] + shift[1]; } if (pdev->is_open) { - /* call ResetCTM */ - if (apiEntry->opvpResetCTM) { - apiEntry->opvpResetCTM(printerContext); - } else { - /* call SetCTM */ - omat.a = 1; - omat.b = 0; - omat.c = 0; - omat.d = 1; - omat.e = 0; - omat.f = 0; - if (apiEntry->opvpSetCTM) { - apiEntry->opvpSetCTM(printerContext, &omat); - } - } + /* call ResetCTM */ + if (apiEntry->opvpResetCTM) { + apiEntry->opvpResetCTM(printerContext); + } else { + /* call SetCTM */ + omat.a = 1; + omat.b = 0; + omat.c = 0; + omat.d = 1; + omat.e = 0; + omat.f = 0; + if (apiEntry->opvpSetCTM) { + apiEntry->opvpSetCTM(printerContext, &omat); + } + } } return; @@ -2265,7 +2265,7 @@ opvp_get_initial_matrix(gx_device *dev, gs_matrix *pmat) /* * output page */ -static int +static int opvp_output_page(gx_device *dev, int num_copies, int flush) { gx_device_opvp *pdev = (gx_device_opvp *)dev; @@ -2280,18 +2280,18 @@ opvp_output_page(gx_device *dev, int num_copies, int flush) /* check page-in */ if (opvp_check_in_page(pdev)) return -1; #endif - /* end page */ - code = opvp_endpage(); - if (code) ecode = code; + /* end page */ + code = opvp_endpage(); + if (code) ecode = code; - pdev->in_page = false; - beginPage = false; + pdev->in_page = false; + beginPage = false; #ifdef OPVP_IGNORE_BLANK_PAGE } #endif if (vector) { - gdev_vector_reset((gx_device_vector *)pdev); + gdev_vector_reset((gx_device_vector *)pdev); } code = gx_finish_output_page(dev, num_copies, flush); @@ -2303,7 +2303,7 @@ opvp_output_page(gx_device *dev, int num_copies, int flush) /* * print page */ -static int +static int oprp_print_page(gx_device_printer *pdev, FILE *prn_stream) { int ecode = 0; @@ -2335,9 +2335,9 @@ oprp_print_page(gx_device_printer *pdev, FILE *prn_stream) /* start page */ if (!ecode) { - code = opvp_startpage((gx_device *)pdev); - if (code) ecode = code; - else start_page = true; + code = opvp_startpage((gx_device *)pdev); + if (code) ecode = code; + else start_page = true; } /* moveto origin */ @@ -2346,85 +2346,85 @@ oprp_print_page(gx_device_printer *pdev, FILE *prn_stream) /* call StartRaster */ if (!ecode) { - if (apiEntry->opvpStartRaster) { - r = apiEntry->opvpStartRaster(printerContext,rasterWidth); - } - if (r != OPVP_OK) { - ecode = r; - } else { - start_raster = true; - } + if (apiEntry->opvpStartRaster) { + r = apiEntry->opvpStartRaster(printerContext,rasterWidth); + } + if (r != OPVP_OK) { + ecode = r; + } else { + start_raster = true; + } } /* line */ for (line = 0; (line < scan_lines) && (!ecode); line++) { - /* get raster data */ - if (!ecode) { - code = gdev_prn_get_bits(pdev, line, buff, &data); - if (code) { - ecode = code; - break; - } - } + /* get raster data */ + if (!ecode) { + code = gdev_prn_get_bits(pdev, line, buff, &data); + if (code) { + ecode = code; + break; + } + } #if ENABLE_SKIP_RASTER - /* check support SkipRaster */ - if (apiEntry->opvpSkipRaster) { - /* check all white */ - if (pdev->color_info.depth > 8) { - for (check = 0xff, i = 0; i < raster_size; i++) - { - check &= data[i]; - if (check != 0xff) break; - } - /* if all white call SkipRaster */ - if (check == 0xff) { - r = apiEntry->opvpSkipRaster(printerContext, 1); - if (r == OPVP_OK) continue; - } - } else { - for (check = 0, i = 0; i < raster_size; i++) { - check |= data[i]; - if (check) break; - } - /* if all zero call SkipRaster */ - if (check) { - r = apiEntry->opvpSkipRaster(printerContext, 1); - if (r == OPVP_OK) continue; - } - } - } + /* check support SkipRaster */ + if (apiEntry->opvpSkipRaster) { + /* check all white */ + if (pdev->color_info.depth > 8) { + for (check = 0xff, i = 0; i < raster_size; i++) + { + check &= data[i]; + if (check != 0xff) break; + } + /* if all white call SkipRaster */ + if (check == 0xff) { + r = apiEntry->opvpSkipRaster(printerContext, 1); + if (r == OPVP_OK) continue; + } + } else { + for (check = 0, i = 0; i < raster_size; i++) { + check |= data[i]; + if (check) break; + } + /* if all zero call SkipRaster */ + if (check) { + r = apiEntry->opvpSkipRaster(printerContext, 1); + if (r == OPVP_OK) continue; + } + } + } #endif - /* call TransferRasterData */ - if (!ecode) { - if (apiEntry->opvpTransferRasterData) { - r = apiEntry->opvpTransferRasterData(printerContext, - raster_size, - data); - } - if (r != OPVP_OK) ecode = r; - } + /* call TransferRasterData */ + if (!ecode) { + if (apiEntry->opvpTransferRasterData) { + r = apiEntry->opvpTransferRasterData(printerContext, + raster_size, + data); + } + if (r != OPVP_OK) ecode = r; + } } /* call EndRaster */ if (start_raster) { - if (apiEntry->opvpEndRaster) { - r = apiEntry->opvpEndRaster(printerContext); - } - if (r != OPVP_OK) ecode = r; - start_raster = false; + if (apiEntry->opvpEndRaster) { + r = apiEntry->opvpEndRaster(printerContext); + } + if (r != OPVP_OK) ecode = r; + start_raster = false; } /* end page */ if (start_page) { - code = opvp_endpage(); - if (code) ecode = code; - start_page = false; + code = opvp_endpage(); + if (code) ecode = code; + start_page = false; } /* free buffer */ if (buff) { - free(buff); - buff = NULL; + free(buff); + buff = NULL; } return ecode; @@ -2433,7 +2433,7 @@ oprp_print_page(gx_device_printer *pdev, FILE *prn_stream) /* * close device */ -static int +static int opvp_close(gx_device *dev) { gx_device_opvp *pdev = (gx_device_opvp *)dev; @@ -2441,21 +2441,21 @@ opvp_close(gx_device *dev) /* finalize */ if (printerContext != -1) { - /* call EndDoc */ - if (apiEntry->opvpEndDoc) { - apiEntry->opvpEndDoc(printerContext); - } + /* call EndDoc */ + if (apiEntry->opvpEndDoc) { + apiEntry->opvpEndDoc(printerContext); + } - /* call EndJob */ - if (apiEntry->opvpEndJob) { - apiEntry->opvpEndJob(printerContext); - } + /* call EndJob */ + if (apiEntry->opvpEndJob) { + apiEntry->opvpEndJob(printerContext); + } - /* call ClosePrinter */ - if (apiEntry->opvpClosePrinter) { - apiEntry->opvpClosePrinter(printerContext); - } - printerContext = -1; + /* call ClosePrinter */ + if (apiEntry->opvpClosePrinter) { + apiEntry->opvpClosePrinter(printerContext); + } + printerContext = -1; } /* unload vector driver */ @@ -2464,11 +2464,11 @@ opvp_close(gx_device *dev) opvp_unload_vector_driver(); if (inkjet) { - /* close printer */ - gdev_prn_close(dev); + /* close printer */ + gdev_prn_close(dev); } else { - /* close output stream */ - gdev_vector_close_file((gx_device_vector *)pdev); + /* close output stream */ + gdev_vector_close_file((gx_device_vector *)pdev); } outputFD = -1; @@ -2479,15 +2479,15 @@ opvp_close(gx_device *dev) * map rgb color */ #if GS_VERSION_MAJOR >= 8 -static gx_color_index +static gx_color_index opvp_map_rgb_color(gx_device *dev, - const gx_color_value *prgb /* modified for gs 8.15 */) + const gx_color_value *prgb /* modified for gs 8.15 */) #else -static gx_color_index +static gx_color_index opvp_map_rgb_color(gx_device *dev, - gx_color_value r, - gx_color_value g, - gx_color_value b) + gx_color_value r, + gx_color_value g, + gx_color_value b) #endif { opvp_cspace_t cs; @@ -2515,87 +2515,87 @@ opvp_map_rgb_color(gx_device *dev, cs = colorSpace; #else if (pdev->is_open) { - /* call GetColorSpace */ - if (apiEntry->opvpGetColorSpace) { - r = apiEntry->opvpGetColorSpace(printerContext, &cs); - } - if (r != OPVP_OK) { - if (pdev->color_info.depth > 32) { - cs = OPVP_CSPACE_STANDARDRGB64; - } else if (pdev->color_info.depth > 8 ) { - cs = OPVP_CSPACE_STANDARDRGB; - } else if (pdev->color_info.depth > 1 ) { - cs = OPVP_CSPACE_DEVICEGRAY; - } else { - cs = OPVP_CSPACE_BW; - } - } + /* call GetColorSpace */ + if (apiEntry->opvpGetColorSpace) { + r = apiEntry->opvpGetColorSpace(printerContext, &cs); + } + if (r != OPVP_OK) { + if (pdev->color_info.depth > 32) { + cs = OPVP_CSPACE_STANDARDRGB64; + } else if (pdev->color_info.depth > 8 ) { + cs = OPVP_CSPACE_STANDARDRGB; + } else if (pdev->color_info.depth > 1 ) { + cs = OPVP_CSPACE_DEVICEGRAY; + } else { + cs = OPVP_CSPACE_BW; + } + } } #endif switch (cs) { case OPVP_CSPACE_STANDARDRGB64: - /* unsupported */ - if (sizeof(gx_color_index) >= 6) { - return (long long)b - + ((long long)g << 16) - + ((long long)b << 32); - } else { - return gx_color_value_to_byte(b) - + ((uint)gx_color_value_to_byte(g) << 8) - + ((ulong)gx_color_value_to_byte(r) << 16); - } - break; + /* unsupported */ + if (sizeof(gx_color_index) >= 6) { + return (long long)b + + ((long long)g << 16) + + ((long long)b << 32); + } else { + return gx_color_value_to_byte(b) + + ((uint)gx_color_value_to_byte(g) << 8) + + ((ulong)gx_color_value_to_byte(r) << 16); + } + break; case OPVP_CSPACE_DEVICECMYK: case OPVP_CSPACE_DEVICECMY: - /* unsupported */ - c = gx_color_value_to_byte(~r); - m = gx_color_value_to_byte(~g); - y = gx_color_value_to_byte(~b); - if (cs == OPVP_CSPACE_DEVICECMYK) { - k = (c<m ? (c<y ? c : y) : (m<y ? m : y)); - c -= k; - m -= k; - y -= k; - } else { - k = 0; - } - return (k + (y << 8) + (m << 16) + (c << 24)); - break; + /* unsupported */ + c = gx_color_value_to_byte(~r); + m = gx_color_value_to_byte(~g); + y = gx_color_value_to_byte(~b); + if (cs == OPVP_CSPACE_DEVICECMYK) { + k = (c<m ? (c<y ? c : y) : (m<y ? m : y)); + c -= k; + m -= k; + y -= k; + } else { + k = 0; + } + return (k + (y << 8) + (m << 16) + (c << 24)); + break; case OPVP_CSPACE_DEVICEGRAY: #if GS_VERSION_MAJOR >= 8 - { - gx_color_value rgb[3]; - rgb[0] = rgb[1] = rgb[2] = r; - return gx_default_gray_map_rgb_color(dev, rgb); - } + { + gx_color_value rgb[3]; + rgb[0] = rgb[1] = rgb[2] = r; + return gx_default_gray_map_rgb_color(dev, rgb); + } #else - return gx_default_gray_map_rgb_color(dev, r, g, b); + return gx_default_gray_map_rgb_color(dev, r, g, b); #endif - break; + break; case OPVP_CSPACE_BW : #if GS_VERSION_MAJOR >= 8 - return gx_default_b_w_map_rgb_color(dev, prgb); + return gx_default_b_w_map_rgb_color(dev, prgb); #else - return gx_default_b_w_map_rgb_color(dev, r, g, b); + return gx_default_b_w_map_rgb_color(dev, r, g, b); #endif - break; + break; case OPVP_CSPACE_STANDARDRGB: case OPVP_CSPACE_DEVICEKRGB: default: #if GS_VERSION_MAJOR >= 8 - return gx_default_rgb_map_rgb_color(dev, prgb); + return gx_default_rgb_map_rgb_color(dev, prgb); #else - return gx_default_rgb_map_rgb_color(dev, r, g, b); + return gx_default_rgb_map_rgb_color(dev, r, g, b); #endif - break; + break; } } /* * map color rgb */ -static int +static int opvp_map_color_rgb(gx_device *dev, gx_color_index color, gx_color_value prgb[3]) { @@ -2611,63 +2611,63 @@ opvp_map_color_rgb(gx_device *dev, gx_color_index color, #else /* call GetColorSpace */ if (pdev->is_open) { - if (apiEntry->opvpGetColorSpace) { - r = apiEntry->opvpGetColorSpace(printerContext, &cs); - } - if (r != OPVP_OK) { - if (pdev->color_info.depth > 32) { - cs = OPVP_CSPACE_STANDARDRGB64; - } else if (pdev->color_info.depth > 8 ) { - cs = OPVP_CSPACE_STANDARDRGB; - } else if (pdev->color_info.depth > 1 ) { - cs = OPVP_CSPACE_DEVICEGRAY; - } else { - cs = OPVP_CSPACE_BW; - } - } + if (apiEntry->opvpGetColorSpace) { + r = apiEntry->opvpGetColorSpace(printerContext, &cs); + } + if (r != OPVP_OK) { + if (pdev->color_info.depth > 32) { + cs = OPVP_CSPACE_STANDARDRGB64; + } else if (pdev->color_info.depth > 8 ) { + cs = OPVP_CSPACE_STANDARDRGB; + } else if (pdev->color_info.depth > 1 ) { + cs = OPVP_CSPACE_DEVICEGRAY; + } else { + cs = OPVP_CSPACE_BW; + } + } } #endif switch (cs) { case OPVP_CSPACE_STANDARDRGB64: - /* unsupported */ - if (sizeof(gx_color_index) >= 6) { - prgb[0] = ((long long)color >> 32) & 0xffff; - prgb[1] = ((long long)color >> 16) & 0xffff; - prgb[2] = color & 0xffff; - } else { - prgb[0] = gx_color_value_from_byte((color >> 16) & 0xff); - prgb[1] = gx_color_value_from_byte((color >> 8) & 0xff); - prgb[2] = gx_color_value_from_byte(color & 0xff); - } - break; + /* unsupported */ + if (sizeof(gx_color_index) >= 6) { + prgb[0] = ((long long)color >> 32) & 0xffff; + prgb[1] = ((long long)color >> 16) & 0xffff; + prgb[2] = color & 0xffff; + } else { + prgb[0] = gx_color_value_from_byte((color >> 16) & 0xff); + prgb[1] = gx_color_value_from_byte((color >> 8) & 0xff); + prgb[2] = gx_color_value_from_byte(color & 0xff); + } + break; case OPVP_CSPACE_DEVICECMYK: case OPVP_CSPACE_DEVICECMY: - /* unsupported */ - c = gx_color_value_from_byte((color >> 24) & 0xff); - m = gx_color_value_from_byte((color >> 16) & 0xff); - y = gx_color_value_from_byte((color >> 8) & 0xff); - if (cs == OPVP_CSPACE_DEVICECMYK) { - k = gx_color_value_from_byte(color & 0xff); - c += k; if (c > 255) c = 255; - m += k; if (m > 255) m = 255; - y += k; if (y > 255) y = 255; - } - prgb[0] = gx_color_value_from_byte(~c & 0xff); - prgb[1] = gx_color_value_from_byte(~m & 0xff); - prgb[2] = gx_color_value_from_byte(~y & 0xff); - break; + /* unsupported */ + c = gx_color_value_from_byte((color >> 24) & 0xff); + m = gx_color_value_from_byte((color >> 16) & 0xff); + y = gx_color_value_from_byte((color >> 8) & 0xff); + if (cs == OPVP_CSPACE_DEVICECMYK) { + k = gx_color_value_from_byte(color & 0xff); + c += k; if (c > 255) c = 255; + m += k; if (m > 255) m = 255; + y += k; if (y > 255) y = 255; + } + prgb[0] = gx_color_value_from_byte(~c & 0xff); + prgb[1] = gx_color_value_from_byte(~m & 0xff); + prgb[2] = gx_color_value_from_byte(~y & 0xff); + break; case OPVP_CSPACE_DEVICEGRAY: - return gx_default_gray_map_color_rgb(dev, color, prgb); - break; + return gx_default_gray_map_color_rgb(dev, color, prgb); + break; case OPVP_CSPACE_BW: - return gx_default_b_w_map_color_rgb(dev, color, prgb); - break; + return gx_default_b_w_map_color_rgb(dev, color, prgb); + break; case OPVP_CSPACE_STANDARDRGB: case OPVP_CSPACE_DEVICEKRGB: default: - return gx_default_rgb_map_color_rgb(dev, color, prgb); - break; + return gx_default_rgb_map_color_rgb(dev, color, prgb); + break; } return 0; @@ -2676,7 +2676,7 @@ opvp_map_color_rgb(gx_device *dev, gx_color_index color, /* * fill rectangle */ -static int +static int opvp_fill_rectangle( gx_device *dev, int x, @@ -2693,7 +2693,7 @@ opvp_fill_rectangle( opvp_point_t point; if (vector) { - return gdev_vector_fill_rectangle( dev, x, y, w, h, color); + return gdev_vector_fill_rectangle( dev, x, y, w, h, color); } /* check page-in */ @@ -2702,7 +2702,7 @@ opvp_fill_rectangle( #if !(ENABLE_SIMPLE_MODE) /* call SaveGS */ if (apiEntry->opvpSaveGS) { - apiEntry->opvpSaveGS(printerContext); + apiEntry->opvpSaveGS(printerContext); } #endif @@ -2711,40 +2711,40 @@ opvp_fill_rectangle( /* call SetFillColor */ if (apiEntry->opvpSetFillColor) { - apiEntry->opvpSetFillColor(printerContext, &brush); + apiEntry->opvpSetFillColor(printerContext, &brush); } /* call SetCurrentPoint */ OPVP_I2FIX(x, point.x); OPVP_I2FIX(y, point.y); if (apiEntry->opvpSetCurrentPoint) { - apiEntry->opvpSetCurrentPoint(printerContext,point.x, point.y); + apiEntry->opvpSetCurrentPoint(printerContext,point.x, point.y); } /* draw image */ code = opvp_draw_image(pdev, - 1, - 2, 2, - w, h, - 4, - 0, - data); + 1, + 2, 2, + w, h, + 4, + 0, + data); if (code) { - ecode = code; + ecode = code; } /* restore fill color */ if (vectorFillColor) { - /* call SetFillColor */ - if (apiEntry->opvpSetFillColor) { - apiEntry->opvpSetFillColor(printerContext,vectorFillColor); - } + /* call SetFillColor */ + if (apiEntry->opvpSetFillColor) { + apiEntry->opvpSetFillColor(printerContext,vectorFillColor); + } } #if !(ENABLE_SIMPLE_MODE) /* call RestoreGS */ if (apiEntry->opvpRestoreGS) { - apiEntry->opvpRestoreGS(printerContext); + apiEntry->opvpRestoreGS(printerContext); } #endif @@ -2754,7 +2754,7 @@ opvp_fill_rectangle( /* * copy mono */ -static int +static int opvp_copy_mono( gx_device *dev, const byte *data, @@ -2790,65 +2790,65 @@ opvp_copy_mono( /* data offset */ if (data_x) { - byte_offset = data_x >> 3; - bit_shift = data_x & 0x07; - if (bit_shift) bit_mask <<= (8 - bit_shift); - - byte_length = ((w + 7) >> 3); - adj_raster = ((byte_length + 3) >> 2) << 2; - - buff = mybuf = calloc(adj_raster, h); - if (!mybuf) { - /* memory error */ - return -1; - } - s = &(data[byte_offset]); - d = mybuf; - if (bit_shift) { - for (i = 0;i < h; i++, d += adj_raster, s+= raster) { - for (j = 0; j < byte_length; j++) { - d[j] = ((s[j] & ~bit_mask) << bit_shift) - | ((s[j + 1] & bit_mask) >> (8 - bit_shift)); - } - } - } else { - for (i = 0;i < h; i++, d += adj_raster, s+= raster) { - for (j = 0; j < byte_length; j++) { - d[j] = s[j]; - } - } - } - byte_offset = 0; + byte_offset = data_x >> 3; + bit_shift = data_x & 0x07; + if (bit_shift) bit_mask <<= (8 - bit_shift); + + byte_length = ((w + 7) >> 3); + adj_raster = ((byte_length + 3) >> 2) << 2; + + buff = mybuf = calloc(adj_raster, h); + if (!mybuf) { + /* memory error */ + return -1; + } + s = &(data[byte_offset]); + d = mybuf; + if (bit_shift) { + for (i = 0;i < h; i++, d += adj_raster, s+= raster) { + for (j = 0; j < byte_length; j++) { + d[j] = ((s[j] & ~bit_mask) << bit_shift) + | ((s[j + 1] & bit_mask) >> (8 - bit_shift)); + } + } + } else { + for (i = 0;i < h; i++, d += adj_raster, s+= raster) { + for (j = 0; j < byte_length; j++) { + d[j] = s[j]; + } + } + } + byte_offset = 0; } #if !(ENABLE_SIMPLE_MODE) /* call SaveGS */ if (apiEntry->opvpSaveGS) { - apiEntry->opvpSaveGS(printerContext); + apiEntry->opvpSaveGS(printerContext); } #endif if (one == gx_no_color_index) { - gx_color_index tc; + gx_color_index tc; - reverse = (!reverse); - tc = zero; - zero = one; - one = tc; + reverse = (!reverse); + tc = zero; + zero = one; + one = tc; } if (zero != gx_no_color_index) { - /* not mask */ - /* Set PaintMode */ - if (apiEntry->opvpSetPaintMode) { - apiEntry->opvpSetPaintMode(printerContext,OPVP_PAINTMODE_OPAQUE); - } - /* zero-color */ - opvp_set_brush_color(pdev, zero, &brush); + /* not mask */ + /* Set PaintMode */ + if (apiEntry->opvpSetPaintMode) { + apiEntry->opvpSetPaintMode(printerContext,OPVP_PAINTMODE_OPAQUE); + } + /* zero-color */ + opvp_set_brush_color(pdev, zero, &brush); - /* call SetBgColor */ - if (apiEntry->opvpSetBgColor) { - apiEntry->opvpSetBgColor(printerContext, &brush); - } + /* call SetBgColor */ + if (apiEntry->opvpSetBgColor) { + apiEntry->opvpSetBgColor(printerContext, &brush); + } } /* one-color */ @@ -2856,67 +2856,67 @@ opvp_copy_mono( /* call SetFillColor */ if (apiEntry->opvpSetFillColor) { - apiEntry->opvpSetFillColor(printerContext, &brush); + apiEntry->opvpSetFillColor(printerContext, &brush); } if (reverse) { - /* 0/1 reverse image */ - int n = adj_raster*h; - - if (buff == data) { - /* buff was not allocated from this function yet */ - /* allocate here */ - if ((mybuf = malloc(n)) == 0) return -1; - } - for (i = 0;i < n;i++) { - mybuf[i] = ~buff[i]; - } - buff = mybuf; + /* 0/1 reverse image */ + int n = adj_raster*h; + + if (buff == data) { + /* buff was not allocated from this function yet */ + /* allocate here */ + if ((mybuf = malloc(n)) == 0) return -1; + } + for (i = 0;i < n;i++) { + mybuf[i] = ~buff[i]; + } + buff = mybuf; } /* call SetCurrentPoint */ OPVP_I2FIX(x, point.x); OPVP_I2FIX(y, point.y); if (apiEntry->opvpSetCurrentPoint) { - apiEntry->opvpSetCurrentPoint(printerContext,point.x, point.y); + apiEntry->opvpSetCurrentPoint(printerContext,point.x, point.y); } /* draw image */ code = opvp_draw_image(pdev, - 1, - w, h, - w, h, - adj_raster, - 1, - &(buff[byte_offset])); + 1, + w, h, + w, h, + adj_raster, + 1, + &(buff[byte_offset])); if (code) { - ecode = code; + ecode = code; } if (zero != gx_no_color_index) { - /* restore PaintMode */ - if (apiEntry->opvpSetPaintMode) { - apiEntry->opvpSetPaintMode(printerContext, - OPVP_PAINTMODE_TRANSPARENT); - } + /* restore PaintMode */ + if (apiEntry->opvpSetPaintMode) { + apiEntry->opvpSetPaintMode(printerContext, + OPVP_PAINTMODE_TRANSPARENT); + } } /* restore fill color */ if (vectorFillColor) { - /* call SetFillColor */ - if (apiEntry->opvpSetFillColor) { - apiEntry->opvpSetFillColor(printerContext,vectorFillColor); - } + /* call SetFillColor */ + if (apiEntry->opvpSetFillColor) { + apiEntry->opvpSetFillColor(printerContext,vectorFillColor); + } } #if !(ENABLE_SIMPLE_MODE) /* call RestoreGS */ if (apiEntry->opvpRestoreGS) { - apiEntry->opvpRestoreGS(printerContext); + apiEntry->opvpRestoreGS(printerContext); } #endif if (buff != data) { - /* buff was allocated from this function */ - if (mybuf) free(mybuf); + /* buff was allocated from this function */ + if (mybuf) free(mybuf); } return ecode; @@ -2925,7 +2925,7 @@ opvp_copy_mono( /* * copy color */ -static int +static int opvp_copy_color( gx_device *dev, const byte *data, @@ -2956,28 +2956,28 @@ opvp_copy_color( /* data offset */ if (data_x) { - depth = pdev->color_info.depth; - pixel = (depth + 7) >> 3; - byte_length = pixel * w; - adj_raster = ((byte_length + 3) >> 2) << 2; - - buff = mybuf = malloc(adj_raster * h); - if (!mybuf) { - /* memory error */ - return -1; - } - s = &(data[data_x*pixel]); - d = mybuf; - for (i = 0;i < h; i++, d += adj_raster, s += raster) { - memcpy(d, s, byte_length); - } - data_x = 0; + depth = pdev->color_info.depth; + pixel = (depth + 7) >> 3; + byte_length = pixel * w; + adj_raster = ((byte_length + 3) >> 2) << 2; + + buff = mybuf = malloc(adj_raster * h); + if (!mybuf) { + /* memory error */ + return -1; + } + s = &(data[data_x*pixel]); + d = mybuf; + for (i = 0;i < h; i++, d += adj_raster, s += raster) { + memcpy(d, s, byte_length); + } + data_x = 0; } #if !(ENABLE_SIMPLE_MODE) /* call SaveGS */ if (apiEntry->opvpSaveGS) { - apiEntry->opvpSaveGS(printerContext); + apiEntry->opvpSaveGS(printerContext); } #endif @@ -2985,32 +2985,32 @@ opvp_copy_color( OPVP_I2FIX(x, point.x); OPVP_I2FIX(y, point.y); if (apiEntry->opvpSetCurrentPoint) { - apiEntry->opvpSetCurrentPoint(printerContext, point.x, point.y); + apiEntry->opvpSetCurrentPoint(printerContext, point.x, point.y); } /* draw image */ code = opvp_draw_image(pdev, - pdev->color_info.depth, - w, h, - w, h, - adj_raster, - 0, - &(buff[data_x])); + pdev->color_info.depth, + w, h, + w, h, + adj_raster, + 0, + &(buff[data_x])); if (code) { - ecode = code; + ecode = code; } #if !(ENABLE_SIMPLE_MODE) /* call RestoreGS */ if (apiEntry->opvpRestoreGS) { - apiEntry->opvpRestoreGS(printerContext); + apiEntry->opvpRestoreGS(printerContext); } #endif if (buff != data) { - /* buff was allocated from this function */ - if (mybuf) free(mybuf); + /* buff was allocated from this function */ + if (mybuf) free(mybuf); } return ecode; @@ -3019,7 +3019,7 @@ opvp_copy_color( /* * get params */ -static int +static int _get_params(gs_param_list *plist) { int code; @@ -3074,24 +3074,24 @@ _get_params(gs_param_list *plist) /* fast image support */ switch (FastImageMode) { case FastImageNoCTM: - opvp_alloc_string(&fastImage, "NoCTM"); - break; + opvp_alloc_string(&fastImage, "NoCTM"); + break; case FastImageNoRotate: - opvp_alloc_string(&fastImage, "NoRotateCTM"); - break; + opvp_alloc_string(&fastImage, "NoRotateCTM"); + break; case FastImageRightAngle: - opvp_alloc_string(&fastImage, "RightAngleCTM"); - break; + opvp_alloc_string(&fastImage, "RightAngleCTM"); + break; case FastImageReverseAngle: - opvp_alloc_string(&fastImage, "ReverseAngleCTM"); - break; + opvp_alloc_string(&fastImage, "ReverseAngleCTM"); + break; case FastImageAll: - opvp_alloc_string(&fastImage, "All"); - break; + opvp_alloc_string(&fastImage, "All"); + break; case FastImageDisable: default: - opvp_alloc_string(&fastImage, NULL); - break; + opvp_alloc_string(&fastImage, NULL); + break; } pname = "FastImage"; fips.data = (byte *)fastImage; @@ -3146,7 +3146,7 @@ _get_params(gs_param_list *plist) /* * get params for vector */ -static int +static int opvp_get_params(gx_device *dev, gs_param_list *plist) { int code; @@ -3162,7 +3162,7 @@ opvp_get_params(gx_device *dev, gs_param_list *plist) /* * get params for inkjet */ -static int +static int oprp_get_params(gx_device *dev, gs_param_list *plist) { int code; @@ -3178,7 +3178,7 @@ oprp_get_params(gx_device *dev, gs_param_list *plist) /* * put params */ -static int +static int _put_params(gs_param_list *plist) { int code; @@ -3201,17 +3201,17 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &vdps); switch (code) { case 0: - buff = realloc(buff, vdps.size + 1); - memcpy(buff, vdps.data, vdps.size); - buff[vdps.size] = 0; - opvp_alloc_string(&vectorDriver, buff); - break; + buff = realloc(buff, vdps.size + 1); + memcpy(buff, vdps.data, vdps.size); + buff[vdps.size] = 0; + opvp_alloc_string(&vectorDriver, buff); + break; case 1: - /* opvp_alloc_string(&vectorDriver, NULL);*/ - break; + /* opvp_alloc_string(&vectorDriver, NULL);*/ + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } /* printer model name */ @@ -3219,17 +3219,17 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &pmps); switch (code) { case 0: - buff = realloc(buff, pmps.size + 1); - memcpy(buff, pmps.data, pmps.size); - buff[pmps.size] = 0; - opvp_alloc_string(&printerModel, buff); - break; + buff = realloc(buff, pmps.size + 1); + memcpy(buff, pmps.data, pmps.size); + buff[pmps.size] = 0; + opvp_alloc_string(&printerModel, buff); + break; case 1: - /*opvp_alloc_string(&printerModel, NULL);*/ - break; + /*opvp_alloc_string(&printerModel, NULL);*/ + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } /* job info */ @@ -3237,17 +3237,17 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &jips); switch (code) { case 0: - buff = realloc(buff, jips.size + 1); - memcpy(buff, jips.data, jips.size); - buff[jips.size] = 0; - opvp_alloc_string(&jobInfo, buff); - break; + buff = realloc(buff, jips.size + 1); + memcpy(buff, jips.data, jips.size); + buff[jips.size] = 0; + opvp_alloc_string(&jobInfo, buff); + break; case 1: - /*opvp_alloc_string(&jobInfo, NULL);*/ - break; + /*opvp_alloc_string(&jobInfo, NULL);*/ + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } /* doc info */ @@ -3255,17 +3255,17 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &dips); switch (code) { case 0: - buff = realloc(buff, dips.size + 1); - memcpy(buff, dips.data, dips.size); - buff[dips.size] = 0; - opvp_alloc_string(&docInfo, buff); - break; + buff = realloc(buff, dips.size + 1); + memcpy(buff, dips.data, dips.size); + buff[dips.size] = 0; + opvp_alloc_string(&docInfo, buff); + break; case 1: - /*opvp_alloc_string(&docInfo, NULL);*/ - break; + /*opvp_alloc_string(&docInfo, NULL);*/ + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } /* fast image support */ @@ -3273,30 +3273,30 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &fips); switch (code) { case 0: - buff = realloc(buff, fips.size + 1); - memcpy(buff, fips.data, fips.size); - buff[fips.size] = 0; - opvp_alloc_string(&fastImage, buff); - if (strcasecmp(fastImage,"NoCTM")==0) { - FastImageMode = FastImageNoCTM; - } else if (strncasecmp(fastImage,"NoRotate",8)==0) { - FastImageMode = FastImageNoRotate; - } else if (strncasecmp(fastImage,"Right",5)==0) { - FastImageMode = FastImageRightAngle; - } else if (strncasecmp(fastImage,"Reverse",7)==0) { - FastImageMode = FastImageReverseAngle; - } else if (strncasecmp(fastImage,"All",3)==0) { - FastImageMode = FastImageAll; - } else { - FastImageMode = FastImageDisable; - } - break; + buff = realloc(buff, fips.size + 1); + memcpy(buff, fips.data, fips.size); + buff[fips.size] = 0; + opvp_alloc_string(&fastImage, buff); + if (strcasecmp(fastImage,"NoCTM")==0) { + FastImageMode = FastImageNoCTM; + } else if (strncasecmp(fastImage,"NoRotate",8)==0) { + FastImageMode = FastImageNoRotate; + } else if (strncasecmp(fastImage,"Right",5)==0) { + FastImageMode = FastImageRightAngle; + } else if (strncasecmp(fastImage,"Reverse",7)==0) { + FastImageMode = FastImageReverseAngle; + } else if (strncasecmp(fastImage,"All",3)==0) { + FastImageMode = FastImageAll; + } else { + FastImageMode = FastImageDisable; + } + break; case 1: - /*opvp_alloc_string(&fastImage, NULL);*/ - break; + /*opvp_alloc_string(&fastImage, NULL);*/ + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } /* margins */ @@ -3304,61 +3304,61 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &mlps); switch (code) { case 0: - buff = realloc(buff, mlps.size + 1); - memcpy(buff, mlps.data, mlps.size); - buff[mlps.size] = 0; - margins[0] = atof(buff); - break; + buff = realloc(buff, mlps.size + 1); + memcpy(buff, mlps.data, mlps.size); + buff[mlps.size] = 0; + margins[0] = atof(buff); + break; case 1: - break; + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } pname = "MarginTop"; code = param_read_string(plist, pname, &mtps); switch (code) { case 0: - buff = realloc(buff, mtps.size + 1); - memcpy(buff, mtps.data, mtps.size); - buff[mtps.size] = 0; - margins[3] = atof(buff); - break; + buff = realloc(buff, mtps.size + 1); + memcpy(buff, mtps.data, mtps.size); + buff[mtps.size] = 0; + margins[3] = atof(buff); + break; case 1: - break; + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } pname = "MarginRight"; code = param_read_string(plist, pname, &mrps); switch (code) { case 0: - buff = realloc(buff, mrps.size + 1); - memcpy(buff, mrps.data, mrps.size); - buff[mrps.size] = 0; - margins[2] = atof(buff); - break; + buff = realloc(buff, mrps.size + 1); + memcpy(buff, mrps.data, mrps.size); + buff[mrps.size] = 0; + margins[2] = atof(buff); + break; case 1: - break; + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } pname = "MarginBottom"; code = param_read_string(plist, pname, &mbps); switch (code) { case 0: - buff = realloc(buff, mbps.size + 1); - memcpy(buff, mbps.data, mbps.size); - buff[mbps.size] = 0; - margins[1] = atof(buff); - break; + buff = realloc(buff, mbps.size + 1); + memcpy(buff, mbps.data, mbps.size); + buff[mbps.size] = 0; + margins[1] = atof(buff); + break; case 1: - break; + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } /* zoom */ @@ -3366,26 +3366,26 @@ _put_params(gs_param_list *plist) code = param_read_string(plist, pname, &zmps); switch (code) { case 0: - buff = realloc(buff, zmps.size + 1); - memcpy(buff, zmps.data, zmps.size); - buff[zmps.size] = 0; - if (strncasecmp(buff, "Auto", 4)) { - zoom[0] = atof(buff); - if (zoom[0] > 0) { - zoom[1] = zoom[0]; - } else { - zoom[0] = zoom[1] = 1; - } - } else { - zoom[0] = zoom[1] = 1; - zoomAuto = true; - } - break; + buff = realloc(buff, zmps.size + 1); + memcpy(buff, zmps.data, zmps.size); + buff[zmps.size] = 0; + if (strncasecmp(buff, "Auto", 4)) { + zoom[0] = atof(buff); + if (zoom[0] > 0) { + zoom[1] = zoom[0]; + } else { + zoom[0] = zoom[1] = 1; + } + } else { + zoom[0] = zoom[1] = 1; + zoomAuto = true; + } + break; case 1: - break; + break; default: - ecode = code; - param_signal_error(plist, pname, ecode); + ecode = code; + param_signal_error(plist, pname, ecode); } if (buff) free(buff); @@ -3396,7 +3396,7 @@ _put_params(gs_param_list *plist) /* * put params for vector */ -static int +static int opvp_put_params(gx_device *dev, gs_param_list *plist) { int code; @@ -3412,7 +3412,7 @@ opvp_put_params(gx_device *dev, gs_param_list *plist) /* * put params for inkjet */ -static int +static int oprp_put_params(gx_device *dev, gs_param_list *plist) { int code; @@ -3428,7 +3428,7 @@ oprp_put_params(gx_device *dev, gs_param_list *plist) /* * fill path */ -static int +static int opvp_fill_path( gx_device *dev, const gs_imager_state *pis, @@ -3442,19 +3442,19 @@ opvp_fill_path( /* check clippath support */ if (!(apiEntry->opvpSetClipPath)) { - /* get clipping box area */ - gx_cpath_inner_box(pxpath,&inner); - gx_cpath_outer_box(pxpath,&outer); - /* check difference between inner-box and outer-box */ - if ((inner.p.x != outer.p.x) || (inner.p.y != outer.p.y) || - (inner.q.x != outer.q.x) || (inner.q.y != outer.q.y)) { - /* set draw by image */ - draw_image = true; - } + /* get clipping box area */ + gx_cpath_inner_box(pxpath,&inner); + gx_cpath_outer_box(pxpath,&outer); + /* check difference between inner-box and outer-box */ + if ((inner.p.x != outer.p.x) || (inner.p.y != outer.p.y) || + (inner.q.x != outer.q.x) || (inner.q.y != outer.q.y)) { + /* set draw by image */ + draw_image = true; + } } if (!vector || draw_image) { - return gx_default_fill_path(dev, pis, ppath, params, pdevc, pxpath); + return gx_default_fill_path(dev, pis, ppath, params, pdevc, pxpath); } return gdev_vector_fill_path(dev, pis, ppath, params, pdevc, pxpath); @@ -3463,7 +3463,7 @@ opvp_fill_path( /* * stroke path */ -static int +static int opvp_stroke_path( gx_device *dev, const gs_imager_state *pis, @@ -3477,30 +3477,30 @@ opvp_stroke_path( /* check clippath support */ if (!(apiEntry->opvpSetClipPath)) { - /* get clipping box area */ - gx_cpath_inner_box(pxpath,&inner); - gx_cpath_outer_box(pxpath,&outer); - /* check difference between inner-box and outer-box */ - if ((inner.p.x != outer.p.x) || (inner.p.y != outer.p.y) || - (inner.q.x != outer.q.x) || (inner.q.y != outer.q.y)) { - /* set draw by image */ - draw_image = true; - } + /* get clipping box area */ + gx_cpath_inner_box(pxpath,&inner); + gx_cpath_outer_box(pxpath,&outer); + /* check difference between inner-box and outer-box */ + if ((inner.p.x != outer.p.x) || (inner.p.y != outer.p.y) || + (inner.q.x != outer.q.x) || (inner.q.y != outer.q.y)) { + /* set draw by image */ + draw_image = true; + } } if (!vector || draw_image) { - return gx_default_stroke_path(dev, pis, ppath, - params, pdcolor, pxpath); + return gx_default_stroke_path(dev, pis, ppath, + params, pdcolor, pxpath); } return gdev_vector_stroke_path(dev, pis, ppath, - params, pdcolor, pxpath); + params, pdcolor, pxpath); } /* * fill mask */ -static int +static int opvp_fill_mask( gx_device *dev, const byte *data, @@ -3517,23 +3517,23 @@ opvp_fill_mask( const gx_clip_path *pcpath) { if (vector) { -#if GS_VERSION_MAJOR >= 8 /* for gs 8.15 */ - gdev_vector_update_fill_color((gx_device_vector *)dev, NULL, pdcolor); +#if GS_VERSION_MAJOR >= 8 /* for gs 8.15 */ + gdev_vector_update_fill_color((gx_device_vector *)dev, NULL, pdcolor); #else - gdev_vector_update_fill_color((gx_device_vector *)dev, pdcolor); + gdev_vector_update_fill_color((gx_device_vector *)dev, pdcolor); #endif - gdev_vector_update_clip_path((gx_device_vector *)dev, pcpath); - gdev_vector_update_log_op((gx_device_vector *)dev, lop); + gdev_vector_update_clip_path((gx_device_vector *)dev, pcpath); + gdev_vector_update_log_op((gx_device_vector *)dev, lop); } return gx_default_fill_mask(dev, data, data_x, raster, id, - x, y, w, h, pdcolor, depth, lop, pcpath); + x, y, w, h, pdcolor, depth, lop, pcpath); } /* * begin image */ -static int +static int opvp_begin_image( gx_device *dev, const gs_imager_state *pis, @@ -3542,7 +3542,7 @@ opvp_begin_image( const gs_int_rect *prect, const gx_drawing_color *pdcolor, const gx_clip_path *pcpath, - gs_memory_t *mem, + gs_memory_t *mem, gx_image_enum_common_t **pinfo) { gx_device_vector *vdev =(gx_device_vector *)dev; @@ -3563,344 +3563,344 @@ opvp_begin_image( color_index = 0; vinfo = gs_alloc_struct(mem, gdev_vector_image_enum_t, - &st_vector_image_enum, - "opvp_begin_image"); + &st_vector_image_enum, + "opvp_begin_image"); if (vinfo) { - memcpy(imageDecode,pim->Decode,sizeof(pim->Decode)); - vinfo->memory =mem; - code = gdev_vector_begin_image(vdev, pis, pim, format, prect, - pdcolor, pcpath, mem, - &opvp_image_enum_procs, - vinfo); - if (code) ecode = code; - - if (!ecode) { - /* bits per pixel */ - for (bits_per_pixel=0, p=0; p < vinfo->num_planes; p++) { - bits_per_pixel += vinfo->plane_depths[p]; - } - - /* for indexed color */ - if (!(pim->ImageMask)) { - color_index = gs_color_space_get_index(pcs); - if (color_index == gs_color_space_index_Indexed) { - base_color_index - = gs_color_space_indexed_base_space(pcs)->type->index; - if (((pcs->params.indexed.hival + 1) > 256) - || (bits_per_pixel != 8 && bits_per_pixel != 1)) { - return gx_default_begin_image( - dev, pis, pim, format, - prect, pdcolor, pcpath, - mem, pinfo); - } else if (base_color_index - == gs_color_space_index_DeviceCMYK) { - /* for CMYK indexed color */ - int count; - const unsigned char *p - = pcs->params.indexed.lookup.table.data; - frac rgb[3]; - - for(count = 0;count < - (pcs->params.indexed.hival + 1); count++) { - memset(rgb, 0, sizeof(rgb)); - color_cmyk_to_rgb( - byte2frac((*(p + 0 + (count * 4)))), - byte2frac((*(p + 1 + (count * 4)))), - byte2frac((*(p + 2 + (count * 4)))), - byte2frac((*(p + 3 + (count * 4)))), - pis, rgb); - *(palette + 0 + (count * 3)) = frac2byte(rgb[0]); - *(palette + 1 + (count * 3)) = frac2byte(rgb[1]); - *(palette + 2 + (count * 3)) = frac2byte(rgb[2]); - } - - bits_per_pixel = 24; - } else if (base_color_index - == gs_color_space_index_DeviceRGB || - base_color_index == gs_color_space_index_CIEABC) { - /* for RGB or CalRGB indexed color */ - memcpy(palette, pcs->params.indexed.lookup.table.data,\ - pcs->params.indexed.lookup.table.size); - bits_per_pixel = 24; - } else if (base_color_index - == gs_color_space_index_DeviceGray || - base_color_index == gs_color_space_index_CIEA) { - /* for Gray or CalGray indexed color */ - memcpy(palette, pcs->params.indexed.lookup.table.data,\ - pcs->params.indexed.lookup.table.size); - bits_per_pixel = 8; - } else { - /* except CMYK and RGB */ - return gx_default_begin_image( - dev, pis, pim, format, - prect, pdcolor, pcpath, - mem, pinfo); - } - } - } + memcpy(imageDecode,pim->Decode,sizeof(pim->Decode)); + vinfo->memory =mem; + code = gdev_vector_begin_image(vdev, pis, pim, format, prect, + pdcolor, pcpath, mem, + &opvp_image_enum_procs, + vinfo); + if (code) ecode = code; + + if (!ecode) { + /* bits per pixel */ + for (bits_per_pixel=0, p=0; p < vinfo->num_planes; p++) { + bits_per_pixel += vinfo->plane_depths[p]; + } + + /* for indexed color */ + if (!(pim->ImageMask)) { + color_index = gs_color_space_get_index(pcs); + if (color_index == gs_color_space_index_Indexed) { + base_color_index + = gs_color_space_indexed_base_space(pcs)->type->index; + if (((pcs->params.indexed.hival + 1) > 256) + || (bits_per_pixel != 8 && bits_per_pixel != 1)) { + return gx_default_begin_image( + dev, pis, pim, format, + prect, pdcolor, pcpath, + mem, pinfo); + } else if (base_color_index + == gs_color_space_index_DeviceCMYK) { + /* for CMYK indexed color */ + int count; + const unsigned char *p + = pcs->params.indexed.lookup.table.data; + frac rgb[3]; + + for(count = 0;count < + (pcs->params.indexed.hival + 1); count++) { + memset(rgb, 0, sizeof(rgb)); + color_cmyk_to_rgb( + byte2frac((*(p + 0 + (count * 4)))), + byte2frac((*(p + 1 + (count * 4)))), + byte2frac((*(p + 2 + (count * 4)))), + byte2frac((*(p + 3 + (count * 4)))), + pis, rgb, mem); + *(palette + 0 + (count * 3)) = frac2byte(rgb[0]); + *(palette + 1 + (count * 3)) = frac2byte(rgb[1]); + *(palette + 2 + (count * 3)) = frac2byte(rgb[2]); + } + + bits_per_pixel = 24; + } else if (base_color_index + == gs_color_space_index_DeviceRGB || + base_color_index == gs_color_space_index_CIEABC) { + /* for RGB or CalRGB indexed color */ + memcpy(palette, pcs->params.indexed.lookup.table.data,\ + pcs->params.indexed.lookup.table.size); + bits_per_pixel = 24; + } else if (base_color_index + == gs_color_space_index_DeviceGray || + base_color_index == gs_color_space_index_CIEA) { + /* for Gray or CalGray indexed color */ + memcpy(palette, pcs->params.indexed.lookup.table.data,\ + pcs->params.indexed.lookup.table.size); + bits_per_pixel = 8; + } else { + /* except CMYK and RGB */ + return gx_default_begin_image( + dev, pis, pim, format, + prect, pdcolor, pcpath, + mem, pinfo); + } + } + } #if ENABLE_AUTO_REVERSE - if (bits_per_pixel % 8 == 0) { - can_reverse = true; - } + if (bits_per_pixel % 8 == 0) { + can_reverse = true; + } #endif - /* adjust matrix */ - reverse_image = false; - gs_matrix_invert(&pim->ImageMatrix, &mtx); - gs_matrix_multiply(&mtx, &ctm_only(pis), &mtx); - switch (FastImageMode) { - case FastImageNoCTM: - if ((mtx.xy==0)&&(mtx.yx==0)&& (mtx.yy>=0)) { - if (mtx.xx>=0) { - mag[0] = mtx.xx; - mag[1] = mtx.yy; - mtx.xx = 1; - mtx.yy = 1; - supported_angle = true; - } else if (can_reverse) { - mtx.xx *= -1; - mag[0] = mtx.xx; - mag[1] = mtx.yy; - mtx.xx = 1; - mtx.yy = 1; - mtx.tx -= vinfo->width - * mag[0]; - supported_angle = true; - reverse_image = true; - } - } - break; - case FastImageNoRotate: - if ((mtx.xy==0)&&(mtx.yx==0)&& (mtx.yy>=0)) { - if (mtx.xx>=0) { - supported_angle = true; - } else if (can_reverse) { - mtx.xx *= -1; - mtx.tx -= vinfo->width - * mtx.xx; - supported_angle = true; - reverse_image = true; - } - } - break; - case FastImageRightAngle: - if ((mtx.xy==0)&&(mtx.yx==0)) { - if (((mtx.xx>=0)&&(mtx.yy>=0))|| - ((mtx.xx<=0)&&(mtx.yy<=0))){ - supported_angle = true; - } else if (can_reverse) { - mtx.xx *= -1; - mtx.tx -= vinfo->width - * mtx.xx; - supported_angle = true; - reverse_image = true; - } - } else if ((mtx.xx==0)&&(mtx.yy==0)) { - if (((mtx.xy>=0)&&(mtx.yx<=0))|| - ((mtx.xy<=0)&&(mtx.yx>=0))){ - supported_angle = true; - } else if (can_reverse) { - mtx.xy *= -1; - mtx.ty -= vinfo->height - * mtx.xy; - supported_angle = true; - reverse_image = true; - } - } - break; - case FastImageReverseAngle: - if (((mtx.xy==0)&&(mtx.yx==0))|| - ((mtx.xx==0)&&(mtx.yy==0))) { - supported_angle = true; - } - break; - case FastImageAll: - supported_angle = true; - break; - case FastImageDisable: - default: - break; - } - } - - if ((!ecode) && supported_angle) { - if ((!prect) && - ((vinfo->num_planes == 1) || - ((vinfo->num_planes == 3) && - (vinfo->plane_depths[0] == 8) && - (vinfo->plane_depths[1] == 8) && - (vinfo->plane_depths[2] == 8)) - ) - ) { - /* - * avail only - * 1 plane image - * or - * 3 planes 24 bits color image - * (8 bits per plane) - */ - if (apiEntry->opvpStartDrawImage) { - draw_image = true; - } - } - } + /* adjust matrix */ + reverse_image = false; + gs_matrix_invert(&pim->ImageMatrix, &mtx); + gs_matrix_multiply(&mtx, &ctm_only(pis), &mtx); + switch (FastImageMode) { + case FastImageNoCTM: + if ((mtx.xy==0)&&(mtx.yx==0)&& (mtx.yy>=0)) { + if (mtx.xx>=0) { + mag[0] = mtx.xx; + mag[1] = mtx.yy; + mtx.xx = 1; + mtx.yy = 1; + supported_angle = true; + } else if (can_reverse) { + mtx.xx *= -1; + mag[0] = mtx.xx; + mag[1] = mtx.yy; + mtx.xx = 1; + mtx.yy = 1; + mtx.tx -= vinfo->width + * mag[0]; + supported_angle = true; + reverse_image = true; + } + } + break; + case FastImageNoRotate: + if ((mtx.xy==0)&&(mtx.yx==0)&& (mtx.yy>=0)) { + if (mtx.xx>=0) { + supported_angle = true; + } else if (can_reverse) { + mtx.xx *= -1; + mtx.tx -= vinfo->width + * mtx.xx; + supported_angle = true; + reverse_image = true; + } + } + break; + case FastImageRightAngle: + if ((mtx.xy==0)&&(mtx.yx==0)) { + if (((mtx.xx>=0)&&(mtx.yy>=0))|| + ((mtx.xx<=0)&&(mtx.yy<=0))){ + supported_angle = true; + } else if (can_reverse) { + mtx.xx *= -1; + mtx.tx -= vinfo->width + * mtx.xx; + supported_angle = true; + reverse_image = true; + } + } else if ((mtx.xx==0)&&(mtx.yy==0)) { + if (((mtx.xy>=0)&&(mtx.yx<=0))|| + ((mtx.xy<=0)&&(mtx.yx>=0))){ + supported_angle = true; + } else if (can_reverse) { + mtx.xy *= -1; + mtx.ty -= vinfo->height + * mtx.xy; + supported_angle = true; + reverse_image = true; + } + } + break; + case FastImageReverseAngle: + if (((mtx.xy==0)&&(mtx.yx==0))|| + ((mtx.xx==0)&&(mtx.yy==0))) { + supported_angle = true; + } + break; + case FastImageAll: + supported_angle = true; + break; + case FastImageDisable: + default: + break; + } + } + + if ((!ecode) && supported_angle) { + if ((!prect) && + ((vinfo->num_planes == 1) || + ((vinfo->num_planes == 3) && + (vinfo->plane_depths[0] == 8) && + (vinfo->plane_depths[1] == 8) && + (vinfo->plane_depths[2] == 8)) + ) + ) { + /* + * avail only + * 1 plane image + * or + * 3 planes 24 bits color image + * (8 bits per plane) + */ + if (apiEntry->opvpStartDrawImage) { + draw_image = true; + } + } + } } if (draw_image) { - *pinfo = (gx_image_enum_common_t *)vinfo; - - if (!ecode) { - if (!pim->ImageMask) { - /* call SetPaintMode */ - if (apiEntry->opvpSetPaintMode) { - apiEntry->opvpSetPaintMode(printerContext, - OPVP_PAINTMODE_OPAQUE); - change_paint_mode = true; - } - /* set color space */ - if (apiEntry->opvpSetColorSpace != NULL) { - opvp_cspace_t ncspace; - - savedColorSpace = colorSpace; - switch (bits_per_pixel) { - case 1: - ncspace = OPVP_CSPACE_DEVICEGRAY; - bits_per_pixel = 8; - if (!cspace_available[ncspace]) { - ncspace = OPVP_CSPACE_STANDARDRGB; - bits_per_pixel = 24; - } - break; - case 8: - ncspace = OPVP_CSPACE_DEVICEGRAY; - if (!cspace_available[ncspace]) { - ncspace = OPVP_CSPACE_STANDARDRGB; - bits_per_pixel = 24; - } - break; - case 24: - ncspace = OPVP_CSPACE_DEVICERGB; - if (!cspace_available[ncspace]) { - ncspace = OPVP_CSPACE_STANDARDRGB; - } - break; - default: - r = -1; - goto fallthrough; - break; - } - if (ncspace != colorSpace) { - if (apiEntry->opvpSetColorSpace(printerContext,ncspace) - != OPVP_OK) { - r = -1; - goto fallthrough; - } - colorSpace = ncspace; - change_cspace = true; - } - } - } - } - if (!ecode) { - if (supported_angle) { - /* moveto */ - opvp_moveto(vdev, 0, 0, mtx.tx, mtx.ty, 0); - } - if ((supported_angle) && (FastImageMode != FastImageNoCTM)) { - /* call SetCTM */ - ctm.a = mtx.xx; - ctm.b = mtx.xy; - ctm.c = mtx.yx; - ctm.d = mtx.yy; - ctm.e = mtx.tx; - ctm.f = mtx.ty; - if (apiEntry->opvpSetCTM) { - r = apiEntry->opvpSetCTM(printerContext, &ctm); - } - else r = -1; - if (r != OPVP_OK) ecode = r; - } - } - if (!ecode) { - int dw,dh; - - /* image size */ - if (mag[0] != 1) { - dw = floor(vinfo->width * mag[0]+0.5); - } else { - dw = vinfo->width; - } - if (mag[1] != 1) { - dh = floor(vinfo->height * mag[1]+0.5); - } else { - dh = vinfo->height; - } - /* call StartDrawImage */ - if (apiEntry->opvpStartDrawImage) { - opvp_int_t adj_raster; - - adj_raster = bits_per_pixel*vinfo->width; - adj_raster = ((adj_raster+31) >> 5) << 2; - r = apiEntry->opvpStartDrawImage( - printerContext, - vinfo->width, - vinfo->height, - adj_raster, - pim->ImageMask ? - OPVP_IFORMAT_MASK: - OPVP_IFORMAT_RAW, - dw,dh); - if(r != OPVP_OK) { - if (apiEntry->opvpEndDrawImage) { - apiEntry->opvpEndDrawImage(printerContext); - } - } - } - - /* bugfix for 32bit CMYK image print error */ + *pinfo = (gx_image_enum_common_t *)vinfo; + + if (!ecode) { + if (!pim->ImageMask) { + /* call SetPaintMode */ + if (apiEntry->opvpSetPaintMode) { + apiEntry->opvpSetPaintMode(printerContext, + OPVP_PAINTMODE_OPAQUE); + change_paint_mode = true; + } + /* set color space */ + if (apiEntry->opvpSetColorSpace != NULL) { + opvp_cspace_t ncspace; + + savedColorSpace = colorSpace; + switch (bits_per_pixel) { + case 1: + ncspace = OPVP_CSPACE_DEVICEGRAY; + bits_per_pixel = 8; + if (!cspace_available[ncspace]) { + ncspace = OPVP_CSPACE_STANDARDRGB; + bits_per_pixel = 24; + } + break; + case 8: + ncspace = OPVP_CSPACE_DEVICEGRAY; + if (!cspace_available[ncspace]) { + ncspace = OPVP_CSPACE_STANDARDRGB; + bits_per_pixel = 24; + } + break; + case 24: + ncspace = OPVP_CSPACE_DEVICERGB; + if (!cspace_available[ncspace]) { + ncspace = OPVP_CSPACE_STANDARDRGB; + } + break; + default: + r = -1; + goto fallthrough; + break; + } + if (ncspace != colorSpace) { + if (apiEntry->opvpSetColorSpace(printerContext,ncspace) + != OPVP_OK) { + r = -1; + goto fallthrough; + } + colorSpace = ncspace; + change_cspace = true; + } + } + } + } + if (!ecode) { + if (supported_angle) { + /* moveto */ + opvp_moveto(vdev, 0, 0, mtx.tx, mtx.ty, 0); + } + if ((supported_angle) && (FastImageMode != FastImageNoCTM)) { + /* call SetCTM */ + ctm.a = mtx.xx; + ctm.b = mtx.xy; + ctm.c = mtx.yx; + ctm.d = mtx.yy; + ctm.e = mtx.tx; + ctm.f = mtx.ty; + if (apiEntry->opvpSetCTM) { + r = apiEntry->opvpSetCTM(printerContext, &ctm); + } + else r = -1; + if (r != OPVP_OK) ecode = r; + } + } + if (!ecode) { + int dw,dh; + + /* image size */ + if (mag[0] != 1) { + dw = floor(vinfo->width * mag[0]+0.5); + } else { + dw = vinfo->width; + } + if (mag[1] != 1) { + dh = floor(vinfo->height * mag[1]+0.5); + } else { + dh = vinfo->height; + } + /* call StartDrawImage */ + if (apiEntry->opvpStartDrawImage) { + opvp_int_t adj_raster; + + adj_raster = bits_per_pixel*vinfo->width; + adj_raster = ((adj_raster+31) >> 5) << 2; + r = apiEntry->opvpStartDrawImage( + printerContext, + vinfo->width, + vinfo->height, + adj_raster, + pim->ImageMask ? + OPVP_IFORMAT_MASK: + OPVP_IFORMAT_RAW, + dw,dh); + if(r != OPVP_OK) { + if (apiEntry->opvpEndDrawImage) { + apiEntry->opvpEndDrawImage(printerContext); + } + } + } + + /* bugfix for 32bit CMYK image print error */ fallthrough: - if(r != OPVP_OK) { - if (change_paint_mode) { - /* restore paint mode */ - if (apiEntry->opvpSetPaintMode) { - apiEntry->opvpSetPaintMode(printerContext, - OPVP_PAINTMODE_TRANSPARENT); - } - change_paint_mode = false; - } - if (change_cspace) { - /* restore color space */ - colorSpace = savedColorSpace; - if (apiEntry->opvpSetColorSpace) { - apiEntry->opvpSetColorSpace(printerContext, - colorSpace); - } - change_cspace = false; - } - if(apiEntry->opvpResetCTM) { - apiEntry->opvpResetCTM(printerContext); /* reset CTM */ - } - return gx_default_begin_image(dev, pis, pim, format, - prect, pdcolor, pcpath, mem, pinfo); - } - } - - if (!ecode) { - begin_image = true; - } - - return ecode; + if(r != OPVP_OK) { + if (change_paint_mode) { + /* restore paint mode */ + if (apiEntry->opvpSetPaintMode) { + apiEntry->opvpSetPaintMode(printerContext, + OPVP_PAINTMODE_TRANSPARENT); + } + change_paint_mode = false; + } + if (change_cspace) { + /* restore color space */ + colorSpace = savedColorSpace; + if (apiEntry->opvpSetColorSpace) { + apiEntry->opvpSetColorSpace(printerContext, + colorSpace); + } + change_cspace = false; + } + if(apiEntry->opvpResetCTM) { + apiEntry->opvpResetCTM(printerContext); /* reset CTM */ + } + return gx_default_begin_image(dev, pis, pim, format, + prect, pdcolor, pcpath, mem, pinfo); + } + } + + if (!ecode) { + begin_image = true; + } + + return ecode; } return gx_default_begin_image(dev, pis, pim, format, prect, - pdcolor, pcpath, mem, pinfo); + pdcolor, pcpath, mem, pinfo); } /* * plane data */ -static int +static int opvp_image_plane_data( gx_image_enum_common_t *info, const gx_image_plane_t *planes, @@ -3930,7 +3930,7 @@ opvp_image_plane_data( if (!begin_image) return 0; for (bits_per_pixel=0, p=0; p < vinfo->num_planes; p++) { - bits_per_pixel += vinfo->plane_depths[p]; + bits_per_pixel += vinfo->plane_depths[p]; } data_bytes = (bits_per_pixel * vinfo->width + 7) >> 3; @@ -3938,380 +3938,380 @@ opvp_image_plane_data( buf = calloc(raster_length, height); if (vinfo->default_info) { - gx_image_plane_data(vinfo->default_info, planes, height); + gx_image_plane_data(vinfo->default_info, planes, height); } if (vinfo->bbox_info) { - gx_image_plane_data(vinfo->bbox_info, planes, height); + gx_image_plane_data(vinfo->bbox_info, planes, height); } if (buf) { - /* Adjust image data gamma */ - pbe = (bbox_image_enum *)vinfo->bbox_info; - tinfo = (gx_image_enum *)pbe->target_info; - pis = tinfo->pis; - - if (vinfo->num_planes == 1) { - for (h = 0; h < height; h++) { - d = raster_length * h; - if (reverse_image) { - int bytes_per_pixel = bits_per_pixel / 8; - for (x = data_bytes * (h + 1) - bytes_per_pixel; - x >= data_bytes * h; - x-=bytes_per_pixel, - d+=bytes_per_pixel) { - memcpy(buf+d, planes[0].data+x, bytes_per_pixel); - } - } else { - memcpy(buf + d, - planes[0].data - + (data_bytes * h), - data_bytes); - } - } - } else { - for (h = 0; h < height; h++) { - d = raster_length * h; - if (reverse_image) { - for (x = vinfo->width * (h + 1) - 1; - x >= vinfo->width * h; - x--) { - for (p = 0; - p < vinfo->num_planes; - p++, d++) { - buf[d] = (byte)(planes[p].data[x]); - } - } - } else { - for (x = vinfo->width * h; - x < vinfo->width * (h + 1); - x++) { - for (p = 0; - p < vinfo->num_planes; - p++, d++) { - buf[d] = (byte) - (planes[p].data[x]); - } - } - } - } - } - - if (tinfo->masked) { - bool reverse = false; - - /* image mask */ - if (imageDecode[0] == 0) { - reverse = true; - } - if (reverse) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - for (j = 0; j < data_bytes; j++) { - src_ptr[j] ^= 0xff; - } - } - } - } else { - if(color_index == gs_color_space_index_Indexed) { - if (base_color_index == gs_color_space_index_DeviceGray || - base_color_index == gs_color_space_index_CIEA) { - if (colorSpace == OPVP_CSPACE_DEVICEGRAY) { - /* Convert indexed gray color -> Gray */ - if (bits_per_pixel == 8) { /* 8bit image */ - dst_bytes = data_bytes; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < data_bytes; j++) { - ppalette = palette + src_ptr[j] ; - dst_ptr[j] = ppalette[0]; - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 8; - } - } else { /* 1bit image */ - dst_bytes = vinfo->width; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < vinfo->width; j++) { - int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) - != 0); - ppalette = palette + o; - dst_ptr[j] = ppalette[0]; - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 8; - } - } - } else { - /* Convert indexed Gray color -> RGB */ - if (bits_per_pixel == 8) { /* 8bit image */ - dst_bytes = data_bytes * 3; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < data_bytes; j++) { - ppalette = palette + src_ptr[j] * 3; - dst_ptr[j*3] = ppalette[0]; /* R */ - dst_ptr[j*3 + 1] = ppalette[0]; /* G */ - dst_ptr[j*3 + 2] = ppalette[0]; /* B */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 24; - } - } else { /* 1bit image */ - dst_bytes = vinfo->width * 3; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < vinfo->width; j++) { - int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) - != 0); - ppalette = palette + o * 3; - dst_ptr[j*3] = ppalette[0]; /* R */ - dst_ptr[j*3 + 1] = ppalette[0]; /* G */ - dst_ptr[j*3 + 2] = ppalette[0]; /* B */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 24; - } - } - } - } else { - /* Convert indexed color -> RGB */ - if (bits_per_pixel == 8) { /* 8bit image */ - dst_bytes = data_bytes * 3; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < data_bytes; j++) { - ppalette = palette + src_ptr[j] * 3; - dst_ptr[j*3] = ppalette[0]; /* R */ - dst_ptr[j*3 + 1] = ppalette[1]; /* G */ - dst_ptr[j*3 + 2] = ppalette[2]; /* B */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 24; - } - } else { /* 1bit image */ - dst_bytes = vinfo->width * 3; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < vinfo->width; j++) { - int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) - != 0); - ppalette = palette + o * 3; - dst_ptr[j*3] = ppalette[0]; /* R */ - dst_ptr[j*3 + 1] = ppalette[1]; /* G */ - dst_ptr[j*3 + 2] = ppalette[2]; /* B */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 24; - } - } - } - } - - /* Convert Gray */ - if(color_index == gs_color_space_index_DeviceGray || - color_index == gs_color_space_index_CIEA) { - if (colorSpace == OPVP_CSPACE_STANDARDRGB - || colorSpace == OPVP_CSPACE_DEVICERGB) { - /* convert to RGB */ - if (bits_per_pixel == 8) { /* 8bit image */ - dst_bytes = data_bytes * 3; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < data_bytes; j++) { - unsigned char d = floor( - imageDecode[0]*255 + src_ptr[j]* - (imageDecode[1]-imageDecode[0])+0.5); - - dst_ptr[j*3] = d; /* R */ - dst_ptr[j*3 + 1] = d; /* G */ - dst_ptr[j*3 + 2] = d; /* B */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 24; - } - } else { /* 1bit image */ - dst_bytes = vinfo->width * 3; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < vinfo->width; j++) { - int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) - != 0); - unsigned char d = floor( - imageDecode[0]*255 + o* - (imageDecode[1]-imageDecode[0])*255+0.5); - dst_ptr[j*3] = d; /* R */ - dst_ptr[j*3 + 1] = d; /* G */ - dst_ptr[j*3 + 2] =d; /* B */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 24; - } - } - } else if (colorSpace == OPVP_CSPACE_DEVICEGRAY) { - if (bits_per_pixel == 1) { /* 1bit image */ - dst_bytes = vinfo->width; - dst_length = ((dst_bytes + 3) >> 2) << 2; - - tmp_buf = calloc(dst_length, height); - if (tmp_buf) { - for (i = 0; i < height; i++) { - src_ptr = buf + raster_length * i; - dst_ptr = tmp_buf + dst_length * i; - for (j = 0; j < vinfo->width; j++) { - int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) - != 0); - unsigned char d = floor( - imageDecode[0]*255 + o* - (imageDecode[1]-imageDecode[0])*255+0.5); - dst_ptr[j] = d; /* R */ - } - } - - free (buf); - buf = tmp_buf; - data_bytes = dst_bytes; - raster_length = dst_length; - vinfo->bits_per_pixel = 8; - } - } - } - } - } + /* Adjust image data gamma */ + pbe = (bbox_image_enum *)vinfo->bbox_info; + tinfo = (gx_image_enum *)pbe->target_info; + pis = tinfo->pis; + + if (vinfo->num_planes == 1) { + for (h = 0; h < height; h++) { + d = raster_length * h; + if (reverse_image) { + int bytes_per_pixel = bits_per_pixel / 8; + for (x = data_bytes * (h + 1) - bytes_per_pixel; + x >= data_bytes * h; + x-=bytes_per_pixel, + d+=bytes_per_pixel) { + memcpy(buf+d, planes[0].data+x, bytes_per_pixel); + } + } else { + memcpy(buf + d, + planes[0].data + + (data_bytes * h), + data_bytes); + } + } + } else { + for (h = 0; h < height; h++) { + d = raster_length * h; + if (reverse_image) { + for (x = vinfo->width * (h + 1) - 1; + x >= vinfo->width * h; + x--) { + for (p = 0; + p < vinfo->num_planes; + p++, d++) { + buf[d] = (byte)(planes[p].data[x]); + } + } + } else { + for (x = vinfo->width * h; + x < vinfo->width * (h + 1); + x++) { + for (p = 0; + p < vinfo->num_planes; + p++, d++) { + buf[d] = (byte) + (planes[p].data[x]); + } + } + } + } + } + + if (tinfo->masked) { + bool reverse = false; + + /* image mask */ + if (imageDecode[0] == 0) { + reverse = true; + } + if (reverse) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + for (j = 0; j < data_bytes; j++) { + src_ptr[j] ^= 0xff; + } + } + } + } else { + if(color_index == gs_color_space_index_Indexed) { + if (base_color_index == gs_color_space_index_DeviceGray || + base_color_index == gs_color_space_index_CIEA) { + if (colorSpace == OPVP_CSPACE_DEVICEGRAY) { + /* Convert indexed gray color -> Gray */ + if (bits_per_pixel == 8) { /* 8bit image */ + dst_bytes = data_bytes; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < data_bytes; j++) { + ppalette = palette + src_ptr[j] ; + dst_ptr[j] = ppalette[0]; + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 8; + } + } else { /* 1bit image */ + dst_bytes = vinfo->width; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < vinfo->width; j++) { + int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) + != 0); + ppalette = palette + o; + dst_ptr[j] = ppalette[0]; + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 8; + } + } + } else { + /* Convert indexed Gray color -> RGB */ + if (bits_per_pixel == 8) { /* 8bit image */ + dst_bytes = data_bytes * 3; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < data_bytes; j++) { + ppalette = palette + src_ptr[j] * 3; + dst_ptr[j*3] = ppalette[0]; /* R */ + dst_ptr[j*3 + 1] = ppalette[0]; /* G */ + dst_ptr[j*3 + 2] = ppalette[0]; /* B */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 24; + } + } else { /* 1bit image */ + dst_bytes = vinfo->width * 3; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < vinfo->width; j++) { + int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) + != 0); + ppalette = palette + o * 3; + dst_ptr[j*3] = ppalette[0]; /* R */ + dst_ptr[j*3 + 1] = ppalette[0]; /* G */ + dst_ptr[j*3 + 2] = ppalette[0]; /* B */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 24; + } + } + } + } else { + /* Convert indexed color -> RGB */ + if (bits_per_pixel == 8) { /* 8bit image */ + dst_bytes = data_bytes * 3; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < data_bytes; j++) { + ppalette = palette + src_ptr[j] * 3; + dst_ptr[j*3] = ppalette[0]; /* R */ + dst_ptr[j*3 + 1] = ppalette[1]; /* G */ + dst_ptr[j*3 + 2] = ppalette[2]; /* B */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 24; + } + } else { /* 1bit image */ + dst_bytes = vinfo->width * 3; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < vinfo->width; j++) { + int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) + != 0); + ppalette = palette + o * 3; + dst_ptr[j*3] = ppalette[0]; /* R */ + dst_ptr[j*3 + 1] = ppalette[1]; /* G */ + dst_ptr[j*3 + 2] = ppalette[2]; /* B */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 24; + } + } + } + } + + /* Convert Gray */ + if(color_index == gs_color_space_index_DeviceGray || + color_index == gs_color_space_index_CIEA) { + if (colorSpace == OPVP_CSPACE_STANDARDRGB + || colorSpace == OPVP_CSPACE_DEVICERGB) { + /* convert to RGB */ + if (bits_per_pixel == 8) { /* 8bit image */ + dst_bytes = data_bytes * 3; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < data_bytes; j++) { + unsigned char d = floor( + imageDecode[0]*255 + src_ptr[j]* + (imageDecode[1]-imageDecode[0])+0.5); + + dst_ptr[j*3] = d; /* R */ + dst_ptr[j*3 + 1] = d; /* G */ + dst_ptr[j*3 + 2] = d; /* B */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 24; + } + } else { /* 1bit image */ + dst_bytes = vinfo->width * 3; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < vinfo->width; j++) { + int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) + != 0); + unsigned char d = floor( + imageDecode[0]*255 + o* + (imageDecode[1]-imageDecode[0])*255+0.5); + dst_ptr[j*3] = d; /* R */ + dst_ptr[j*3 + 1] = d; /* G */ + dst_ptr[j*3 + 2] =d; /* B */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 24; + } + } + } else if (colorSpace == OPVP_CSPACE_DEVICEGRAY) { + if (bits_per_pixel == 1) { /* 1bit image */ + dst_bytes = vinfo->width; + dst_length = ((dst_bytes + 3) >> 2) << 2; + + tmp_buf = calloc(dst_length, height); + if (tmp_buf) { + for (i = 0; i < height; i++) { + src_ptr = buf + raster_length * i; + dst_ptr = tmp_buf + dst_length * i; + for (j = 0; j < vinfo->width; j++) { + int o = ((src_ptr[j/8] & (1 << (7 - (j & 7)))) + != 0); + unsigned char d = floor( + imageDecode[0]*255 + o* + (imageDecode[1]-imageDecode[0])*255+0.5); + dst_ptr[j] = d; /* R */ + } + } + + free (buf); + buf = tmp_buf; + data_bytes = dst_bytes; + raster_length = dst_length; + vinfo->bits_per_pixel = 8; + } + } + } + } + } #if GS_VERSION_MAJOR >= 8 - if (vinfo->bits_per_pixel == 24) { /* 24bit RGB color */ - for (i = 0; i < height; i++) { - ptr = buf + raster_length * i; - for (j = 0; j < vinfo->width; j++) { - ptr[j*3] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j*3]), effective_transfer[0]))); - ptr[j*3+1] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j*3+1]), effective_transfer[1]))); - ptr[j*3+2] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j*3+2]), effective_transfer[2]))); - } - } - } else if (vinfo->bits_per_pixel == 8) { /* 8bit Gray image */ - for (i = 0; i < height; i++) { - ptr = buf + raster_length * i; - for (j=0; j < vinfo->width; j++) { - ptr[j] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j]), effective_transfer[3]))); - } - } - } + if (vinfo->bits_per_pixel == 24) { /* 24bit RGB color */ + for (i = 0; i < height; i++) { + ptr = buf + raster_length * i; + for (j = 0; j < vinfo->width; j++) { + ptr[j*3] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j*3]), effective_transfer[0]))); + ptr[j*3+1] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j*3+1]), effective_transfer[1]))); + ptr[j*3+2] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j*3+2]), effective_transfer[2]))); + } + } + } else if (vinfo->bits_per_pixel == 8) { /* 8bit Gray image */ + for (i = 0; i < height; i++) { + ptr = buf + raster_length * i; + for (j=0; j < vinfo->width; j++) { + ptr[j] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j]), effective_transfer[3]))); + } + } + } #else - if (vinfo->bits_per_pixel == 24) { /* 24bit RGB color */ - for (i = 0; i < height; i++) { - ptr = buf + raster_length * i; - for (j = 0; j < vinfo->width; j++) { - ptr[j*3] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j*3]), effective_transfer.colored.red))); - ptr[j*3+1] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j*3+1]), effective_transfer.colored.green))); - ptr[j*3+2] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j*3+2]), effective_transfer.colored.blue))); - } - } - } else if (vinfo->bits_per_pixel == 8) { /* 8bit Gray image */ - for (i = 0; i < height; i++) { - ptr = buf + raster_length * i; - for (j = 0; j < vinfo->width; j++) { - ptr[j] = min(255, frac2cv(gx_map_color_frac(pis, - cv2frac(ptr[j]), effective_transfer.colored.gray))); - } - } - } + if (vinfo->bits_per_pixel == 24) { /* 24bit RGB color */ + for (i = 0; i < height; i++) { + ptr = buf + raster_length * i; + for (j = 0; j < vinfo->width; j++) { + ptr[j*3] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j*3]), effective_transfer.colored.red))); + ptr[j*3+1] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j*3+1]), effective_transfer.colored.green))); + ptr[j*3+2] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j*3+2]), effective_transfer.colored.blue))); + } + } + } else if (vinfo->bits_per_pixel == 8) { /* 8bit Gray image */ + for (i = 0; i < height; i++) { + ptr = buf + raster_length * i; + for (j = 0; j < vinfo->width; j++) { + ptr[j] = min(255, frac2cv(gx_map_color_frac(pis, + cv2frac(ptr[j]), effective_transfer.colored.gray))); + } + } + } #endif - /* call TansferDrawImage */ - if (apiEntry->opvpTransferDrawImage) { - apiEntry->opvpTransferDrawImage(printerContext, - raster_length * height, (void *)buf); - } - if (buf) { - free(buf); /* free buffer */ - } + /* call TansferDrawImage */ + if (apiEntry->opvpTransferDrawImage) { + apiEntry->opvpTransferDrawImage(printerContext, + raster_length * height, (void *)buf); + } + if (buf) { + free(buf); /* free buffer */ + } } vinfo->y += height; @@ -4323,8 +4323,8 @@ opvp_image_plane_data( /* * end image */ -static int -opvp_image_end_image(gx_image_enum_common_t *info, bool draw_last) +static int +opvp_image_end_image(gx_image_enum_common_t *info, bool draw_last) { gx_device *dev = info->dev; gx_device_vector *vdev = (gx_device_vector *)dev; @@ -4334,47 +4334,47 @@ opvp_image_end_image(gx_image_enum_common_t *info, bool draw_last) vinfo = (gdev_vector_image_enum_t *)info; if (begin_image) { - /* call EndDrawImage */ - if (apiEntry->opvpEndDrawImage) { - apiEntry->opvpEndDrawImage(printerContext); - } - - begin_image = false; - - if (FastImageMode != FastImageNoCTM) { - /* call ResetCTM */ - if (apiEntry->opvpResetCTM) { - apiEntry->opvpResetCTM(printerContext); - } else { - /* call SetCTM */ - ctm.a = 1; - ctm.b = 0; - ctm.c = 0; - ctm.d = 1; - ctm.e = 0; - ctm.f = 0; - if (apiEntry->opvpSetCTM) { - apiEntry->opvpSetCTM(printerContext, &ctm); - } - } - } - if (change_paint_mode) { - /* restore paint mode */ - if (apiEntry->opvpSetPaintMode) { - apiEntry->opvpSetPaintMode(printerContext, - OPVP_PAINTMODE_TRANSPARENT); - } - change_paint_mode = false; - } - if (change_cspace) { - /* restore color space */ - colorSpace = savedColorSpace; - if (apiEntry->opvpSetColorSpace) { - apiEntry->opvpSetColorSpace(printerContext, - colorSpace); - } - change_cspace = false; - } + /* call EndDrawImage */ + if (apiEntry->opvpEndDrawImage) { + apiEntry->opvpEndDrawImage(printerContext); + } + + begin_image = false; + + if (FastImageMode != FastImageNoCTM) { + /* call ResetCTM */ + if (apiEntry->opvpResetCTM) { + apiEntry->opvpResetCTM(printerContext); + } else { + /* call SetCTM */ + ctm.a = 1; + ctm.b = 0; + ctm.c = 0; + ctm.d = 1; + ctm.e = 0; + ctm.f = 0; + if (apiEntry->opvpSetCTM) { + apiEntry->opvpSetCTM(printerContext, &ctm); + } + } + } + if (change_paint_mode) { + /* restore paint mode */ + if (apiEntry->opvpSetPaintMode) { + apiEntry->opvpSetPaintMode(printerContext, + OPVP_PAINTMODE_TRANSPARENT); + } + change_paint_mode = false; + } + if (change_cspace) { + /* restore color space */ + colorSpace = savedColorSpace; + if (apiEntry->opvpSetColorSpace) { + apiEntry->opvpSetColorSpace(printerContext, + colorSpace); + } + change_cspace = false; + } } return gdev_vector_end_image(vdev, vinfo, draw_last, vdev->white); @@ -4384,7 +4384,7 @@ opvp_image_end_image(gx_image_enum_common_t *info, bool draw_last) /* * begin page */ -static int +static int opvp_beginpage(gx_device_vector *vdev) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4397,10 +4397,10 @@ opvp_beginpage(gx_device_vector *vdev) /* start page */ code = opvp_startpage((gx_device *)pdev); if (code) { - ecode = code; + ecode = code; } else { - pdev->in_page = true; /* added '05.12.07 */ - beginPage = true; + pdev->in_page = true; /* added '05.12.07 */ + beginPage = true; } return ecode; @@ -4409,7 +4409,7 @@ opvp_beginpage(gx_device_vector *vdev) /* * set line width */ -static int +static int opvp_setlinewidth(gx_device_vector *vdev, floatp width) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4423,10 +4423,10 @@ opvp_setlinewidth(gx_device_vector *vdev, floatp width) /* call SetLineWidth */ OPVP_F2FIX(width, w); if (apiEntry->opvpSetLineWidth) { - r = apiEntry->opvpSetLineWidth(printerContext, w); + r = apiEntry->opvpSetLineWidth(printerContext, w); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -4435,7 +4435,7 @@ opvp_setlinewidth(gx_device_vector *vdev, floatp width) /* * set line cap */ -static int +static int opvp_setlinecap(gx_device_vector *vdev, gs_line_cap cap) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4448,26 +4448,26 @@ opvp_setlinecap(gx_device_vector *vdev, gs_line_cap cap) switch (cap) { case gs_cap_butt: - linecap = OPVP_LINECAP_BUTT; - break; + linecap = OPVP_LINECAP_BUTT; + break; case gs_cap_round: - linecap = OPVP_LINECAP_ROUND; - break; + linecap = OPVP_LINECAP_ROUND; + break; case gs_cap_square: - linecap = OPVP_LINECAP_SQUARE; - break; + linecap = OPVP_LINECAP_SQUARE; + break; case gs_cap_triangle: default: - linecap = OPVP_LINECAP_BUTT; - break; + linecap = OPVP_LINECAP_BUTT; + break; } /* call SetLineCap */ if (apiEntry->opvpSetLineCap) { - r = apiEntry->opvpSetLineCap(printerContext, linecap); + r = apiEntry->opvpSetLineCap(printerContext, linecap); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -4476,7 +4476,7 @@ opvp_setlinecap(gx_device_vector *vdev, gs_line_cap cap) /* * set line join */ -static int +static int opvp_setlinejoin(gx_device_vector *vdev, gs_line_join join) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4489,27 +4489,27 @@ opvp_setlinejoin(gx_device_vector *vdev, gs_line_join join) switch (join) { case gs_join_miter: - linejoin = OPVP_LINEJOIN_MITER; - break; + linejoin = OPVP_LINEJOIN_MITER; + break; case gs_join_round: - linejoin = OPVP_LINEJOIN_ROUND; - break; + linejoin = OPVP_LINEJOIN_ROUND; + break; case gs_join_bevel: - linejoin = OPVP_LINEJOIN_BEVEL; - break; + linejoin = OPVP_LINEJOIN_BEVEL; + break; case gs_join_none: case gs_join_triangle: default: - linejoin = OPVP_LINEJOIN_MITER; - break; + linejoin = OPVP_LINEJOIN_MITER; + break; } /* call SetLineJoin */ if (apiEntry->opvpSetLineJoin) { - r = apiEntry->opvpSetLineJoin(printerContext, linejoin); + r = apiEntry->opvpSetLineJoin(printerContext, linejoin); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -4518,7 +4518,7 @@ opvp_setlinejoin(gx_device_vector *vdev, gs_line_join join) /* * set miter limit */ -static int +static int opvp_setmiterlimit(gx_device_vector *vdev, floatp limit) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4532,10 +4532,10 @@ opvp_setmiterlimit(gx_device_vector *vdev, floatp limit) /* call SetMiterLimit */ OPVP_F2FIX(limit, l); if (apiEntry->opvpSetMiterLimit) { - r = apiEntry->opvpSetMiterLimit(printerContext, l); + r = apiEntry->opvpSetMiterLimit(printerContext, l); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -4544,7 +4544,7 @@ opvp_setmiterlimit(gx_device_vector *vdev, floatp limit) /* * set dash */ -static int +static int opvp_setdash( gx_device_vector *vdev, const float *pattern, @@ -4563,48 +4563,48 @@ opvp_setdash( /* pattern */ if (count) { - p = calloc(sizeof(opvp_fix_t), count); - if (p) { - for (i = 0; i < count; i++) { - OPVP_F2FIX(pattern[i], p[i]); - } - } else { - ecode = -1; - } + p = calloc(sizeof(opvp_fix_t), count); + if (p) { + for (i = 0; i < count; i++) { + OPVP_F2FIX(pattern[i], p[i]); + } + } else { + ecode = -1; + } } /* call SetLineDash */ if (!ecode) { - if (apiEntry->opvpSetLineDash) { - r = apiEntry->opvpSetLineDash(printerContext, count,p); - } - if (r != OPVP_OK) { - ecode = -1; - } + if (apiEntry->opvpSetLineDash) { + r = apiEntry->opvpSetLineDash(printerContext, count,p); + } + if (r != OPVP_OK) { + ecode = -1; + } } /* call SetLineDashOffset */ if (!ecode) { - OPVP_F2FIX(offset, o); - if (apiEntry->opvpSetLineDashOffset) { - r = apiEntry->opvpSetLineDashOffset(printerContext, o); - } - if (r != OPVP_OK) { - ecode = -1; - } + OPVP_F2FIX(offset, o); + if (apiEntry->opvpSetLineDashOffset) { + r = apiEntry->opvpSetLineDashOffset(printerContext, o); + } + if (r != OPVP_OK) { + ecode = -1; + } } /* call SetLineStyle */ if (!ecode) { - if (apiEntry->opvpSetLineStyle) { - r = apiEntry->opvpSetLineStyle(printerContext, - (count ? - OPVP_LINESTYLE_DASH : - OPVP_LINESTYLE_SOLID)); - } - if (r != OPVP_OK) { - ecode = -1; - } + if (apiEntry->opvpSetLineStyle) { + r = apiEntry->opvpSetLineStyle(printerContext, + (count ? + OPVP_LINESTYLE_DASH : + OPVP_LINESTYLE_SOLID)); + } + if (r != OPVP_OK) { + ecode = -1; + } } if (p) free(p); @@ -4615,7 +4615,7 @@ opvp_setdash( /* * set flat */ -static int +static int opvp_setflat(gx_device_vector *vdev, floatp flatness) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4632,7 +4632,7 @@ opvp_setflat(gx_device_vector *vdev, floatp flatness) /* * set logical operation */ -static int +static int opvp_setlogop( gx_device_vector *vdev, gs_logical_operation_t lop, @@ -4646,7 +4646,7 @@ opvp_setlogop( /*--- added for Ghostscritp 8.15 ---*/ static int opvp_can_handle_hl_color(gx_device_vector * vdev, - const gs_imager_state * pis1, const gx_drawing_color * pdc) + const gs_imager_state * pis1, const gx_drawing_color * pdc) { return false; /* High level color is not implemented yet. */ } @@ -4656,14 +4656,14 @@ opvp_can_handle_hl_color(gx_device_vector * vdev, * set fill color */ #if GS_VERSION_MAJOR >= 8 -static int +static int opvp_setfillcolor( gx_device_vector *vdev, const gs_imager_state *pis, /* added for gs 8.15 */ const gx_drawing_color *pdc) #else -static int -opvp_setfillcolor(gx_device_vector *vdev, const gx_drawing_color *pdc) +static int +opvp_setfillcolor(gx_device_vector *vdev, const gx_drawing_color *pdc) #endif { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -4684,10 +4684,10 @@ opvp_setfillcolor(gx_device_vector *vdev, const gx_drawing_color *pdc) /* call SetFillColor */ if (apiEntry->opvpSetFillColor) { - r = apiEntry->opvpSetFillColor(printerContext, vectorFillColor); + r = apiEntry->opvpSetFillColor(printerContext, vectorFillColor); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -4697,13 +4697,13 @@ opvp_setfillcolor(gx_device_vector *vdev, const gx_drawing_color *pdc) * set stroke color */ #if GS_VERSION_MAJOR >= 8 -static int +static int opvp_setstrokecolor( gx_device_vector *vdev, const gs_imager_state *pis, /* added for gs 8.15 */ const gx_drawing_color *pdc) #else -static int +static int opvp_setstrokecolor(gx_device_vector *vdev, const gx_drawing_color *pdc) #endif { @@ -4724,21 +4724,21 @@ opvp_setstrokecolor(gx_device_vector *vdev, const gx_drawing_color *pdc) /* call SetStrokeColor */ if (apiEntry->opvpSetStrokeColor) { - r = apiEntry->opvpSetStrokeColor(printerContext, &brush); + r = apiEntry->opvpSetStrokeColor(printerContext, &brush); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; } -#define OPVP_OPT_MULTI_PATH +#define OPVP_OPT_MULTI_PATH /* * vector do path */ -static int +static int opvp_vector_dopath( gx_device_vector *vdev, const gx_path *ppath, @@ -4753,7 +4753,7 @@ opvp_vector_dopath( gs_path_enum path; gs_point scale; int op; -#ifdef OPVP_OPT_MULTI_PATH +#ifdef OPVP_OPT_MULTI_PATH int i; int pop = 0; int npoints = 0; @@ -4770,7 +4770,7 @@ opvp_vector_dopath( bool begin = true; start.x = start.y = 0; -#ifdef OPVP_OPT_MULTI_PATH +#ifdef OPVP_OPT_MULTI_PATH current.x = current.y = 0; #endif /* check page-in */ @@ -4778,9 +4778,9 @@ opvp_vector_dopath( if (gx_path_is_rectangle(ppath, &rect)) return (*vdev_proc(vdev, dorect))(vdev, - rect.p.x, rect.p.y, - rect.q.x, rect.q.y, - type); + rect.p.x, rect.p.y, + rect.q.x, rect.q.y, + type); /* begin path */ code = (*vdev_proc(vdev, beginpath))(vdev, type); @@ -4789,200 +4789,200 @@ opvp_vector_dopath( gx_path_enum_init(&path, ppath); while (!ecode) { - op = gx_path_enum_next(&path, (gs_fixed_point *)vs); - if (begin) { - /* start point */ - start.x = fixed2float(vs[0]) / scale.x; - start.y = fixed2float(vs[1]) / scale.y; - begin = false; - -#ifdef OPVP_OPT_MULTI_PATH - npoints = 1; - points = realloc(points, sizeof(_fPoint)); - current = start; + op = gx_path_enum_next(&path, (gs_fixed_point *)vs); + if (begin) { + /* start point */ + start.x = fixed2float(vs[0]) / scale.x; + start.y = fixed2float(vs[1]) / scale.y; + begin = false; + +#ifdef OPVP_OPT_MULTI_PATH + npoints = 1; + points = realloc(points, sizeof(_fPoint)); + current = start; #endif - points[0] = start; - -#ifdef OPVP_OPT_MULTI_PATH - } else if (op != pop) { - /* convert float to Fix */ - opvp_p = realloc(opvp_p, sizeof(opvp_point_t) * npoints); - for (i = 0; i < npoints; i++) { - OPVP_F2FIX(points[i].x, opvp_p[i].x); - OPVP_F2FIX(points[i].y, opvp_p[i].y); - } - - switch (pop) { - case gs_pe_moveto: - /* call SetCurrentPoint */ - if (apiEntry->opvpSetCurrentPoint) { - r = apiEntry->opvpSetCurrentPoint( - printerContext, - opvp_p[npoints-1].x, - opvp_p[npoints-1].y); - } - if (r != OPVP_OK) ecode = -1; - break; - case gs_pe_lineto: - /* call LinePath */ - if (apiEntry->opvpLinePath) { - r = apiEntry->opvpLinePath( - printerContext, - OPVP_PATHOPEN, - npoints - 1, - &(opvp_p[1])); - } - if (r != OPVP_OK) ecode = -1; - break; - case gs_pe_curveto: - /* npoints */ - if (!cp_num) - cp_num = calloc(sizeof(int), 2); - cp_num[0] = npoints; - cp_num[1] = 0; - - /* call BezierPath */ - if (apiEntry->opvpBezierPath) { - r = apiEntry->opvpBezierPath( - printerContext, - npoints - 1, - &(opvp_p[1]) - ); - } - if (r != OPVP_OK) ecode = -1; - break; - case gs_pe_closepath: - /* close path */ - break; - default: - /* error */ - return_error(gs_error_unknownerror); - break; - } - - /* reset */ - npoints = 1; - if (cp_num) free(cp_num), cp_num = NULL; - points = realloc(points, sizeof(_fPoint)); - points[0] = current; + points[0] = start; + +#ifdef OPVP_OPT_MULTI_PATH + } else if (op != pop) { + /* convert float to Fix */ + opvp_p = realloc(opvp_p, sizeof(opvp_point_t) * npoints); + for (i = 0; i < npoints; i++) { + OPVP_F2FIX(points[i].x, opvp_p[i].x); + OPVP_F2FIX(points[i].y, opvp_p[i].y); + } + + switch (pop) { + case gs_pe_moveto: + /* call SetCurrentPoint */ + if (apiEntry->opvpSetCurrentPoint) { + r = apiEntry->opvpSetCurrentPoint( + printerContext, + opvp_p[npoints-1].x, + opvp_p[npoints-1].y); + } + if (r != OPVP_OK) ecode = -1; + break; + case gs_pe_lineto: + /* call LinePath */ + if (apiEntry->opvpLinePath) { + r = apiEntry->opvpLinePath( + printerContext, + OPVP_PATHOPEN, + npoints - 1, + &(opvp_p[1])); + } + if (r != OPVP_OK) ecode = -1; + break; + case gs_pe_curveto: + /* npoints */ + if (!cp_num) + cp_num = calloc(sizeof(int), 2); + cp_num[0] = npoints; + cp_num[1] = 0; + + /* call BezierPath */ + if (apiEntry->opvpBezierPath) { + r = apiEntry->opvpBezierPath( + printerContext, + npoints - 1, + &(opvp_p[1]) + ); + } + if (r != OPVP_OK) ecode = -1; + break; + case gs_pe_closepath: + /* close path */ + break; + default: + /* error */ + return_error(gs_error_unknownerror); + break; + } + + /* reset */ + npoints = 1; + if (cp_num) free(cp_num), cp_num = NULL; + points = realloc(points, sizeof(_fPoint)); + points[0] = current; #endif - } - - if (!op) break; /* END */ - - switch (op) { - case gs_pe_moveto: -#ifdef OPVP_OPT_MULTI_PATH - /* move to */ - i = npoints; - npoints += 1; - points = realloc(points, sizeof(_fPoint) * npoints); - points[i].x = fixed2float(vs[0]) / scale.x; - points[i].y = fixed2float(vs[1]) / scale.y; - current = points[i]; - start = current; + } + + if (!op) break; /* END */ + + switch (op) { + case gs_pe_moveto: +#ifdef OPVP_OPT_MULTI_PATH + /* move to */ + i = npoints; + npoints += 1; + points = realloc(points, sizeof(_fPoint) * npoints); + points[i].x = fixed2float(vs[0]) / scale.x; + points[i].y = fixed2float(vs[1]) / scale.y; + current = points[i]; + start = current; #else - /* move to */ - points[1].x = fixed2float(vs[0]) / scale.x; - points[1].y = fixed2float(vs[1]) / scale.y; - code = (*vdev_proc(vdev, moveto))(vdev, - points[0].x, - points[0].y, - points[1].x, - points[1].y, - type); - if (code) ecode = code; - points[0] = points[1]; - start = points[0]; + /* move to */ + points[1].x = fixed2float(vs[0]) / scale.x; + points[1].y = fixed2float(vs[1]) / scale.y; + code = (*vdev_proc(vdev, moveto))(vdev, + points[0].x, + points[0].y, + points[1].x, + points[1].y, + type); + if (code) ecode = code; + points[0] = points[1]; + start = points[0]; #endif - break; - case gs_pe_lineto: -#ifdef OPVP_OPT_MULTI_PATH - /* line to */ - i = npoints; - npoints += 1; - points = realloc(points, sizeof(_fPoint) * npoints); - points[i].x = fixed2float(vs[0]) / scale.x; - points[i].y = fixed2float(vs[1]) / scale.y; - current = points[i]; + break; + case gs_pe_lineto: +#ifdef OPVP_OPT_MULTI_PATH + /* line to */ + i = npoints; + npoints += 1; + points = realloc(points, sizeof(_fPoint) * npoints); + points[i].x = fixed2float(vs[0]) / scale.x; + points[i].y = fixed2float(vs[1]) / scale.y; + current = points[i]; #else - /* line to */ - points[1].x = fixed2float(vs[0]) / scale.x; - points[1].y = fixed2float(vs[1]) / scale.y; - code = (*vdev_proc(vdev, lineto))(vdev, - points[0].x, - points[0].y, - points[1].x, - points[1].y, - type); - if (code) ecode = code; - points[0] = points[1]; + /* line to */ + points[1].x = fixed2float(vs[0]) / scale.x; + points[1].y = fixed2float(vs[1]) / scale.y; + code = (*vdev_proc(vdev, lineto))(vdev, + points[0].x, + points[0].y, + points[1].x, + points[1].y, + type); + if (code) ecode = code; + points[0] = points[1]; #endif - break; - case gs_pe_curveto: -#ifdef OPVP_OPT_MULTI_PATH - /* curve to */ - check_p.x = fixed2float(vs[0]) / scale.x; - check_p.y = fixed2float(vs[1]) / scale.y; - - i = npoints; - npoints += 3; - points = realloc(points, sizeof(_fPoint) * npoints); - points[i ].x = fixed2float(vs[0]) / scale.x; - points[i ].y = fixed2float(vs[1]) / scale.y; - points[i+1].x = fixed2float(vs[2]) / scale.x; - points[i+1].y = fixed2float(vs[3]) / scale.y; - points[i+2].x = fixed2float(vs[4]) / scale.x; - points[i+2].y = fixed2float(vs[5]) / scale.y; - current = points[i+2]; + break; + case gs_pe_curveto: +#ifdef OPVP_OPT_MULTI_PATH + /* curve to */ + check_p.x = fixed2float(vs[0]) / scale.x; + check_p.y = fixed2float(vs[1]) / scale.y; + + i = npoints; + npoints += 3; + points = realloc(points, sizeof(_fPoint) * npoints); + points[i ].x = fixed2float(vs[0]) / scale.x; + points[i ].y = fixed2float(vs[1]) / scale.y; + points[i+1].x = fixed2float(vs[2]) / scale.x; + points[i+1].y = fixed2float(vs[3]) / scale.y; + points[i+2].x = fixed2float(vs[4]) / scale.x; + points[i+2].y = fixed2float(vs[5]) / scale.y; + current = points[i+2]; #else - /* curve to */ - points[1].x = fixed2float(vs[0]) / scale.x; - points[1].y = fixed2float(vs[1]) / scale.y; - points[2].x = fixed2float(vs[2]) / scale.x; - points[2].y = fixed2float(vs[3]) / scale.y; - points[3].x = fixed2float(vs[4]) / scale.x; - points[3].y = fixed2float(vs[5]) / scale.y; - code = (*vdev_proc(vdev, curveto))(vdev, - points[0].x, - points[0].y, - points[1].x, - points[1].y, - points[2].x, - points[2].y, - points[3].x, - points[3].y, - type); - if (code) ecode = code; - points[0] = points[3]; + /* curve to */ + points[1].x = fixed2float(vs[0]) / scale.x; + points[1].y = fixed2float(vs[1]) / scale.y; + points[2].x = fixed2float(vs[2]) / scale.x; + points[2].y = fixed2float(vs[3]) / scale.y; + points[3].x = fixed2float(vs[4]) / scale.x; + points[3].y = fixed2float(vs[5]) / scale.y; + code = (*vdev_proc(vdev, curveto))(vdev, + points[0].x, + points[0].y, + points[1].x, + points[1].y, + points[2].x, + points[2].y, + points[3].x, + points[3].y, + type); + if (code) ecode = code; + points[0] = points[3]; #endif - break; - case gs_pe_closepath: - /* close path */ - code = (*vdev_proc(vdev, closepath))( - vdev, - points[0].x, - points[0].y, - start.x, - start.y, - type); - if (code) ecode = code; - points[0] = start; -#ifdef OPVP_OPT_MULTI_PATH - current = start; + break; + case gs_pe_closepath: + /* close path */ + code = (*vdev_proc(vdev, closepath))( + vdev, + points[0].x, + points[0].y, + start.x, + start.y, + type); + if (code) ecode = code; + points[0] = start; +#ifdef OPVP_OPT_MULTI_PATH + current = start; #endif - break; - default: - /* error */ - return_error(gs_error_unknownerror); - break; - } - -#ifdef OPVP_OPT_MULTI_PATH - pop = op; + break; + default: + /* error */ + return_error(gs_error_unknownerror); + break; + } + +#ifdef OPVP_OPT_MULTI_PATH + pop = op; #endif } @@ -4990,7 +4990,7 @@ opvp_vector_dopath( code = (*vdev_proc(vdev, endpath))(vdev, type); if (code) ecode = code; -#ifdef OPVP_OPT_MULTI_PATH +#ifdef OPVP_OPT_MULTI_PATH if (points) free(points); if (opvp_p) free(opvp_p); if (cp_num) free(cp_num); @@ -5001,7 +5001,7 @@ opvp_vector_dopath( /* * vector do rect */ -static int +static int opvp_vector_dorect( gx_device_vector *vdev, fixed x0, @@ -5027,31 +5027,31 @@ opvp_vector_dorect( scale = vdev->scale; if (!ecode) { - /* rectangle */ - p.x = fixed2float(x0) / scale.x; - p.y = fixed2float(y0) / scale.y; - OPVP_F2FIX(p.x, rectangles[0].p0.x); - OPVP_F2FIX(p.y, rectangles[0].p0.y); - p.x = fixed2float(x1) / scale.x; - p.y = fixed2float(y1) / scale.y; - OPVP_F2FIX(p.x, rectangles[0].p1.x); - OPVP_F2FIX(p.y, rectangles[0].p1.y); - - /* call RectanglePath */ - if (apiEntry->opvpRectanglePath) { - r = apiEntry->opvpRectanglePath(printerContext, - 1, - rectangles); - } - if (r != OPVP_OK) { - ecode = -1; - } + /* rectangle */ + p.x = fixed2float(x0) / scale.x; + p.y = fixed2float(y0) / scale.y; + OPVP_F2FIX(p.x, rectangles[0].p0.x); + OPVP_F2FIX(p.y, rectangles[0].p0.y); + p.x = fixed2float(x1) / scale.x; + p.y = fixed2float(y1) / scale.y; + OPVP_F2FIX(p.x, rectangles[0].p1.x); + OPVP_F2FIX(p.y, rectangles[0].p1.y); + + /* call RectanglePath */ + if (apiEntry->opvpRectanglePath) { + r = apiEntry->opvpRectanglePath(printerContext, + 1, + rectangles); + } + if (r != OPVP_OK) { + ecode = -1; + } } /* end path */ if (!ecode) { - code = (*vdev_proc(vdev, endpath))(vdev, type); - if (code) ecode = code; + code = (*vdev_proc(vdev, endpath))(vdev, type); + if (code) ecode = code; } /* fallback */ @@ -5063,7 +5063,7 @@ opvp_vector_dorect( /* * begin path */ -static int +static int opvp_beginpath(gx_device_vector *vdev, gx_path_type_t type) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -5075,16 +5075,16 @@ opvp_beginpath(gx_device_vector *vdev, gx_path_type_t type) /* check clip-path */ if (type & gx_path_type_clip) { - if (apiEntry->opvpResetClipPath) - apiEntry->opvpResetClipPath(printerContext); + if (apiEntry->opvpResetClipPath) + apiEntry->opvpResetClipPath(printerContext); } /* call NewPath */ if (apiEntry->opvpNewPath) { - r = apiEntry->opvpNewPath(printerContext); + r = apiEntry->opvpNewPath(printerContext); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -5093,7 +5093,7 @@ opvp_beginpath(gx_device_vector *vdev, gx_path_type_t type) /* * move to */ -static int +static int opvp_moveto( gx_device_vector *vdev, floatp x0, @@ -5114,10 +5114,10 @@ opvp_moveto( OPVP_F2FIX(x1, p.x); OPVP_F2FIX(y1, p.y); if (apiEntry->opvpSetCurrentPoint) { - r = apiEntry->opvpSetCurrentPoint(printerContext, p.x, p.y); + r = apiEntry->opvpSetCurrentPoint(printerContext, p.x, p.y); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -5126,7 +5126,7 @@ opvp_moveto( /* * line to */ -static int +static int opvp_lineto( gx_device_vector *vdev, floatp x0, @@ -5149,10 +5149,10 @@ opvp_lineto( /* call LinePath */ if (apiEntry->opvpLinePath) { - r = apiEntry->opvpLinePath(printerContext, OPVP_PATHOPEN, 1, points); + r = apiEntry->opvpLinePath(printerContext, OPVP_PATHOPEN, 1, points); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -5161,7 +5161,7 @@ opvp_lineto( /* * curve to */ -static int +static int opvp_curveto( gx_device_vector *vdev, floatp x0, @@ -5197,13 +5197,13 @@ opvp_curveto( /* call BezierPath */ if (apiEntry->opvpBezierPath) { - r = apiEntry->opvpBezierPath(printerContext, - 3, - &(points[1]) - ); + r = apiEntry->opvpBezierPath(printerContext, + 3, + &(points[1]) + ); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -5212,7 +5212,7 @@ opvp_curveto( /* * close path */ -static int +static int opvp_closepath( gx_device_vector *vdev, floatp x, @@ -5235,10 +5235,10 @@ opvp_closepath( /* call LinePath */ if (apiEntry->opvpLinePath) { - r = apiEntry->opvpLinePath(printerContext, OPVP_PATHCLOSE, 1, points); + r = apiEntry->opvpLinePath(printerContext, OPVP_PATHCLOSE, 1, points); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } return ecode; @@ -5247,7 +5247,7 @@ opvp_closepath( /* * end path */ -static int +static int opvp_endpath(gx_device_vector *vdev, gx_path_type_t type) { gx_device_opvp *pdev = (gx_device_opvp *)vdev; @@ -5259,75 +5259,75 @@ opvp_endpath(gx_device_vector *vdev, gx_path_type_t type) /* call EndPath */ if (apiEntry->opvpEndPath) { - r = apiEntry->opvpEndPath(printerContext); + r = apiEntry->opvpEndPath(printerContext); } if (r != OPVP_OK) { - ecode = -1; + ecode = -1; } if (type & gx_path_type_fill) { - /* fill mode */ - if (type & gx_path_type_even_odd) { - /* call SetFillMode */ - if (apiEntry->opvpSetFillMode) { - r = apiEntry->opvpSetFillMode( - printerContext, - OPVP_FILLMODE_EVENODD - ); - } - if (r != OPVP_OK) { - ecode = -1; - } - } else { - /* call SetFillMode */ - if (apiEntry->opvpSetFillMode) { - r = apiEntry->opvpSetFillMode( - printerContext, - OPVP_FILLMODE_WINDING - ); - } - if (r != OPVP_OK) { - ecode = -1; - } - } - - if (type & gx_path_type_stroke) { - /* call StrokeFillPath */ - if (apiEntry->opvpStrokeFillPath) { - r = apiEntry->opvpStrokeFillPath(printerContext); - } - if (r != OPVP_OK) { - ecode = -1; - } - } else { - /* call FillPath */ - if (apiEntry->opvpFillPath) { - r = apiEntry->opvpFillPath(printerContext); - } - if (r != OPVP_OK) { - ecode = -1; - } - } + /* fill mode */ + if (type & gx_path_type_even_odd) { + /* call SetFillMode */ + if (apiEntry->opvpSetFillMode) { + r = apiEntry->opvpSetFillMode( + printerContext, + OPVP_FILLMODE_EVENODD + ); + } + if (r != OPVP_OK) { + ecode = -1; + } + } else { + /* call SetFillMode */ + if (apiEntry->opvpSetFillMode) { + r = apiEntry->opvpSetFillMode( + printerContext, + OPVP_FILLMODE_WINDING + ); + } + if (r != OPVP_OK) { + ecode = -1; + } + } + + if (type & gx_path_type_stroke) { + /* call StrokeFillPath */ + if (apiEntry->opvpStrokeFillPath) { + r = apiEntry->opvpStrokeFillPath(printerContext); + } + if (r != OPVP_OK) { + ecode = -1; + } + } else { + /* call FillPath */ + if (apiEntry->opvpFillPath) { + r = apiEntry->opvpFillPath(printerContext); + } + if (r != OPVP_OK) { + ecode = -1; + } + } } else if (type & gx_path_type_clip) { - /* call SetClipPath */ - if (apiEntry->opvpSetClipPath) { - r = apiEntry->opvpSetClipPath( - printerContext, - (type & gx_path_type_even_odd - ? OPVP_CLIPRULE_EVENODD - : OPVP_CLIPRULE_WINDING)); - } - if (r != OPVP_OK) { - ecode = -1; - } + /* call SetClipPath */ + if (apiEntry->opvpSetClipPath) { + r = apiEntry->opvpSetClipPath( + printerContext, + (type & gx_path_type_even_odd + ? OPVP_CLIPRULE_EVENODD + : OPVP_CLIPRULE_WINDING)); + } + if (r != OPVP_OK) { + ecode = -1; + } } else if (type & gx_path_type_stroke) { - /* call StrokePath */ - if (apiEntry->opvpStrokePath) { - r = apiEntry->opvpStrokePath(printerContext); - } - if (r != OPVP_OK) { - ecode = -1; - } + /* call StrokePath */ + if (apiEntry->opvpStrokePath) { + r = apiEntry->opvpStrokePath(printerContext); + } + if (r != OPVP_OK) { + ecode = -1; + } } return ecode; diff --git a/gs/psi/zchar.c b/gs/psi/zchar.c index 71b85b623..cd3fa0125 100644 --- a/gs/psi/zchar.c +++ b/gs/psi/zchar.c @@ -39,8 +39,6 @@ #include "store.h" #include "zchar42.h" -extern bool CPSI_mode; - /* Forward references */ static bool map_glyph_to_char(const gs_memory_t *mem, const ref *, const ref *, ref *); @@ -446,9 +444,8 @@ op_show_finish_setup(i_ctx_t *i_ctx_p, gs_text_enum_t * penum, int npop, gs_text_enum_t *osenum = op_show_find(i_ctx_p); es_ptr ep = esp + snumpush; gs_glyph glyph; - extern bool CPSI_mode; - if (CPSI_mode) { + if (gs_currentcpsimode(igs->memory)) { /* CET 14-03.PS page 2 emits rangecheck before rendering a character. Early check the text to font compatibility with decomposing the text into characters.*/ @@ -908,7 +905,7 @@ font_bbox_param(const gs_memory_t *mem, const ref * pfdict, double bbox[4]) ) bbox[0] = bbox[1] = bbox[2] = bbox[3] = 0.0; } - } else if (CPSI_mode) { + } else if (gs_currentcpsimode(mem)) { return_error(e_invalidfont); /* CPSI requires FontBBox */ } return 0; diff --git a/gs/psi/zcharx.c b/gs/psi/zcharx.c index 6b8ffcc47..bc1fa06e1 100644 --- a/gs/psi/zcharx.c +++ b/gs/psi/zcharx.c @@ -97,7 +97,7 @@ moveshow(i_ctx_t *i_ctx_p, bool have_x, bool have_y) int format; uint i, size, widths_needed; float *values; - extern bool CPSI_mode; + bool CPSI_mode = gs_currentcpsimode(imemory); if (code != 0) return code; diff --git a/gs/psi/zfont.c b/gs/psi/zfont.c index 05daae164..84fcd21f0 100644 --- a/gs/psi/zfont.c +++ b/gs/psi/zfont.c @@ -164,7 +164,7 @@ zsetcacheparams(i_ctx_t *i_ctx_p) } switch (i) { case 3: - if ((code = gs_setcachesize(ifont_dir, params[2])) < 0) + if ((code = gs_setcachesize(igs, ifont_dir, params[2])) < 0) return code; case 2: if ((code = gs_setcachelower(ifont_dir, params[1])) < 0) diff --git a/gs/psi/zfunc3.c b/gs/psi/zfunc3.c index cd03cf4ce..3a8bbc485 100644 --- a/gs/psi/zfunc3.c +++ b/gs/psi/zfunc3.c @@ -25,6 +25,7 @@ #include "idparam.h" #include "ifunc.h" #include "store.h" +#include "igstate.h" /* Check prototypes */ build_function_proc(gs_build_function_2); @@ -69,7 +70,6 @@ gs_build_function_3(i_ctx_t *i_ctx_p, const ref *op, const gs_function_params_t { gs_function_1ItSg_params_t params; int code; - extern bool CPSI_mode; *(gs_function_params_t *) & params = *mnDR; params.Functions = 0; @@ -99,7 +99,7 @@ gs_build_function_3(i_ctx_t *i_ctx_p, const ref *op, const gs_function_params_t } if ((code = fn_build_float_array(op, "Bounds", true, false, ¶ms.Bounds, mem)) != params.k - 1) goto fail; - if (CPSI_mode) { + if (gs_currentcpsimode(imemory)) { /* Adobe implementation doesn't check the Encode length. */ /* Extra elements are ignored; missing elements are filled with 0. */ /* CET 12-14m.ps depends on this bug */ diff --git a/gs/psi/zimage.c b/gs/psi/zimage.c index d7d5280fb..f39109c66 100644 --- a/gs/psi/zimage.c +++ b/gs/psi/zimage.c @@ -164,7 +164,6 @@ image1_setup(i_ctx_t * i_ctx_p, bool has_alpha) image_params ip; int code; gs_color_space *csp = gs_currentcolorspace(igs); - extern bool CPSI_mode; /* Adobe interpreters accept sampled images when the current color * space is a pattern color space using the base color space instead @@ -172,7 +171,7 @@ image1_setup(i_ctx_t * i_ctx_p, bool has_alpha) * If all conditions are not met the pattern color space goes through * triggering a rangecheck error. */ - if (CPSI_mode && gs_color_space_num_components(csp) < 1) { + if (gs_currentcpsimode(imemory) && gs_color_space_num_components(csp) < 1) { gs_color_space *bsp = csp->base_space; if (bsp) csp = bsp; diff --git a/gs/psi/zmisc.c b/gs/psi/zmisc.c index aae51e6ad..75c4baba4 100644 --- a/gs/psi/zmisc.c +++ b/gs/psi/zmisc.c @@ -384,22 +384,15 @@ zsetdebug(i_ctx_t *i_ctx_p) /* There are a few cases where a customer/user might want CPSI behavior * instead of the GS default behavior. cmyk_to_rgb and Type 1 char fill * method are two that have come up so far. This operator allows a PS - * program to control the behavior without needing to recompile - * - * While this would better if it were in some context 'state', we use - * a global, which we don't really like, but at least it is better - * than a compile time #define, as in #USE_ADOBE_CMYK_RGB and allows - * us to easily test with/without and not require recompilation. + * program to control the behavior without needing to recompile. */ -extern bool CPSI_mode; /* not worth polluting a header file */ - /* <bool> .setCPSImode - */ static int zsetCPSImode(i_ctx_t *i_ctx_p) { os_ptr op = osp; check_type(*op, t_boolean); - CPSI_mode = op->value.boolval; + gs_setcpsimode(imemory, op->value.boolval); pop(1); return 0; } @@ -411,7 +404,7 @@ zgetCPSImode(i_ctx_t *i_ctx_p) os_ptr op = osp; push(1); - make_bool(op, CPSI_mode); + make_bool(op, gs_currentcpsimode(imemory)); return 0; } diff --git a/gs/psi/zupath.c b/gs/psi/zupath.c index f35bc3d9e..a3d1757da 100644 --- a/gs/psi/zupath.c +++ b/gs/psi/zupath.c @@ -49,8 +49,6 @@ extern const int gs_hit_detected; * The 'upath_compat' Boolean controls this behavior. */ -extern bool CPSI_mode; - /* Forward references */ static int upath_append(os_ptr, i_ctx_t *, bool); static int upath_stroke(i_ctx_t *, gs_matrix *, bool); @@ -367,7 +365,7 @@ zueofill(i_ctx_t *i_ctx_p) if (code < 0) return code; - if ((code = upath_append(op, i_ctx_p, CPSI_mode)) >= 0) + if ((code = upath_append(op, i_ctx_p, gs_currentcpsimode(imemory))) >= 0) code = gs_eofill(igs); gs_grestore(igs); if (code < 0) @@ -385,7 +383,7 @@ zufill(i_ctx_t *i_ctx_p) if (code < 0) return code; - if ((code = upath_append(op, i_ctx_p, CPSI_mode)) >= 0) + if ((code = upath_append(op, i_ctx_p, gs_currentcpsimode(imemory))) >= 0) code = gs_fill(igs); gs_grestore(igs); if (code < 0) @@ -404,7 +402,7 @@ zustroke(i_ctx_t *i_ctx_p) if (code < 0) return code; - if ((code = npop = upath_stroke(i_ctx_p, NULL, CPSI_mode)) >= 0) + if ((code = npop = upath_stroke(i_ctx_p, NULL, gs_currentcpsimode(imemory))) >= 0) code = gs_stroke(igs); gs_grestore(igs); if (code < 0) @@ -509,7 +507,7 @@ make_upath(i_ctx_t *i_ctx_p, ref *rupath, gs_state *pgs, gx_path *ppath, * not in CPSI compatibility mode, we set a reasonable default * bbox instead. */ - if (code != e_nocurrentpoint || CPSI_mode) + if (code != e_nocurrentpoint || gs_currentcpsimode(imemory)) return code; bbox.p.x = bbox.p.y = bbox.q.x = bbox.q.y = 0; } diff --git a/gs/psi/zusparam.c b/gs/psi/zusparam.c index e12ea4685..198de228e 100644 --- a/gs/psi/zusparam.c +++ b/gs/psi/zusparam.c @@ -35,6 +35,7 @@ #include "ivmem2.h" #include "store.h" #include "gsnamecl.h" +#include "igstate.h" /* The (global) font directory */ extern gs_font_dir *ifont_dir; /* in zfont.c */ @@ -137,7 +138,7 @@ current_MaxFontCache(i_ctx_t *i_ctx_p) static int set_MaxFontCache(i_ctx_t *i_ctx_p, long val) { - return gs_setcachesize(ifont_dir, + return gs_setcachesize(igs, ifont_dir, (uint)(val < 0 ? 0 : val > max_uint ? max_uint : val)); } |