summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/gdevplnx.c8
-rw-r--r--base/gsgstate.c18
-rw-r--r--base/gxclrast.c35
-rw-r--r--base/gxgstate.h4
-rw-r--r--base/lib.mak2
5 files changed, 42 insertions, 25 deletions
diff --git a/base/gdevplnx.c b/base/gdevplnx.c
index 37ed6414c..3a85b6d03 100644
--- a/base/gdevplnx.c
+++ b/base/gdevplnx.c
@@ -29,6 +29,7 @@
#include "gxgetbit.h"
#include "gxiparam.h"
#include "gxgstate.h"
+#include "gsstate.h"
#include "gdevplnx.h"
/* Define the size of the locally allocated bitmap buffers. */
@@ -428,6 +429,7 @@ plane_device_init(gx_device_plane_extract *edev, gx_device *target,
gx_device_set_target((gx_device_forward *)edev, target);
gx_device_copy_params((gx_device *)edev, target);
edev->plane_dev = plane_dev;
+ gx_device_retain(plane_dev, true);
edev->plane = *render_plane;
plane_open_device((gx_device *)edev);
if (clear) {
@@ -841,6 +843,8 @@ typedef struct plane_image_enum_s {
const gs_gstate *pgs; /* original gs_gstate */
gs_gstate *pgs_image; /* modified gs_gstate state */
} plane_image_enum_t;
+/* Note that we include the pgs_image which is 'bytes' type (not gs_gstate) */
+/* It still needs to be traced so that a GC won't free it prematurely. */
gs_private_st_suffix_add3(st_plane_image_enum, plane_image_enum_t,
"plane_image_enum_t", plane_image_enum_enum_ptrs,
plane_image_enum_reloc_ptrs, st_gx_image_enum_common, info, pgs, pgs_image);
@@ -991,10 +995,9 @@ plane_begin_typed_image(gx_device * dev,
}
info = gs_alloc_struct(memory, plane_image_enum_t, &st_plane_image_enum,
"plane_image_begin_typed(info)");
- pgs_image = gs_gstate_copy_temp(pgs, memory);
+ pgs_image = gs_gstate_copy(pgs, memory);
if (pgs_image == 0 || info == 0)
goto fail;
- *pgs_image = *pgs;
pgs_image->client_data = info;
pgs_image->get_cmap_procs = plane_get_cmap_procs;
code = dev_proc(edev->plane_dev, begin_typed_image)
@@ -1034,6 +1037,7 @@ plane_image_end_image(gx_image_enum_common_t * info, bool draw_last)
plane_image_enum_t * const ppie = (plane_image_enum_t *)info;
int code = gx_image_end(ppie->info, draw_last);
+ ppie->pgs_image->client_data = NULL; /* this isn't a complete client_data struct */
gs_free_object(ppie->memory, ppie->pgs_image,
"plane_image_end_image(pgs_image)");
gx_image_free_enum(&info);
diff --git a/base/gsgstate.c b/base/gsgstate.c
index 6227ade6f..d74a6f094 100644
--- a/base/gsgstate.c
+++ b/base/gsgstate.c
@@ -148,24 +148,6 @@ gs_gstate_initialize(gs_gstate * pgs, gs_memory_t * mem)
return 0;
}
-/*
- * Make a temporary copy of a gs_gstate. Note that this does not
- * do all the necessary reference counting, etc. However, it does
- * clear out the transparency stack in the destination.
- */
-gs_gstate *
-gs_gstate_copy_temp(const gs_gstate * pgs, gs_memory_t * mem)
-{
- gs_gstate *pgs_copy =
- gs_alloc_struct(mem, gs_gstate, &st_gs_gstate,
- "gs_gstate_copy");
-
- if (pgs_copy) {
- *pgs_copy = *pgs;
- }
- return pgs_copy;
-}
-
/* Increment reference counts to note that an gs_gstate has been copied. */
void
gs_gstate_copied(gs_gstate * pgs)
diff --git a/base/gxclrast.c b/base/gxclrast.c
index 65df9bd38..3414799a3 100644
--- a/base/gxclrast.c
+++ b/base/gxclrast.c
@@ -629,6 +629,33 @@ in: /* Initialize for a new page. */
rc_increment_cs(pcs);
gs_gstate.color[1].color_space = pcs;
rc_increment_cs(pcs);
+ /* Initialize client color and device color */
+ gs_gstate.color[0].ccolor =
+ gs_alloc_struct(mem, gs_client_color, &st_client_color, "clist_playback_band");
+ gs_gstate.color[1].ccolor =
+ gs_alloc_struct(mem, gs_client_color, &st_client_color, "clist_playback_band");
+ gs_gstate.color[0].dev_color =
+ gs_alloc_struct(mem, gx_device_color, &st_device_color, "clist_playback_band");
+ gs_gstate.color[1].dev_color =
+ gs_alloc_struct(mem, gx_device_color, &st_device_color, "clist_playback_band");
+ if (gs_gstate.color[0].ccolor == 0 || gs_gstate.color[0].dev_color == 0 ||
+ gs_gstate.color[1].ccolor == 0 || gs_gstate.color[1].dev_color == 0
+ ) {
+ gs_free_object(mem, gs_gstate.color[1].ccolor, "clist_playback_band");
+ gs_free_object(mem, gs_gstate.color[0].dev_color, "clist_playback_band");
+ gs_free_object(mem, gs_gstate.color[1].dev_color, "clist_playback_band");
+ return_error(gs_error_VMerror);
+ }
+ gs_gstate.color[0].color_space->pclient_color_space_data =
+ pcs->pclient_color_space_data;
+ cs_full_init_color(gs_gstate.color[0].ccolor, pcs);
+ gx_unset_dev_color(&gs_gstate);
+
+ gs_gstate.color[1].color_space->pclient_color_space_data =
+ pcs->pclient_color_space_data;
+ cs_full_init_color(gs_gstate.color[1].ccolor, pcs);
+ gx_unset_dev_color(&gs_gstate);
+
/* Remove the ICC link cache and replace with the device link cache
so that we share the cache across bands */
rc_decrement(gs_gstate.icc_link_cache,"clist_playback_band");
@@ -2361,6 +2388,14 @@ idata: data_size = 0;
gx_pattern_cache_free(gs_gstate.pattern_cache);
gs_gstate.pattern_cache = NULL;
}
+ /* Free the client color and device colors allocated upon entry */
+ gs_free_object(mem, gs_gstate.color[0].ccolor, "clist_playback_band");
+ gs_free_object(mem, gs_gstate.color[1].ccolor, "clist_playback_band");
+ gs_free_object(mem, gs_gstate.color[0].dev_color, "clist_playback_band");
+ gs_free_object(mem, gs_gstate.color[1].dev_color, "clist_playback_band");
+ gs_gstate.color[0].ccolor = gs_gstate.color[1].ccolor = NULL;
+ gs_gstate.color[0].dev_color = gs_gstate.color[1].dev_color = NULL;
+
/* The imager state release will decrement the icc link cache. To avoid
race conditions lock the cache */
gx_monitor_enter(cdev->icc_cache_cl->lock);
diff --git a/base/gxgstate.h b/base/gxgstate.h
index 984d0c2bb..0b0f5bd18 100644
--- a/base/gxgstate.h
+++ b/base/gxgstate.h
@@ -415,10 +415,6 @@ struct_proc_finalize(gs_gstate_finalize);
/* gs_gstate_initial. */
int gs_gstate_initialize(gs_gstate * pgs, gs_memory_t * mem);
-/* Make a temporary copy of a gs_gstate. Note that this does not */
-/* do all the necessary reference counting, etc. */
-gs_gstate * gs_gstate_copy_temp(const gs_gstate * pgs, gs_memory_t * mem);
-
/* Increment reference counts to note that a graphics state has been copied. */
void gs_gstate_copied(gs_gstate * pgs);
diff --git a/base/lib.mak b/base/lib.mak
index 4e5bceba1..133fe338c 100644
--- a/base/lib.mak
+++ b/base/lib.mak
@@ -1227,7 +1227,7 @@ $(GLOBJ)gdevplnx.$(OBJ) : $(GLSRC)gdevplnx.c $(AK) $(gx_h)\
$(gserrors_h) $(gsbitops_h) $(gsrop_h) $(gsstruct_h) $(gsutil_h)\
$(gdevplnx_h)\
$(gxcmap_h) $(gxdcolor_h) $(gxdevice_h) $(gxdevmem_h) $(gxdither_h)\
- $(gxgetbit_h) $(gxiparam_h) $(gxgstate_h) $(LIB_MAK) $(MAKEDIRS)
+ $(gxgetbit_h) $(gxiparam_h) $(gxgstate_h) $(gsstate_h) $(LIB_MAK) $(MAKEDIRS)
$(GLCC) $(GLO_)gdevplnx.$(OBJ) $(C_) $(GLSRC)gdevplnx.c
### Default driver procedure implementations