diff options
author | Robin Watts <robin.watts@artifex.com> | 2017-08-09 14:34:36 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-10-24 15:16:36 +0100 |
commit | edcac9b62fd9034f3901c2b23467be9632c07b99 (patch) | |
tree | 2080e8cbcea824e2f7b52782e241954eb5ea48c6 /source/fitz/draw-device.c | |
parent | e9387d19a9e12ed5b4148059f9ae7c140274ab2e (diff) | |
download | mupdf-edcac9b62fd9034f3901c2b23467be9632c07b99.tar.xz |
Move to be more like Ghostscript in the handling of shapes.
When pushing a transparency group, MuPDF used to always create a shape
plane if there was one before. Ghostscript works differently, and
only creates a shape plane if we are in a non-isolated group.
This means that when blending an isolated group back to a non
isolated group, GS uses the "source alpha" in place of the "shape
alpha" to modify the non-isolated groups shape plane.
We update MuPDF to do the same here - it requires some new (small)
routines to do this new type of shape update, but means we carry
smaller amounts of data around overall.
Also, for what little remains of my sanities sake, this helps by
making it easier to compare the debug output from the 2 different
renderers.
Diffstat (limited to 'source/fitz/draw-device.c')
-rw-r--r-- | source/fitz/draw-device.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 85c0b7e3..27229108 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -2119,12 +2119,8 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs); } - if (blendmode == 0 && alpha == 1.0f && isolated) - { - /* We can render direct to any existing shape plane. - * If there isn't one, we don't need to make one. */ - state[1].shape = state[0].shape; - } + if (isolated) + state[1].shape = NULL; else { state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1); @@ -2212,17 +2208,21 @@ fz_draw_end_group(fz_context *ctx, fz_device *devp) else fz_blend_pixmap(ctx, state[0].dest, state[1].dest, alpha * 255, blendmode, isolated, state[1].shape); + assert(state[0].shape == NULL || state[0].shape != state[1].shape); + if (state[0].shape && state[0].shape != state[1].shape) + { + if (state[1].shape) + fz_paint_pixmap(state[0].shape, state[1].shape, alpha * 255); + else + fz_paint_pixmap_alpha(state[0].shape, state[1].dest, alpha * 255); + } + fz_drop_pixmap(ctx, state[1].shape); /* The following test should not be required, but just occasionally * errors can cause the stack to get out of sync, and this might save * our bacon. */ + assert(state[0].dest != state[1].dest); if (state[0].dest != state[1].dest) fz_drop_pixmap(ctx, state[1].dest); - if (state[0].shape != state[1].shape) - { - if (state[0].shape) - fz_paint_pixmap(state[0].shape, state[1].shape, alpha * 255); - fz_drop_pixmap(ctx, state[1].shape); - } #ifdef DUMP_GROUP_BLENDS fz_dump_blend(ctx, " to get ", state[0].dest); if (state[0].shape) |