diff options
Diffstat (limited to 'pdf/pdf_pattern.c')
-rw-r--r-- | pdf/pdf_pattern.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/pdf/pdf_pattern.c b/pdf/pdf_pattern.c index 57a16449..b4bd0375 100644 --- a/pdf/pdf_pattern.c +++ b/pdf/pdf_pattern.c @@ -114,35 +114,12 @@ static void pdfi_free_pattern_context(pdf_pattern_context_t *context) gs_free_object(context->ctx->memory, context, "Free pattern context"); } -static bool -pdfi_pattern_purge_proc(gx_color_tile * ctile, void *proc_data) -{ - if (ctile->id == *((gx_bitmap_id *)proc_data)) - return true; - return false; -} - void pdfi_pattern_cleanup(gs_memory_t * mem, void *p) { gs_pattern1_instance_t *pinst = (gs_pattern1_instance_t *)p; - pdf_pattern_context_t *context; - gx_color_tile *pctile = NULL; - - context = (pdf_pattern_context_t *)pinst->client_data; - /* If are being called from Ghostscript, the clist pattern accumulator device (in - the tile cache) *can* outlast outlast our pattern instance, so if the pattern - instance is being freed, also remove the entry from the cache - */ - if (context != NULL && context->ctx != NULL && context->ctx->pgs != NULL && - context->shading == NULL && context->ctx->pgs->pattern_cache != NULL - && gx_pattern_cache_get_entry(context->ctx->pgs, pinst->id, &pctile) == 0 - && gx_pattern_tile_is_clist(pctile)) { - gx_pattern_cache_winnow(gstate_pattern_cache(context->ctx->pgs), pdfi_pattern_purge_proc, (void *)(&pctile->id)); - } - - if (context != NULL) { - pdfi_free_pattern_context(context); + if (pinst->client_data != NULL) { + pdfi_free_pattern_context((pdf_pattern_context_t *)pinst->client_data); pinst->client_data = NULL; pinst->notify_free = NULL; } @@ -418,7 +395,7 @@ pdfi_setpattern_type1(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_di gs_pattern1_init(&templat); /* Must be a stream */ - if (stream->type != PDF_STREAM) { + if (pdfi_type_of(stream) != PDF_STREAM) { code = gs_note_error(gs_error_typecheck); goto exit; } @@ -525,6 +502,28 @@ pdfi_setpattern_type1(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_di cc->pattern->client_data = context; cc->pattern->notify_free = pdfi_pattern_cleanup; + { + unsigned long hash = 5381; + unsigned int i; + const char *str = (const char *)&ctx->pgs->ctm; + + gs_pattern1_instance_t *pinst = (gs_pattern1_instance_t *)cc->pattern; + + + for (i = 0; i < 4 * sizeof(float); i++) + hash = ((hash << 5) + hash) + str[i]; /* hash * 33 + c */ + + str = (const char *)&pdict->object_num; + for (i = 0; i < sizeof(uint32_t); i++) + hash = ((hash << 5) + hash) + str[i]; /* hash * 33 + c */ + + hash = ((hash << 5) + hash) + ctx->pgs->device->color_info.num_components; /* hash * 33 + c */ + + /* Include num_components for case where we have softmask and non-softmask + fills with the same tile. We may need two tiles for this if there is a + change in color space for the transparency group. */ + pinst->id = hash; + } context = NULL; code = pdfi_grestore(ctx); |