diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-10-14 17:26:41 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-10-14 18:25:19 +0100 |
commit | 06fd5ef29b26bba0f6d8e6fa1034756737e12ef5 (patch) | |
tree | 6de5549d22bb8a9a74b524d95768ebbb04e2c8b6 /source/pdf | |
parent | 67cc9edf0cc0dc8ccf6ef419c96ab5087c914cae (diff) | |
download | mupdf-06fd5ef29b26bba0f6d8e6fa1034756737e12ef5.tar.xz |
Handle stroke+fill operations with transparency/blendmodes.
When stroking and filling in a single operation, we are supposed
to form the complete stroke+fill image, then blend it back, rather
than filling and blending, then stroking and blending.
This only matters during transparency, or with non-normal blend
modes.
We fix MuPDF to push a knockout group when doing such operations.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-interpret.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c index d7e3a021..ee6fcc45 100644 --- a/source/pdf/pdf-interpret.c +++ b/source/pdf/pdf-interpret.c @@ -531,6 +531,7 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) fz_path *path; fz_rect bbox; softmask_save softmask = { NULL }; + int knockout_group = 0; if (dostroke) { if (csi->dev->flags & (FZ_DEVFLAG_STROKECOLOR_UNDEFINED | FZ_DEVFLAG_LINEJOIN_UNDEFINED | FZ_DEVFLAG_LINEWIDTH_UNDEFINED)) @@ -568,6 +569,24 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) if (dofill || dostroke) pdf_begin_group(csi, &bbox, &softmask); + if (dofill && dostroke) + { + /* We may need to push a knockout group */ + if (gstate->stroke.alpha == 0) + { + /* No need for group, as stroke won't do anything */ + } + else if (gstate->stroke.alpha == 1.0f && gstate->blendmode == FZ_BLEND_NORMAL) + { + /* No need for group, as stroke won't show up */ + } + else + { + knockout_group = 1; + fz_begin_group(csi->dev, &bbox, 0, 1, FZ_BLEND_NORMAL, 1); + } + } + if (dofill) { switch (gstate->fill.kind) @@ -627,6 +646,9 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) } } + if (knockout_group) + fz_end_group(csi->dev); + if (dofill || dostroke) pdf_end_group(csi, &softmask); } |