summaryrefslogtreecommitdiff
path: root/psi/zcie.c
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2015-11-17 13:34:45 +0000
committerKen Sharp <ken.sharp@artifex.com>2015-11-17 13:34:45 +0000
commit5e8eae05c4629217f87eaab7302ac7b880dd9c7c (patch)
tree3f82b22ac35c7d4ff984c14d4669af72e32492d7 /psi/zcie.c
parent70880b866b06e34e4c078e115001371ae8e9c454 (diff)
downloadghostpdl-5e8eae05c4629217f87eaab7302ac7b880dd9c7c.tar.gz
Hash CIE spaces to detect matching, cached, ICC profiles
Bug #696355 "Create unique ID for CIE color spaces" Creating an ICC profile for a PostScript colour space is a performance hit. Especially (I believe) for CIE spaces. We maintain a cache of ICC profiles that have been created, but we need a way to identify if a given, cached, profile matches a newly selected colour space. There is code already in place for this, but missing the generation of a unique ID for a space, so that we can find a matching profile, if we have one cached. This commit uses the existing MD5 machinery to create a hash from the PostScript array defining a CIEBased colour space. We then use that hash as the ID for the space, and check to see if we already have a cached ICC profile with a matching ID. This should improve performance on files using CIEBased colour spaces, especially if they do 'gsave [/CIEBased <<...>>] setcolorspace grestore' operations, as we will only need to create the ICC profile once. I've created and manually checked example CIEBasedA, CIEBasedABC, CIEBasedDEF and CIEBasedDEFG files to see that two identical spaces are correctly identified as the same and that spaces with even very tiny differences are correctly identified as different. No differences expected in cluster test.
Diffstat (limited to 'psi/zcie.c')
-rw-r--r--psi/zcie.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/psi/zcie.c b/psi/zcie.c
index 5085ede3a..34ae3cc3a 100644
--- a/psi/zcie.c
+++ b/psi/zcie.c
@@ -438,8 +438,10 @@ ciedefgspace(i_ctx_t *i_ctx_p, ref *CIEDict, ulong dictkey)
bool has_defg_procs, has_abc_procs, has_lmn_procs;
gs_ref_memory_t *imem = (gs_ref_memory_t *)mem;
-/* pcs = gsicc_find_cs(dictkey, igs); */
- pcs = NULL;
+ if (dictkey != 0)
+ pcs = gsicc_find_cs(dictkey, igs);
+ else
+ pcs = NULL;
push(1); /* Sacrificial */
procs = istate->colorspace[0].procs.cie;
if (pcs == NULL ) {
@@ -538,8 +540,10 @@ ciedefspace(i_ctx_t *i_ctx_p, ref *CIEDict, ulong dictkey)
bool has_def_procs, has_lmn_procs, has_abc_procs;
gs_ref_memory_t *imem = (gs_ref_memory_t *)mem;
-/* pcs = gsicc_find_cs(dictkey, igs); */
- pcs = NULL;
+ if (dictkey != 0)
+ pcs = gsicc_find_cs(dictkey, igs);
+ else
+ pcs = NULL;
push(1); /* Sacrificial */
procs = istate->colorspace[0].procs.cie;
if (pcs == NULL ) {
@@ -596,8 +600,11 @@ cieabcspace(i_ctx_t *i_ctx_p, ref *CIEDict, ulong dictkey)
gs_ref_memory_t *imem = (gs_ref_memory_t *)mem;
/* See if the color space is in the profile cache */
-/* pcs = gsicc_find_cs(dictkey, igs); */
- pcs = NULL;
+ if (dictkey != 0)
+ pcs = gsicc_find_cs(dictkey, igs);
+ else
+ pcs = NULL;
+
push(1); /* Sacrificial */
procs = istate->colorspace[0].procs.cie;
if (pcs == NULL ) {
@@ -653,8 +660,10 @@ cieaspace(i_ctx_t *i_ctx_p, ref *CIEdict, ulong dictkey)
bool has_lmn_procs;
/* See if the color space is in the profile cache */
-/* pcs = gsicc_find_cs(dictkey, igs); */
- pcs = NULL;
+ if (dictkey != 0)
+ pcs = gsicc_find_cs(dictkey, igs);
+ else
+ pcs = NULL;
push(1); /* Sacrificial */
procs = istate->colorspace[0].procs.cie;
if (pcs == NULL ) {