diff options
author | Igor Melichev <igor.melichev@artifex.com> | 2008-08-07 19:20:04 +0000 |
---|---|---|
committer | Igor Melichev <igor.melichev@artifex.com> | 2008-08-07 19:20:04 +0000 |
commit | 9fba7b97823998743e79d686204163ca4ffc622a (patch) | |
tree | 16b929d1194768687112155a361d02d961b25aa8 /gs/src/gxclpath.c | |
parent | b1fa0d7430800e3c2cd358c6abec210e380c6f2b (diff) |
Fix (graphics) : Redundant patterns in clist (continued),
DETAILS :
Bug 689995 "segfault with 09-34.PS"
1. (the bug fix) A recent patch doesn't account patterns with no tile,
which represent an empty pattern.
This change inserts checks for empty tiles
and process them with no optimization (redundantly),
because they are small and are not cached.
See comments in code.
2. pcls->band_complexity.uses_color accummulated a pattern address bits instead
a real data. This bug was introduced when serializing colors to clist.
nevertheless this bug has no visible effect because 'pure' is overlayed with
a tile address, which can't be equal to 0 or 0xffffff.
So formally this part of the change is algorithmically equivalent,
but it is important for redability.
Note that when serializing a pattern to clist, 'uses_color' is not properly
computed and needs further development. see new bug 689997.
Minor change : removed the second call to gs_dc_get_pattern_id for a faster code.
EXPECTED DIFFERENCES :
None.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@8952 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/src/gxclpath.c')
-rw-r--r-- | gs/src/gxclpath.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/gs/src/gxclpath.c b/gs/src/gxclpath.c index eee39f007..45533a2f2 100644 --- a/gs/src/gxclpath.c +++ b/gs/src/gxclpath.c @@ -111,7 +111,8 @@ cmd_put_drawing_color(gx_device_clist_writer * cldev, gx_clist_state * pcls, int left; uint portion_size, prefix_size; int req_size_final; - bool is_pattern; + bool is_pattern; + gs_id pattern_id = gs_no_id; /* see if the halftone must be inserted in the command list */ if ( pdht != NULL && @@ -157,12 +158,15 @@ cmd_put_drawing_color(gx_device_clist_writer * cldev, gx_clist_state * pcls, is_pattern = gx_dc_is_pattern1_color(pdcolor); if (is_pattern) { - gs_id id = gs_dc_get_pattern_id(pdcolor); + pattern_id = gs_dc_get_pattern_id(pdcolor); - if (pcls->pattern_id == id) { + if (pattern_id != gs_no_id && pcls->pattern_id == pattern_id) { /* The pattern is known, write its id only. - Note gx_dc_pattern_write must process this case especially. */ - left = sizeof(id); + Note that gx_dc_pattern_write must process this case especially. */ + /* Note that id is gs_no_id when the pattern supplies an empty tile. + In this case the full serialized pattern is shorter (left == 0), + so go with it. */ + left = sizeof(pattern_id); } } @@ -204,12 +208,18 @@ cmd_put_drawing_color(gx_device_clist_writer * cldev, gx_clist_state * pcls, /* should properly calculate colors_used, but for now just punt */ pcls->colors_used.or = ((gx_color_index)1 << cldev->color_info.depth) - 1; - pcls->band_complexity.uses_color |= (pdcolor->colors.pure != 0 && pdcolor->colors.pure != 0xffffff); + /* Here we can't know whether a pattern paints colors besides + black and white, so assume that it does. + todo: provide this info with a pattern tile. */ + pcls->band_complexity.uses_color |= is_pattern || + (pdcolor->colors.pure != 0 && pdcolor->colors.pure != 0xffffff); /* record the color we have just serialized color */ pdcolor->type->save_dc(pdcolor, &pcls->sdc); - if (is_pattern) - pcls->pattern_id = gs_dc_get_pattern_id(pdcolor); + if (pattern_id) { + /* Don't record empty tiles because they're not cached. */ + pcls->pattern_id = pattern_id; + } return code; } |