diff options
-rw-r--r-- | Resource/Init/pdf_draw.ps | 2 | ||||
-rw-r--r-- | base/gsicc_profilecache.c | 9 | ||||
-rw-r--r-- | psi/zicc.c | 38 |
3 files changed, 41 insertions, 8 deletions
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps index 6b0ba93e1..79733df45 100644 --- a/Resource/Init/pdf_draw.ps +++ b/Resource/Init/pdf_draw.ps | |||
@@ -797,7 +797,7 @@ currentdict /csncompdict undef | |||
797 | mark exch { oforce } forall .dicttomark | 797 | mark exch { oforce } forall .dicttomark |
798 | dup dup //true resolvestream | 798 | dup dup //true resolvestream |
799 | /ReusableStreamDecode filter /DataSource exch put | 799 | /ReusableStreamDecode filter /DataSource exch put |
800 | 800 | dup /.hash 0 put % placeholder for use by seticc icc_profile_cache key | |
801 | % Check that the number of components (/N) defined in the ICCBased | 801 | % Check that the number of components (/N) defined in the ICCBased |
802 | % dictionry matches the actual profile. Bug #696120 | 802 | % dictionry matches the actual profile. Bug #696120 |
803 | dup /N get | 803 | dup /N get |
diff --git a/base/gsicc_profilecache.c b/base/gsicc_profilecache.c index 6520ba08e..bf71c2e37 100644 --- a/base/gsicc_profilecache.c +++ b/base/gsicc_profilecache.c | |||
@@ -113,6 +113,9 @@ gsicc_add_cs(gs_gstate * pgs, gs_color_space * colorspace, uint64_t dictkey) | |||
113 | result->color_space = colorspace; | 113 | result->color_space = colorspace; |
114 | rc_increment(colorspace); | 114 | rc_increment(colorspace); |
115 | result->key = dictkey; | 115 | result->key = dictkey; |
116 | if_debug2m(gs_debug_flag_icc, memory, | ||
117 | "[icc] Add cs to cache = 0x%p, hash = %lld \n", | ||
118 | result->color_space, (uint64_t)result->key); | ||
116 | profile_cache->num_entries++; | 119 | profile_cache->num_entries++; |
117 | } | 120 | } |
118 | 121 | ||
@@ -125,6 +128,9 @@ gsicc_find_cs(uint64_t key_test, gs_gstate * pgs) | |||
125 | /* Look through the cache for the key. If found, move to MRU */ | 128 | /* Look through the cache for the key. If found, move to MRU */ |
126 | while (curr != NULL ){ | 129 | while (curr != NULL ){ |
127 | if (curr->key == key_test){ | 130 | if (curr->key == key_test){ |
131 | if_debug2m(gs_debug_flag_icc, pgs->memory, | ||
132 | "[icc] Found cs = 0x%p, hash = %lld \n", | ||
133 | curr->color_space, (uint64_t)curr->key); | ||
128 | /* If not already at head of list, move this one there */ | 134 | /* If not already at head of list, move this one there */ |
129 | if (curr != profile_cache->head) { | 135 | if (curr != profile_cache->head) { |
130 | /* We need to move found one to the top of the list. */ | 136 | /* We need to move found one to the top of the list. */ |
@@ -175,6 +181,9 @@ gsicc_remove_cs_entry(gsicc_profile_cache_t *profile_cache) | |||
175 | /* Decremented, but someone could still be referencing this */ | 181 | /* Decremented, but someone could still be referencing this */ |
176 | /* If found again in the source document, it will be regenerated | 182 | /* If found again in the source document, it will be regenerated |
177 | and added back into the cache. */ | 183 | and added back into the cache. */ |
184 | if_debug2m(gs_debug_flag_icc, memory, | ||
185 | "[icc] Remove cs from cache = 0x%p, hash = %lld \n", | ||
186 | curr->color_space, (uint64_t)curr->key); | ||
178 | rc_decrement(curr->color_space, "gsicc_remove_cs_entry"); | 187 | rc_decrement(curr->color_space, "gsicc_remove_cs_entry"); |
179 | gs_free_object(memory->stable_memory, curr, "gsicc_remove_cs_entry"); | 188 | gs_free_object(memory->stable_memory, curr, "gsicc_remove_cs_entry"); |
180 | } | 189 | } |
diff --git a/psi/zicc.c b/psi/zicc.c index dbd2562c7..f9c7b1ec5 100644 --- a/psi/zicc.c +++ b/psi/zicc.c | |||
@@ -47,6 +47,7 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff) | |||
47 | int code, k; | 47 | int code, k; |
48 | gs_color_space * pcs; | 48 | gs_color_space * pcs; |
49 | ref * pstrmval; | 49 | ref * pstrmval; |
50 | ref * phashval = NULL; | ||
50 | stream * s = 0L; | 51 | stream * s = 0L; |
51 | cmm_profile_t *picc_profile = NULL; | 52 | cmm_profile_t *picc_profile = NULL; |
52 | int i, expected = 0; | 53 | int i, expected = 0; |
@@ -58,13 +59,27 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff) | |||
58 | GSICC_STANDARD_PROFILES_KEYS | 59 | GSICC_STANDARD_PROFILES_KEYS |
59 | }; | 60 | }; |
60 | 61 | ||
62 | /* If we are override ICC mode, we won't use the profile */ | ||
63 | if (!gs_currentoverrideicc(igs) && | ||
64 | dict_find_string(ICCdict, ".hash", &phashval) == 1 && | ||
65 | r_has_type(phashval, t_integer)) { | ||
66 | pcs = gsicc_find_cs(phashval->value.intval, igs); | ||
67 | if (pcs != NULL) { | ||
68 | /* Set the color space. We are done. */ | ||
69 | code = gs_setcolorspace(igs, pcs); | ||
70 | /* Remove the ICC dict from the stack */ | ||
71 | pop(1); | ||
72 | return code; | ||
73 | } | ||
74 | } | ||
75 | |||
61 | /* verify the DataSource entry */ | 76 | /* verify the DataSource entry */ |
62 | if (dict_find_string(ICCdict, "DataSource", &pstrmval) <= 0) | 77 | if (dict_find_string(ICCdict, "DataSource", &pstrmval) <= 0) |
63 | return_error(gs_error_undefined); | 78 | return_error(gs_error_undefined); |
64 | check_read_file(i_ctx_p, s, pstrmval); | 79 | check_read_file(i_ctx_p, s, pstrmval); |
65 | 80 | ||
66 | /* build the color space object */ | 81 | /* build the color space object */ |
67 | code = gs_cspace_build_ICC(&pcs, NULL, gs_gstate_memory(igs)); | 82 | code = gs_cspace_build_ICC(&pcs, NULL, gs_gstate_memory(igs)->stable_memory); |
68 | if (code < 0) | 83 | if (code < 0) |
69 | return gs_rethrow(code, "building color space object"); | 84 | return gs_rethrow(code, "building color space object"); |
70 | /* For now, dump the profile into a buffer | 85 | /* For now, dump the profile into a buffer |
@@ -198,18 +213,27 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff) | |||
198 | } | 213 | } |
199 | /* Have one increment from the color space. Having these tied | 214 | /* Have one increment from the color space. Having these tied |
200 | together is not really correct. Need to fix that. ToDo. MJV */ | 215 | together is not really correct. Need to fix that. ToDo. MJV */ |
201 | rc_adjust(picc_profile, -2, "seticc"); | 216 | rc_adjust(picc_profile, -2, "seticc"); /* NB: May free the profile and set picc_profile to 0 */ |
202 | rc_increment(pcs->cmm_icc_profile_data); | 217 | rc_increment(pcs->cmm_icc_profile_data); |
203 | } | 218 | } |
204 | /* Set the color space. We are done. No joint cache here... */ | 219 | /* Set the color space. We are done. */ |
205 | code = gs_setcolorspace(igs, pcs); | 220 | code = gs_setcolorspace(igs, pcs); |
206 | /* The context has taken a reference to the colorspace. We no longer need | 221 | /* The context has taken a reference to the colorspace. We no longer need |
207 | * ours, so drop it. */ | 222 | * ours, so drop it. */ |
208 | rc_decrement_only(pcs, "seticc"); | 223 | rc_decrement_only(pcs, "seticc"); |
209 | /* In this case, we already have a ref count of 2 on the icc profile | 224 | if (picc_profile != NULL) { |
210 | one for when it was created and one for when it was set. We really | 225 | /* In this case, we already have a ref count of 2 on the icc profile |
211 | only want one here so adjust */ | 226 | one for when it was created and one for when it was set. We really |
212 | rc_decrement(picc_profile,"seticc"); | 227 | only want one here so adjust */ |
228 | rc_decrement(picc_profile,"seticc"); | ||
229 | if (code >= 0) { | ||
230 | /* Save this colorspace in the iccprofile_cache */ | ||
231 | gsicc_add_cs(igs, pcs, picc_profile->hashcode); | ||
232 | /* should be an integer, but if for some reason it isn't, don't update */ | ||
233 | if (phashval && r_has_type(phashval, t_integer)) | ||
234 | phashval->value.intval = picc_profile->hashcode; | ||
235 | } | ||
236 | } | ||
213 | /* Remove the ICC dict from the stack */ | 237 | /* Remove the ICC dict from the stack */ |
214 | pop(1); | 238 | pop(1); |
215 | return code; | 239 | return code; |