[poppler] poppler/CairoOutputDev.cc
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Fri Aug 7 06:26:37 PDT 2009
poppler/CairoOutputDev.cc | 59 +++++++++++++++++++++++++++++-----------------
1 file changed, 38 insertions(+), 21 deletions(-)
New commits:
commit e4439ff527bb202d0239f78e647452983b733411
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Fri Aug 7 15:23:57 2009 +0200
[cairo] Don't apply masks when fill color space mode is csPattern
In that case the mask is used for clipping when drawing images. Fixes
bug #22216.
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index e86ee12..6e9874e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1321,11 +1321,15 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
cairo_matrix_scale (&matrix, width, -height);
cairo_pattern_set_matrix (pattern, &matrix);
- cairo_save (cairo);
- cairo_rectangle (cairo, 0., 0., 1., 1.);
- cairo_clip (cairo);
- cairo_mask (cairo, pattern);
- cairo_restore (cairo);
+ if (state->getFillColorSpace()->getMode() == csPattern) {
+ mask = cairo_pattern_reference (pattern);
+ } else {
+ cairo_save (cairo);
+ cairo_rectangle (cairo, 0., 0., 1., 1.);
+ cairo_clip (cairo);
+ cairo_mask (cairo, pattern);
+ cairo_restore (cairo);
+ }
if (cairo_shape) {
cairo_save (cairo_shape);
@@ -1572,24 +1576,32 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
interpolate ? CAIRO_FILTER_BEST : CAIRO_FILTER_FAST);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
- cairo_save (cairo);
+ if (state->getFillColorSpace()->getMode() == csPattern) {
+ cairo_matrix_init_translate (&matrix, 0, scaledHeight);
+ cairo_matrix_scale (&matrix, scaledWidth, -scaledHeight);
+ cairo_pattern_set_matrix (pattern, &matrix);
- /* modify our current transformation so that the prescaled image
- * goes where it is supposed to */
- cairo_get_matrix(cairo, &matrix);
- cairo_scale(cairo, 1.0/matrix.xx, 1.0/matrix.yy);
- // get integer co-ords
- cairo_translate (cairo, tx - matrix.x0, ty2 - matrix.y0);
- if (yScale > 0)
- cairo_scale(cairo, 1, -1);
+ mask = cairo_pattern_reference (pattern);
+ } else {
+ cairo_save (cairo);
- cairo_rectangle (cairo, 0., 0., scaledWidth, scaledHeight);
- cairo_clip (cairo);
- cairo_mask (cairo, pattern);
+ /* modify our current transformation so that the prescaled image
+ * goes where it is supposed to */
+ cairo_get_matrix(cairo, &matrix);
+ cairo_scale(cairo, 1.0/matrix.xx, 1.0/matrix.yy);
+ // get integer co-ords
+ cairo_translate (cairo, tx - matrix.x0, ty2 - matrix.y0);
+ if (yScale > 0)
+ cairo_scale(cairo, 1, -1);
+
+ cairo_rectangle (cairo, 0., 0., scaledWidth, scaledHeight);
+ cairo_clip (cairo);
+ cairo_mask (cairo, pattern);
- //cairo_get_matrix(cairo, &matrix);
- //printf("mask at: [%f %f], [%f %f], %f %f\n\n", matrix.xx, matrix.xy, matrix.yx, matrix.yy, matrix.x0, matrix.y0);
- cairo_restore(cairo);
+ //cairo_get_matrix(cairo, &matrix);
+ //printf("mask at: [%f %f], [%f %f], %f %f\n\n", matrix.xx, matrix.xy, matrix.yx, matrix.yy, matrix.x0, matrix.y0);
+ cairo_restore(cairo);
+ }
if (cairo_shape) {
cairo_save (cairo_shape);
@@ -1979,7 +1991,12 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
cairo_save (cairo);
cairo_set_source (cairo, pattern);
cairo_rectangle (cairo, 0., 0., 1., 1.);
- cairo_fill (cairo);
+ if (mask) {
+ cairo_clip (cairo);
+ cairo_mask (cairo, mask);
+ } else {
+ cairo_fill (cairo);
+ }
cairo_restore (cairo);
if (cairo_shape) {
More information about the poppler
mailing list