[gs-cvs] gs/src
Dan Coby
dan at casper.ghostscript.com
Wed Aug 28 17:11:33 PDT 2002
Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv13527/src
Modified Files:
gxdcolor.h gxdhtserial.c
Log Message:
The two files were missed in earlier commits.
Missing from the 8-28-02 commit form ORIMP.
src/gxdcolor.c
Added the "get_phase" method to the gx_device_color_type_t structure,
and installed this method in various instances of the structure. Also
provided the two canonical implementations of this method.
Missing from the 8-26-02 commit from ORIMP.
src/gxdhtserial.c
1. Updated gx_ht_read_tf and gx_ht_read_and_install to properly
use the reference count in a transfer function.
2. Fixed various other errors discovered when this code was first
used.
Index: gxdcolor.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxdcolor.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gxdcolor.h 26 Aug 2002 23:00:07 -0000 1.8
+++ gxdcolor.h 29 Aug 2002 00:11:30 -0000 1.9
@@ -86,6 +86,10 @@
* The "get_dev_halftone" method returns a pointer to the device
* halftone used by the current color, or NULL if there is no such
* halftone (i.e.: the device color is a pure color).
+ *
+ * The "get_phase" returns true if the device color contains phase
+ * information, and sets *pphase to the appropriate value. Halftones
+ * that do not use the color information return false.
*/
#define dev_color_proc_save_dc(proc)\
void proc(const gx_device_color * pdevc, gx_device_color_saved * psdc)
@@ -95,6 +99,10 @@
const gx_device_halftone * proc(const gx_device_color * pdevc)
dev_color_proc_get_dev_halftone((*get_dev_halftone));
+#define dev_color_proc_get_phase(proc)\
+ bool proc(const gx_device_color * pdevc, gs_int_point * pphase)
+ dev_color_proc_get_phase((*get_phase));
+
/*
* If necessary and possible, load the halftone or Pattern cache
* with the rendering of this color.
@@ -264,6 +272,10 @@
/* convert between color types and color type indices */
extern int gx_get_dc_type_index(const gx_device_color *);
extern const gx_device_color_type_t * gx_get_dc_type_from_index(int);
+
+/* the two canonical "get_phase" methods */
+extern dev_color_proc_get_phase(gx_dc_no_get_phase);
+extern dev_color_proc_get_phase(gx_dc_ht_get_phase);
#define gs_color_writes_pure(pgs)\
Index: gxdhtserial.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxdhtserial.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gxdhtserial.c 22 Aug 2002 07:12:29 -0000 1.1
+++ gxdhtserial.c 29 Aug 2002 00:11:30 -0000 1.2
@@ -14,7 +14,7 @@
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
*/
-/* $Id: */
+/* $Id$ */
/* Serialization and de-serialization for (traditional) halftones */
#include "memory_.h"
@@ -128,12 +128,12 @@
}
/* allocate a transfer map */
- pmap = gs_alloc_struct( mem,
- gx_transfer_map,
- &st_transfer_map,
- "gx_ht_read_tf" );
- if (pmap == 0)
- return_error(gs_error_VMerror);
+ rc_alloc_struct_1( pmap,
+ gx_transfer_map,
+ &st_transfer_map,
+ mem,
+ return_error(gs_error_VMerror),
+ "gx_ht_read_tf" );
pmap->id = gs_next_ids(1);
pmap->closure.proc = 0;
@@ -144,9 +144,10 @@
} else if (tf_type == gx_ht_tf_complete && size >= sizeof(pmap->values)) {
memcpy(pmap->values, data, sizeof(pmap->values));
pmap->proc = gs_mapped_transfer;
+ *ppmap = pmap;
return 1 + sizeof(pmap->values);
} else {
- gs_free_object(mem, pmap, "gx_ht_read_tf");
+ rc_decrement(pmap, "gx_ht_read_tf");
return_error(gs_error_rangecheck);
}
}
@@ -419,7 +420,9 @@
* will never check values beyond the range required by the
* current order.
*/
- if ( memcmp(phtr->levels, new_order.levels, levels_size) == 0 &&
+ if ( phtr->num_levels * sizeof(phtr->levels[0]) >= levels_size &&
+ phtr->Width * phtr->Height * phtr->elt_size >= bits_size &&
+ memcmp(phtr->levels, new_order.levels, levels_size) == 0 &&
memcmp(phtr->bit_data, new_order.bit_data, bits_size) == 0 ) {
/* the casts below are required to discard const qualifiers */
gs_free_object(mem, new_order.bit_data, "gx_ht_read_component");
@@ -595,6 +598,7 @@
/* process the component orders */
for (i = 0, code = 0; i < num_comps && code >= 0; i++) {
+ components[i].comp_number = i;
code = gx_ht_read_component(&components[i], data, size, mem);
if (code >= 0) {
size -= code;
@@ -607,18 +611,13 @@
code = gx_imager_dev_ht_install(pis, &dht, dht.type, dev);
/*
- * Regardless of the success of installation, discard the allocated
- * elements now. The gx_device_halftone_release procedure can't be
- * used, as the components array is on the stack rather than in the
- * heap. We must also pay special attention to the transfer functions,
- * if any, as there reference counts are not incremented until the
- * halftone is stored in the imager state. Hence, we only want to
- * release them if their reference counts are still 0.
+ * If installation failed, discard the allocated elements. We can't
+ * use the gx_device_halftone_release procedure, as the components
+ * array is on the stack rather than in the heap.
*/
- for (i = 0; i < num_comps; i++) {
- if (components[i].corder.transfer->rc.ref_count != 0)
- components[i].corder.transfer = 0;
- gx_ht_order_release(&components[i].corder, mem, false);
+ if (code < 0) {
+ for (i = 0; i < num_comps; i++)
+ gx_ht_order_release(&components[i].corder, mem, false);
}
return code < 0 ? code : data - data0;
More information about the gs-cvs
mailing list