[poppler] poppler/CairoOutputDev.cc

2023-01-26 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 06a0e17bd9387da0a9737f6ce945482930d98341
Author: Albert Astals Cid 
Date:   Thu Jan 26 19:07:58 2023 +0100

Update (C)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2c0e0672..beb92c25 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -37,6 +37,7 @@
 // Copyright (C) 2021 Uli Schlachter 
 // Copyright (C) 2021 Christian Persch 
 // Copyright (C) 2022 Zachary Travis 
+// Copyright (C) 2023 Artemy Gordon 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git


[poppler] poppler/CairoOutputDev.cc

2023-01-26 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |   47 +-
 1 file changed, 42 insertions(+), 5 deletions(-)

New commits:
commit 1327646900994c033155100adf7bbaad7654ff50
Author: Artemy Gordon 
Date:   Thu Jan 26 18:01:09 2023 +

Add handling matte entry in cairo backend

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 946cb1a4..2c0e0672 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2763,12 +2763,35 @@ cleanup:
 delete imgStr;
 }
 
+static inline void getMatteColorRgb(GfxImageColorMap *colorMap, const GfxColor 
*matteColorIn, GfxRGB *matteColorRgb)
+{
+colorMap->getColorSpace()->getRGB(matteColorIn, matteColorRgb);
+matteColorRgb->r = colToByte(matteColorRgb->r);
+matteColorRgb->g = colToByte(matteColorRgb->g);
+matteColorRgb->b = colToByte(matteColorRgb->b);
+}
+
+static inline void applyMask(unsigned int *imagePointer, int length, GfxRGB 
matteColor, unsigned char *alphaPointer)
+{
+unsigned char *p, r, g, b;
+int i;
+
+for (i = 0, p = (unsigned char *)imagePointer; i < length; i++, p += 4, 
alphaPointer++) {
+if (*alphaPointer) {
+b = std::clamp(matteColor.b + (int)(p[0] - matteColor.b) * 255 / 
*alphaPointer, 0, 255);
+g = std::clamp(matteColor.g + (int)(p[1] - matteColor.g) * 255 / 
*alphaPointer, 0, 255);
+r = std::clamp(matteColor.r + (int)(p[2] - matteColor.r) * 255 / 
*alphaPointer, 0, 255);
+imagePointer[i] = (r << 16) | (g << 8) | (b << 0);
+}
+}
+}
+
 // XXX: is this affect by AIS(alpha is shape)?
 void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream 
*str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, 
Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap,
  bool maskInterpolate)
 {
 ImageStream *maskImgStr, *imgStr;
-ptrdiff_t row_stride;
+ptrdiff_t row_stride, mask_row_stride;
 unsigned char *maskBuffer, *buffer;
 unsigned char *maskDest;
 unsigned int *dest;
@@ -2779,6 +2802,12 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState 
*state, Object *ref, Stream *s
 int y;
 cairo_filter_t filter;
 cairo_filter_t maskFilter;
+GfxRGB matteColorRgb;
+
+const GfxColor *matteColor = maskColorMap->getMatteColor();
+if (matteColor != nullptr) {
+getMatteColorRgb(colorMap, matteColor, );
+}
 
 maskImgStr = new ImageStream(maskStr, maskWidth, 
maskColorMap->getNumPixelComps(), maskColorMap->getBits());
 maskImgStr->reset();
@@ -2791,9 +2820,9 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, 
Object *ref, Stream *s
 }
 
 maskBuffer = cairo_image_surface_get_data(maskImage);
-row_stride = cairo_image_surface_get_stride(maskImage);
+mask_row_stride = cairo_image_surface_get_stride(maskImage);
 for (y = 0; y < maskHeight; y++) {
-maskDest = (unsigned char *)(maskBuffer + y * row_stride);
+maskDest = (unsigned char *)(maskBuffer + y * mask_row_stride);
 pix = maskImgStr->getLine();
 if (likely(pix != nullptr)) {
 maskColorMap->getGrayLine(pix, maskDest, maskWidth);
@@ -2835,14 +2864,22 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState 
*state, Object *ref, Stream *s
 for (y = 0; y < height; y++) {
 dest = reinterpret_cast(buffer + y * row_stride);
 pix = imgStr->getLine();
-colorMap->getRGBLine(pix, dest, width);
+if (likely(pix != nullptr)) {
+colorMap->getRGBLine(pix, dest, width);
+if (matteColor != nullptr) {
+maskDest = (unsigned char *)(maskBuffer + y * mask_row_stride);
+applyMask(dest, width, matteColorRgb, maskDest);
+}
+}
 }
 
 filter = getFilterForSurface(image, interpolate);
 
 cairo_surface_mark_dirty(image);
 
-setMimeData(state, str, ref, colorMap, image, height);
+if (matteColor == nullptr) {
+setMimeData(state, str, ref, colorMap, image, height);
+}
 
 pattern = cairo_pattern_create_for_surface(image);
 cairo_surface_destroy(image);


[poppler] poppler/CairoOutputDev.cc

2022-12-30 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 43e2da4ade60f7e6c62b4d70f15d603327ca7b2b
Author: Albert Astals Cid 
Date:   Fri Dec 30 23:49:15 2022 +0100

Update (C)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2f7ca093..91c05bc5 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -36,6 +36,7 @@
 // Copyright (C) 2020, 2022 Oliver Sander 
 // Copyright (C) 2021 Uli Schlachter 
 // Copyright (C) 2021 Christian Persch 
+// Copyright (C) 2022 Zachary Travis 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git


[poppler] poppler/CairoOutputDev.cc

2022-12-30 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 7d14f465a6441f3df4389df375b154687e1fdb6b
Author: Zachary Travis 
Date:   Fri Aug 13 20:33:35 2021 -0700

Ignore text rendering mode for type3 fonts

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a72c218a..2f7ca093 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1536,6 +1536,12 @@ void CairoOutputDev::endString(GfxState *state)
 goto finish;
 }
 
+if (state->getFont()->getType() == fontType3 && render != 7) {
+// If the current font is a type 3 font, we should ignore the text 
rendering mode
+// (and use the default of 0) as long as we are going to either fill 
or stroke.
+render = 0;
+}
+
 if (!(render & 1)) {
 LOG(printf("fill string\n"));
 cairo_set_source(cairo, fill_pattern);


[poppler] poppler/CairoOutputDev.cc poppler/GfxState.h

2022-05-12 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |2 +-
 poppler/GfxState.h|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit cf5034d83593dae25890d8cb58159491683629f6
Author: Albert Astals Cid 
Date:   Thu May 12 22:35:33 2022 +0200

Update (C)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index e7dbe463..5437687d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2005 Nickolay V. Shmyrev 
 // Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos 

 // Copyright (C) 2008 Carl Worth 
-// Copyright (C) 2008-2018, 2021 Adrian Johnson 
+// Copyright (C) 2008-2018, 2021, 2022 Adrian Johnson 
 // Copyright (C) 2008 Michael Vrable 
 // Copyright (C) 2008, 2009 Chris Wilson 
 // Copyright (C) 2008, 2012 Hib Eris 
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 3ae1550b..08492df6 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -22,7 +22,7 @@
 // Copyright (C) 2011 Andrea Canciani 
 // Copyright (C) 2011-2014, 2016, 2020 Thomas Freitag 
 // Copyright (C) 2013 Lu Wang 
-// Copyright (C) 2015, 2017, 2020 Adrian Johnson 
+// Copyright (C) 2015, 2017, 2020, 2022 Adrian Johnson 
 // Copyright (C) 2017, 2019, 2022 Oliver Sander 
 // Copyright (C) 2018 Adam Reichold 
 // Copyright (C) 2020, 2021 Philipp Knechtges 


[poppler] poppler/CairoOutputDev.cc

2021-11-06 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 89beb709b39f6b9645f27e7390b2464c5864c43b
Author: Albert Astals Cid 
Date:   Sun Nov 7 00:43:04 2021 +0100

Update (C)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 3967bd94..e44a41dd 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2005 Nickolay V. Shmyrev 
 // Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos 

 // Copyright (C) 2008 Carl Worth 
-// Copyright (C) 2008-2018 Adrian Johnson 
+// Copyright (C) 2008-2018, 2021 Adrian Johnson 
 // Copyright (C) 2008 Michael Vrable 
 // Copyright (C) 2008, 2009 Chris Wilson 
 // Copyright (C) 2008, 2012 Hib Eris 


[poppler] poppler/CairoOutputDev.cc

2021-11-06 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |   34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit 0e8d7d11838dc16cdc6141c026def43710c8b326
Author: Adrian Johnson 
Date:   Mon Oct 4 07:42:38 2021 +1030

Fix de-duping of Flate images

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 5f4780c7..3967bd94 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2886,10 +2886,24 @@ void CairoOutputDev::setMimeData(GfxState *state, 
Stream *str, Object *ref, GfxI
 GfxColorSpace *colorSpace;
 StreamKind strKind = str->getKind();
 const char *mime_type;
+cairo_status_t status;
 
 if (!printing)
 return;
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
+// Since 1.5.10 the cairo PS backend stores images with UNIQUE_ID in PS 
memory so the
+// image can be re-used multiple times. As we don't know how large the 
images are or
+// how many times they are used, there is no benefit in enabling this. 
Issue #106
+if (cairo_surface_get_type(cairo_get_target(cairo)) != 
CAIRO_SURFACE_TYPE_PS) {
+if (ref && ref->isRef()) {
+status = setMimeIdFromRef(image, CAIRO_MIME_TYPE_UNIQUE_ID, 
"poppler-surface-", ref->getRef());
+if (status)
+return;
+}
+}
+#endif
+
 switch (strKind) {
 case strDCT:
 mime_type = CAIRO_MIME_TYPE_JPEG;
@@ -2908,7 +2922,8 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream 
*str, Object *ref, GfxI
 break;
 #endif
 default:
-return;
+mime_type = nullptr;
+break;
 }
 
 obj = str->getDict()->lookup("ColorSpace");
@@ -2954,22 +2969,9 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream 
*str, Object *ref, GfxI
 return;
 #endif
 
-if (getStreamData(str->getNextStream(), , )) {
-cairo_status_t status = CAIRO_STATUS_SUCCESS;
-
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
-// Since 1.5.10 the cairo PS backend stores images with UNIQUE_ID in 
PS memory so the
-// image can be re-used multiple times. As we don't know how large the 
images are or
-// how many times they are used, there is no benefit in enabling this. 
Issue #106
-if (cairo_surface_get_type(cairo_get_target(cairo)) != 
CAIRO_SURFACE_TYPE_PS) {
-if (ref && ref->isRef()) {
-status = setMimeIdFromRef(image, CAIRO_MIME_TYPE_UNIQUE_ID, 
"poppler-surface-", ref->getRef());
-}
-}
-#endif
-if (!status) {
+if (mime_type) {
+if (getStreamData(str->getNextStream(), , ))
 status = cairo_surface_set_mime_data(image, mime_type, (const 
unsigned char *)strBuffer, len, gfree, strBuffer);
-}
 
 if (status)
 gfree(strBuffer);


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h utils/HtmlOutputDev.cc utils/pdftocairo.cc

2021-11-01 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |1 +
 poppler/CairoOutputDev.h  |1 +
 utils/HtmlOutputDev.cc|1 +
 utils/pdftocairo.cc   |1 +
 4 files changed, 4 insertions(+)

New commits:
commit 33c9b192ac32e7e95a825aa3ff4e18561f0dc80b
Author: Albert Astals Cid 
Date:   Mon Nov 1 11:31:49 2021 +0100

Update (C)

chpe's ones are from the cairo_t commit last month

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 93975609..5f4780c7 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -35,6 +35,7 @@
 // Copyright (C) 2020 Michal 
 // Copyright (C) 2020 Oliver Sander 
 // Copyright (C) 2021 Uli Schlachter 
+// Copyright (C) 2021 Christian Persch 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 04e71451..9a3bb7dc 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -26,6 +26,7 @@
 // Copyright (C) 2018, 2019, 2021 Albert Astals Cid 
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2020 Michal 
+// Copyright (C) 2021 Christian Persch 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index 9e832bc8..7564b3e4 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -45,6 +45,7 @@
 // Copyright (C) 2018-2020 Adam Reichold 
 // Copyright (C) 2019, 2020 Oliver Sander 
 // Copyright (C) 2020 Eddie Kohler 
+// Copyright (C) 2021 Christopher Hasse 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 342ca213..d6ba0e62 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -38,6 +38,7 @@
 // Copyright (C) 2020 Philipp Knechtges 
 // Copyright (C) 2020 Salvo Miosi 
 // Copyright (C) 2021 Peter Williams 
+// Copyright (C) 2021 Christian Persch 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h utils/pdftocairo.cc

2021-10-01 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |   26 +++---
 poppler/CairoOutputDev.h  |4 +---
 utils/pdftocairo.cc   |   10 +-
 3 files changed, 17 insertions(+), 23 deletions(-)

New commits:
commit e0a0f50a278df6bc1d3618e685494244d7139783
Author: Christian Persch 
Date:   Thu Sep 30 16:38:42 2021 +0200

poppler: cairo: Don't override the antialias settings from the cairo_t

This partially reverts commit 853e9499, which made CairoOutputDev store
the antialias setting, and applying it to its cairo context.

Instead, just copy the antialias (and font antialias) setting from the
passed cairo context to newly created contexts.  That way, the application
can control the antialias settings.

Use this in pdftocairo to implement its -antialias option.

Fixes: https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/282
https://bugs.freedesktop.org/show_bug.cgi?id=94977
https://gitlab.freedesktop.org/poppler/poppler/merge_requests/89

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2cfcb79d..e3606418 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -154,7 +154,6 @@ CairoOutputDev::CairoOutputDev()
 inType3Char = false;
 t3_glyph_has_bbox = false;
 text_matrix_valid = true;
-antialias = CAIRO_ANTIALIAS_DEFAULT;
 
 groupColorSpaceStack = nullptr;
 maskStack = nullptr;
@@ -216,7 +215,6 @@ void CairoOutputDev::setCairo(cairo_t *c)
 /* save the initial matrix so that we can use it for type3 fonts. */
 // XXX: is this sufficient? could we miss changes to the matrix 
somehow?
 cairo_get_matrix(cairo, _matrix);
-setContextAntialias(cairo, antialias);
 } else {
 cairo = nullptr;
 cairo_shape = nullptr;
@@ -239,22 +237,12 @@ void CairoOutputDev::setTextPage(TextPage *text)
 }
 }
 
-void CairoOutputDev::setAntialias(cairo_antialias_t a)
+void CairoOutputDev::copyAntialias(cairo_t *cr, cairo_t *source_cr)
 {
-antialias = a;
-if (cairo)
-setContextAntialias(cairo, antialias);
-if (cairo_shape)
-setContextAntialias(cairo_shape, antialias);
-}
+cairo_set_antialias(cr, cairo_get_antialias(source_cr));
 
-void CairoOutputDev::setContextAntialias(cairo_t *cr, cairo_antialias_t 
antialias)
-{
-cairo_font_options_t *font_options;
-cairo_set_antialias(cr, antialias);
-font_options = cairo_font_options_create();
-cairo_get_font_options(cr, font_options);
-cairo_font_options_set_antialias(font_options, antialias);
+cairo_font_options_t *font_options = cairo_font_options_create();
+cairo_get_font_options(source_cr, font_options);
 cairo_set_font_options(cr, font_options);
 cairo_font_options_destroy(font_options);
 }
@@ -941,7 +929,7 @@ bool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx 
*gfxA, Catalog *cat,
 old_cairo = cairo;
 cairo = cairo_create(surface);
 cairo_surface_destroy(surface);
-setContextAntialias(cairo, antialias);
+copyAntialias(cairo, old_cairo);
 
 box.x1 = bbox[0];
 box.y1 = bbox[1];
@@ -1623,7 +1611,7 @@ void CairoOutputDev::beginTransparencyGroup(GfxState * 
/*state*/, const double *
 cairo_surface_t *cairo_shape_surface = 
cairo_surface_create_similar_clip(cairo, CAIRO_CONTENT_ALPHA);
 cairo_shape = cairo_create(cairo_shape_surface);
 cairo_surface_destroy(cairo_shape_surface);
-setContextAntialias(cairo_shape, antialias);
+copyAntialias(cairo_shape, cairo);
 
 /* the color doesn't matter as long as it is opaque */
 cairo_set_source_rgb(cairo_shape, 0, 0, 0);
@@ -1778,7 +1766,7 @@ void CairoOutputDev::setSoftMask(GfxState *state, const 
double *bbox, bool alpha
 
 cairo_surface_t *source = 
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
 cairo_t *maskCtx = cairo_create(source);
-setContextAntialias(maskCtx, antialias);
+copyAntialias(maskCtx, cairo);
 
 // XXX: hopefully this uses the correct color space */
 if (!alpha && groupColorSpaceStack->cs) {
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index dc101e22..04e71451 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -238,7 +238,7 @@ public:
 printing = printingA;
 needFontUpdate = true;
 }
-void setAntialias(cairo_antialias_t antialias);
+void copyAntialias(cairo_t *cr, cairo_t *source_cr);
 
 void setInType3Char(bool inType3CharA) { inType3Char = inType3CharA; }
 void getType3GlyphWidth(double *wx, double *wy)
@@ -264,7 +264,6 @@ protected:
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
 bool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int 
height);
 #endif
-static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
 
 GfxRGB fill_color, stroke_color;
 cairo_pattern_t 

[poppler] poppler/CairoOutputDev.cc

2021-07-01 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |4 
 1 file changed, 4 insertions(+)

New commits:
commit 571d8138cb9ccc9ac04219a6a552d8c78e93ad88
Author: Uli Schlachter 
Date:   Sat Jun 26 12:00:50 2021 +0200

~CairoOutputDev(): Free textClipPath

The textClipPath member is set in CairoOutputDev::endString() and freed
in CairoOutputDev::endTextObject(). However, if endTextObject() is not
called for whatever reason, the path will just be leaked.

This adds code to the destructor to free this.

This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32326

Testing done:

$ wget -O testcase 
'https://oss-fuzz.com/download?testcase_id=6659952325296128'
[...]
$ cmake .. -G Ninja -DENABLE_DCTDECODER=unmaintained -DENABLE_BOOST=OFF 
-DENABLE_LIBOPENJPEG=unmaintained && ninja
[...]
$ git describe
poppler-21.06.1-5-gb7c40059
$ valgrind --leak-check=full ./utils/pdftocairo testcase -png foo
[...]
==104075==
==104075== HEAP SUMMARY:
==104075== in use at exit: 28,292 bytes in 55 blocks
==104075==   total heap usage: 6,114 allocs, 6,059 frees, 1,617,444 bytes 
allocated
==104075==
==104075== 24 bytes in 1 blocks are definitely lost in loss record 4 of 37
==104075==at 0x483877F: malloc (in 
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==104075==by 0x48AE748: ??? (in 
/usr/lib/x86_64-linux-gnu/libcairo.so.2.11600.0)
==104075==by 0x118995: endString (CairoOutputDev.cc:1474)
==104075==by 0x118995: CairoOutputDev::endString(GfxState*) 
(CairoOutputDev.cc:1412)
==104075==by 0x4B97295: Gfx::doShowText(GooString const*) (Gfx.cc:4010)
==104075==by 0x4B97CB4: Gfx::opShowSpaceText(Object*, int) (Gfx.cc:3793)
==104075==by 0x4B8D866: Gfx::go(bool) (Gfx.cc:681)
==104075==by 0x4B8DCFA: display (Gfx.cc:642)
==104075==by 0x4B8DCFA: Gfx::display(Object*, bool) (Gfx.cc:622)
==104075==by 0x4BE1A83: Page::displaySlice(OutputDev*, double, double, 
int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool 
(*)(Annot*, void*), void*, bool) (Page.cc:576)
==104075==by 0x11317C: renderPage (pdftocairo.cc:669)
==104075==by 0x11317C: main (pdftocairo.cc:1183)
==104075==
==104075== LEAK SUMMARY:
==104075==definitely lost: 24 bytes in 1 blocks
==104075==indirectly lost: 0 bytes in 0 blocks
==104075==  possibly lost: 0 bytes in 0 blocks
==104075==still reachable: 28,268 bytes in 54 blocks
==104075== suppressed: 0 bytes in 0 blocks
==104075== Reachable blocks (those to which a pointer was found) are not 
shown.
==104075== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==104075==
==104075== For lists of detected and suppressed errors, rerun with: -s
==104075== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
$ git checkout cairo-leak-textClipPath && git describe && ninja
Zu Branch 'cairo-leak-textClipPath' gewechselt
poppler-21.06.1-6-g8df6f8d2
$ valgrind --leak-check=full ./utils/pdftocairo testcase -png foo
[...]
==104263==
==104263== HEAP SUMMARY:
==104263== in use at exit: 28,268 bytes in 54 blocks
==104263==   total heap usage: 6,114 allocs, 6,060 frees, 1,617,444 bytes 
allocated
==104263==
==104263== LEAK SUMMARY:
==104263==definitely lost: 0 bytes in 0 blocks
==104263==indirectly lost: 0 bytes in 0 blocks
==104263==  possibly lost: 0 bytes in 0 blocks
==104263==still reachable: 28,268 bytes in 54 blocks
==104263== suppressed: 0 bytes in 0 blocks
==104263== Reachable blocks (those to which a pointer was found) are not 
shown.
==104263== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==104263==
==104263== For lists of detected and suppressed errors, rerun with: -s
==104263== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

As you (might) see, before this commit, there is a "definitely lost"
leak of 24 bytes with this test case. After this commit, this leak is
gone.

Signed-off-by: Uli Schlachter 

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index aa68c6cd..87170849 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -179,6 +179,10 @@ CairoOutputDev::~CairoOutputDev()
 if (fontEngine_owner && fontEngine) {
 delete fontEngine;
 }
+if (textClipPath) {
+cairo_path_destroy(textClipPath);
+textClipPath = nullptr;
+}
 
 if (cairo)
 cairo_destroy(cairo);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2020-05-13 Thread GitLab Mirror
Rebased ref, commits from common ancestor:
commit 0f01638f044c247c2591f873f9f7558ed3c3b4ce
Author: Albert Astals Cid 
Date:   Wed May 13 23:12:43 2020 +0200

Update (C)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 231b9ab2..83f1c78d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -31,7 +31,7 @@
 // Copyright (C) 2015 Suzuki Toshiya 
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018, 2020 Adam Reichold 
-// Copyright (C) 2019 Marek Kasik 
+// Copyright (C) 2019, 2020 Marek Kasik 
 // Copyright (C) 2020 Michal 
 // Copyright (C) 2020 Oliver Sander 
 //
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2020-05-13 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |   20 
 1 file changed, 20 insertions(+)

New commits:
commit 9c3b18b8741f6e68711ce807459504493d6a0be0
Author: Marek Kasik 
Date:   Fri Apr 6 15:06:46 2018 +0200

cairo: Fix tiling patterns when pattern cell is too far

Rendering of tiling pattern which has pattern matrix moving pattern cell
far away can fail on allocation of memory. This commit solves the issue by
modifying of cairo pattern matrix so that its offset is closer to the path
filled by the pattern.

Fixes #190

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 63e49c7a..231b9ab2 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -973,6 +973,26 @@ bool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat,
   if (cairo_pattern_status (pattern))
 return false;
 
+  // Cairo can fail if the pattern translation is too large. Fix by making the
+  // translation smaller.
+  const double det = pmat[0] * pmat[3] - pmat[1] * pmat[2];
+
+  // Find the number of repetitions of pattern we need to shift by. Transform
+  // the translation component of pmat (pmat[4] and pmat[5]) into the pattern's
+  // coordinate system by multiplying by inverse of pmat, then divide by
+  // pattern size (xStep and yStep).
+  const double xoffset = round ((pmat[3] * pmat[4] - pmat[2] * pmat[5]) / 
(xStep * det));
+  const double yoffset = - round ((pmat[1] * pmat[4] - pmat[0] * pmat[5]) / 
(yStep * det));
+
+  if (!std::isfinite(xoffset) || !std::isfinite(yoffset)) {
+error(errSyntaxWarning, -1, "CairoOutputDev: Singular matrix in 
tilingPatternFill");
+return false;
+  }
+
+  // Shift pattern_matrix by multiples of the pattern size.
+  pattern_matrix.x0 -= xoffset * pattern_matrix.xx * xStep + yoffset * 
pattern_matrix.xy * yStep;
+  pattern_matrix.y0 -= xoffset * pattern_matrix.yx * xStep + yoffset * 
pattern_matrix.yy * yStep;
+
   state->getUserClipBBox(, , , );
   cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2020-01-04 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |7 ++-
 poppler/CairoOutputDev.h  |2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)

New commits:
commit 9e15cbae552be5a7b787a07e661ab849427537aa
Author: Michal 
Date:   Sat Jan 4 21:49:29 2020 +

make FT_Library initialisation thread-safe

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 52b05cd4..2302f082 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -118,15 +118,12 @@ void CairoImage::setImage (cairo_surface_t *i) {
 // FT_Library instance; to avoid leaks, just use a single global instance
 // initialized the first time it is needed.
 FT_Library CairoOutputDev::ft_lib;
-bool CairoOutputDev::ft_lib_initialized = false;
+std::once_flag CairoOutputDev::ft_lib_once_flag;
 
 CairoOutputDev::CairoOutputDev() {
   doc = nullptr;
 
-  if (!ft_lib_initialized) {
-FT_Init_FreeType(_lib);
-ft_lib_initialized = true;
-  }
+  std::call_once(ft_lib_once_flag, FT_Init_FreeType, _lib);
 
   fontEngine = nullptr;
   fontEngine_owner = false;
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 9da5322b..537560f6 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -320,7 +320,7 @@ protected:
   PDFDoc *doc; // the current document
 
   static FT_Library ft_lib;
-  static bool ft_lib_initialized;
+  static std::once_flag ft_lib_once_flag;
 
   CairoFontEngine *fontEngine;
   bool fontEngine_owner;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/GfxState.cc poppler/GfxState.h poppler/PSOutputDev.cc poppler/PSOutputDev.h poppler/SplashOutputDev.cc poppler/Splas

2019-11-22 Thread GitLab Mirror
 poppler/CairoOutputDev.cc  |7 +-
 poppler/CairoOutputDev.h   |4 -
 poppler/Gfx.cc |6 +-
 poppler/GfxState.cc|   42 +++---
 poppler/GfxState.h |  129 ++---
 poppler/PSOutputDev.cc |   12 +---
 poppler/PSOutputDev.h  |2 
 poppler/SplashOutputDev.cc |5 -
 poppler/SplashOutputDev.h  |2 
 poppler/TextOutputDev.cc   |   12 +---
 qt5/src/ArthurOutputDev.cc |5 -
 11 files changed, 109 insertions(+), 117 deletions(-)

New commits:
commit 064bbe4be40300739ce8352658e4883534442128
Author: Albert Astals Cid 
Date:   Sat Nov 23 08:13:21 2019 +0100

Add some const to GfxState & friends

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index cbfd0bdd..28f3ae6b 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -712,7 +712,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
 
 /* Align stroke coordinate i if the point is the start or end of a
  * horizontal or vertical line */
-void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, 
double *y)
+void CairoOutputDev::alignStrokeCoords(const GfxSubpath *subpath, int i, 
double *x, double *y)
 {
   double x1, y1, x2, y2;
   bool align = false;
@@ -752,13 +752,12 @@ void CairoOutputDev::alignStrokeCoords(GfxSubpath 
*subpath, int i, double *x, do
 
 #undef STROKE_COORD_TOLERANCE
 
-void CairoOutputDev::doPath(cairo_t *c, GfxState *state, GfxPath *path) {
-  GfxSubpath *subpath;
+void CairoOutputDev::doPath(cairo_t *c, GfxState *state, const GfxPath *path) {
   int i, j;
   double x, y;
   cairo_new_path (c);
   for (i = 0; i < path->getNumSubpaths(); ++i) {
-subpath = path->getSubpath(i);
+const GfxSubpath *subpath = path->getSubpath(i);
 if (subpath->getNumPoints() > 0) {
   if (align_stroke_coords) {
 alignStrokeCoords(subpath, 0, , );
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 4bef6df7..9e6f497c 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -274,7 +274,7 @@ public:
   double *getType3GlyphBBox () { return t3_glyph_bbox; }
 
 protected:
-  void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
+  void doPath(cairo_t *cairo, GfxState *state, const GfxPath *path);
   cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface);
   void getScaledSize(const cairo_matrix_t *matrix,
  int orig_width, int orig_height,
@@ -285,7 +285,7 @@ protected:
   void setMimeData(GfxState *state, Stream *str, Object *ref,
   GfxImageColorMap *colorMap, cairo_surface_t *image, int 
height);
   void fillToStrokePathClip(GfxState *state);
-  void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
+  void alignStrokeCoords(const GfxSubpath *subpath, int i, double *x, double 
*y);
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
   bool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
 #endif
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c5d47443..e8da5038 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4350,9 +4350,9 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg) {
   char *tempIntent = nullptr;
   Object objIntent = dict->lookup("Intent");
   if (objIntent.isName()) {
-tempIntent = state->getRenderingIntent();
-if (tempIntent != nullptr) {
-  tempIntent = strdup(tempIntent);
+const char *stateIntent = state->getRenderingIntent();
+if (stateIntent != nullptr) {
+  tempIntent = strdup(stateIntent);
 }
 state->setRenderingIntent(objIntent.getName());
   }
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index b7347d35..c2851d32 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -437,7 +437,7 @@ void 
GfxColorSpace::createMapping(std::vector *separat
 }
 
 void GfxColorSpace::getDefaultRanges(double *decodeLow, double *decodeRange,
-int maxImgPixel) {
+int maxImgPixel) const {
   int i;
 
   for (i = 0; i < getNComps(); ++i) {
@@ -733,7 +733,7 @@ void GfxDeviceGrayColorSpace::getDeviceN(const GfxColor 
*color, GfxColor *device
   deviceN->c[3] = clip01(gfxColorComp1 - color->c[0]);
 }
 
-void GfxDeviceGrayColorSpace::getDefaultColor(GfxColor *color) {
+void GfxDeviceGrayColorSpace::getDefaultColor(GfxColor *color) const {
   color->c[0] = 0;
 }
 
@@ -943,7 +943,7 @@ void GfxCalGrayColorSpace::getDeviceN(const GfxColor 
*color, GfxColor *deviceN)
   deviceN->c[3] = cmyk.k;
 }
 
-void GfxCalGrayColorSpace::getDefaultColor(GfxColor *color) {
+void GfxCalGrayColorSpace::getDefaultColor(GfxColor *color) const {
   color->c[0] = 0;
 }
 
@@ -1085,7 +1085,7 @@ void GfxDeviceRGBColorSpace::getDeviceN(const GfxColor 
*color, GfxColor *deviceN
   deviceN->c[3] = cmyk.k;
 }
 
-void GfxDeviceRGBColorSpace::getDefaultColor(GfxColor *color) {
+void 

[poppler] poppler/CairoOutputDev.cc

2019-09-22 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit fef3bbc1ef61fb8ee94dc12179d1f660e4016458
Author: Marek Kasik 
Date:   Fri Sep 20 16:33:04 2019 +0200

CairoOutputDev: Check scaled dimensions for 0

Check scaledWidth and scaledHeight for 0 at 
RescaleDrawImage::getSourceImage()
as is done on other places. Set the dimension to 1 if it is 0.

Fixes issue #737

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 68927636..12f312c6 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -3134,6 +3134,13 @@ public:
  scaledWidth = MAX_PRINT_IMAGE_SIZE * (double)width/height;
}
needsCustomDownscaling = true;
+
+if (scaledWidth == 0) {
+  scaledWidth = 1;
+}
+if (scaledHeight == 0) {
+  scaledHeight = 1;
+}
   } else {
needsCustomDownscaling = false;
   }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] poppler/CairoOutputDev.cc

2019-09-22 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 1ef3b513164640390ffeb765ec0dcfa8d36f7262
Author: Albert Astals Cid 
Date:   Sun Sep 22 11:33:31 2019 +0200

Update (C) of last commit

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 12f312c6..d09cab55 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -31,6 +31,7 @@
 // Copyright (C) 2015 Suzuki Toshiya 
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Adam Reichold 
+// Copyright (C) 2019 Marek Kasik 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] poppler/CairoOutputDev.cc poppler/CairoRescaleBox.cc qt5/src utils/ImageOutputDev.cc utils/pdftocairo.cc

2019-02-06 Thread GitLab Mirror
 poppler/CairoOutputDev.cc  |2 +-
 poppler/CairoRescaleBox.cc |1 +
 qt5/src/ArthurOutputDev.cc |2 +-
 utils/ImageOutputDev.cc|2 +-
 utils/pdftocairo.cc|2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 2c5fadd7e1c1b896ee23a3ba694f5f19430b6720
Author: Albert Astals Cid 
Date:   Wed Feb 6 19:45:09 2019 +0100

Update (C) of last commit

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 30c9f57a..d2769a22 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -16,7 +16,7 @@
 //
 // Copyright (C) 2005-2008 Jeff Muizelaar 
 // Copyright (C) 2005, 2006 Kristian Høgsberg 
-// Copyright (C) 2005, 2009, 2012, 2017, 2018 Albert Astals Cid 
+// Copyright (C) 2005, 2009, 2012, 2017-2019 Albert Astals Cid 
 // Copyright (C) 2005 Nickolay V. Shmyrev 
 // Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos 

 // Copyright (C) 2008 Carl Worth 
diff --git a/poppler/CairoRescaleBox.cc b/poppler/CairoRescaleBox.cc
index 838d6348..b8371a5b 100644
--- a/poppler/CairoRescaleBox.cc
+++ b/poppler/CairoRescaleBox.cc
@@ -33,6 +33,7 @@
 // Copyright (C) 2012 Hib Eris 
 // Copyright (C) 2012, 2017 Adrian Johnson 
 // Copyright (C) 2018 Adam Reichold 
+// Copyright (C) 2019 Albert Astals Cid 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc
index deb44514..3eec3eb3 100644
--- a/qt5/src/ArthurOutputDev.cc
+++ b/qt5/src/ArthurOutputDev.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Brad Hards 
-// Copyright (C) 2005-2009, 2011, 2012, 2014, 2015, 2018 Albert Astals Cid 

+// Copyright (C) 2005-2009, 2011, 2012, 2014, 2015, 2018, 2019 Albert Astals 
Cid 
 // Copyright (C) 2008, 2010 Pino Toscano 
 // Copyright (C) 2009, 2011 Carlos Garcia Campos 
 // Copyright (C) 2009 Petr Gajdos 
diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc
index 16719384..850eb102 100644
--- a/utils/ImageOutputDev.cc
+++ b/utils/ImageOutputDev.cc
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2005, 2007, 2011, 2018 Albert Astals Cid 
+// Copyright (C) 2005, 2007, 2011, 2018, 2019 Albert Astals Cid 
 // Copyright (C) 2006 Rainer Keller 
 // Copyright (C) 2008 Timothy Lee 
 // Copyright (C) 2008 Vasile Gaburici 
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index e6d22f34..7bdbb679 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -18,7 +18,7 @@
 // Copyright (C) 2009 Michael K. Johnson 
 // Copyright (C) 2009 Shen Liang 
 // Copyright (C) 2009 Stefan Thomas 
-// Copyright (C) 2009, 2010, 2017, 2018 Albert Astals Cid 
+// Copyright (C) 2009, 2010, 2017-2019 Albert Astals Cid 
 // Copyright (C) 2010, 2011-2017 Adrian Johnson 
 // Copyright (C) 2010, 2014 Hib Eris 
 // Copyright (C) 2010 Jonathan Liu 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2018-11-01 Thread GitLab Mirror
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b645e64e906b4b8930cd380cc95b6d6777b96003
Author: Albert Astals Cid 
Date:   Thu Nov 1 23:18:18 2018 +0100

Update (C)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 8b31df77..0eb09525 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2005 Nickolay V. Shmyrev 
 // Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos 

 // Copyright (C) 2008 Carl Worth 
-// Copyright (C) 2008-2017 Adrian Johnson 
+// Copyright (C) 2008-2018 Adrian Johnson 
 // Copyright (C) 2008 Michael Vrable 
 // Copyright (C) 2008, 2009 Chris Wilson 
 // Copyright (C) 2008, 2012 Hib Eris 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2018-03-04 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 4afe2fb10ab969bfd9895c0ba9d4990c5881b451
Author: Carlos Garcia Campos 
Date:   Sun Mar 4 10:28:57 2018 +0100

cairo: use GOOD instead of BEST as the default cairo filter for scaling

The quality is good enough and the performance is much better.

https://bugs.freedesktop.org/show_bug.cgi?id=103136

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index bc83b807..631ab27b 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1970,7 +1970,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t 
*image,
GBool interpolate)
 {
   if (interpolate)
-return CAIRO_FILTER_BEST;
+return CAIRO_FILTER_GOOD;
 
   int orig_width = cairo_image_surface_get_width (image);
   int orig_height = cairo_image_surface_get_height (image);
@@ -1990,7 +1990,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t 
*image,
   if (scaled_width / orig_width >= 4 || scaled_height / orig_height >= 4)
  return CAIRO_FILTER_NEAREST;
 
-  return CAIRO_FILTER_BEST;
+  return CAIRO_FILTER_GOOD;
 }
 
 void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
@@ -2458,7 +2458,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState 
*state, Object *ref, Stream
* cairo doesn't yet do minifaction filtering causing scaled down
* images with CAIRO_FILTER_NEAREST to look really bad */
   cairo_pattern_set_filter (pattern,
-   interpolate ? CAIRO_FILTER_BEST : 
CAIRO_FILTER_FAST);
+   interpolate ? CAIRO_FILTER_GOOD : 
CAIRO_FILTER_FAST);
 
   if (state->getFillColorSpace()->getMode() == csPattern) {
 cairo_matrix_init_translate (, 0, scaledHeight);
@@ -3258,7 +3258,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   cairo_matrix_t matrix;
   int width, height;
   int scaledWidth, scaledHeight;
-  cairo_filter_t filter = CAIRO_FILTER_BEST;
+  cairo_filter_t filter = CAIRO_FILTER_GOOD;
   RescaleDrawImage rescale;
 
   LOG (printf ("drawImage %dx%d\n", widthA, heightA));
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2017-11-09 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 7ccedf2b082e4d46257fb247e1f6e1197d66eead
Author: Adrian Johnson 
Date:   Wed Nov 8 21:07:45 2017 +1030

cairo: don't overflow y * stride when accessing image data

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 43c604f0..cc8a161b 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1834,7 +1834,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 /* convert to a luminocity map */
 uint32_t *source_data = (uint32_t*)cairo_image_surface_get_data(source);
 /* get stride in units of 32 bits */
-int stride = cairo_image_surface_get_stride(source)/4;
+ptrdiff_t stride = cairo_image_surface_get_stride(source)/4;
 for (int y=0; y= width || 
scaledHeight >= height) {
   // No downscaling. Create cairo image containing the source image data.
   unsigned char *buffer;
-  int stride;
+  ptrdiff_t stride;
 
   image = cairo_image_surface_create (maskColors ?
   CAIRO_FORMAT_ARGB32 :
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/GfxFont.cc poppler/GlobalParams.cc poppler/GlobalParams.h poppler/SplashOutputDev.cc poppler/TextOutputDev.cc

2017-10-19 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc  |2 
 poppler/GfxFont.cc |   94 ++---
 poppler/GlobalParams.cc|  193 -
 poppler/GlobalParams.h |   44 --
 poppler/SplashOutputDev.cc |   66 ---
 poppler/TextOutputDev.cc   |3 
 6 files changed, 68 insertions(+), 334 deletions(-)

New commits:
commit 5b8fe4ee986673f15fcf8f58409cc85e8bf7ca12
Author: Albert Astals Cid 
Date:   Thu Oct 19 17:49:06 2017 +0200

Remove various never called internal setters from GlobalParams.h

TextKeepTinyChars: false, simplify if in TextOutputDev
DisableFreeTypeHinting: didn't actually have a getter :D
StrokeAdjust: true, adjust the code in Cairo/SplashOutputDev to use gTrue
ScreenType: unset, simplify switch in SplashOutputDev
ScreenSize: -1, simplify code in SplashOutputDev
ScreenDotRadius: -1, simplify code in SplashOutputDev
ScreenGamma: 1.0, simplify code in SplashOutputDev
ScreenBlackThreshold: 0.0, simplify code in SplashOutputDev
ScreenWhiteThreshold: 1.0, simplify code in SplashOutputDev
MinLineWidth: 0.0, define it as static const in SplashOutputDev since was 
used in various places
MapNumericCharNames: true, remove GfxFont.cc if guard
MapUnknownCharNames: true, remove GfxFont.cc if guard

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 80f7a99e..fdff172e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -169,7 +169,7 @@ CairoOutputDev::CairoOutputDev() {
 
   // the SA parameter supposedly defaults to false, but Acrobat
   // apparently hardwires it to true
-  stroke_adjust = globalParams->getStrokeAdjust();
+  stroke_adjust = gTrue;
   align_stroke_coords = gFalse;
   adjusted_stroke_width = gFalse;
   xref = NULL;
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 04431b3c..d06eadff 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1311,12 +1311,10 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, 
Ref idA, GooString *nameA
  continue;
}
 
-   // if the 'mapUnknownCharNames' flag is set, do a simple pass-through
+   // do a simple pass-through
// mapping for unknown character names
-   if (globalParams->getMapUnknownCharNames()) {
-   uBuf[0] = code;
-   ctu->setMapping((CharCode)code, uBuf, 1);
-   }
+uBuf[0] = code;
+ctu->setMapping((CharCode)code, uBuf, 1);
   }
 }
   }
@@ -1505,54 +1503,52 @@ static int parseCharName(char *charName, Unicode *uBuf, 
int uLen,
   if (names && (uBuf[0] = globalParams->mapNameToUnicodeText(charName))) {
 return 1;
   }
-  if (globalParams->getMapNumericCharNames()) {
-unsigned int n = strlen(charName);
-// 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E
-// U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9,
-// A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that
-// sequence is a multiple of four, and each group of four digits represents
-// a number in the set {0x .. 0xD7FF, 0xE000 .. 0x}, then interpret
-// each such number as a Unicode scalar value and map the component to the
-// string made of those scalar values. Note that the range and digit length
-// restrictions mean that the "uni" prefix can be used only with Unicode
-// values from the Basic Multilingual Plane (BMP).
-if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) {
-  int i;
-  unsigned int m;
-  for (i = 0, m = 3; i < uLen && m < n; m += 4) {
-   if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) && 
-   isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) {
- unsigned int u;
- sscanf(charName + m, "%4x", );
- if (u <= 0xD7FF || (0xE000 <= u && u <= 0x)) {
-   uBuf[i++] = u;
- }
-   }
-  }
-  return i;
-}
-// 3.4. otherwise, if the component is of the form "u" (U+0075) followed by
-// a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F}
-// (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a
-// number in {0x .. 0xD7FF, 0xE000 .. 0x10}, then interpret this
-// number as a Unicode scalar value and map the component to the string
-// made of this scalar value.
-if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) &&
-   isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4])
-   && (n <= 5 || isxdigit(charName[5]))
-   && (n <= 6 || isxdigit(charName[6]))) {
-  unsigned int u;
-  sscanf(charName + 1, "%x", );
-  if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10)) {
-   uBuf[0] = u;
-   return 1;
+  unsigned int n = strlen(charName);
+  // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E
+  // U+0069) followed by a sequence of uppercase hexadecimal digits 

[poppler] poppler/CairoOutputDev.cc

2017-10-12 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 19ebd40547186a8ea6da08c8d8e2a6d6b7e84f5d
Author: Albert Astals Cid 
Date:   Fri Oct 13 00:55:49 2017 +0200

CairoOutputDev: Fix crash in broken files

Bug #103016

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index ffd39ef7..80f7a99e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2714,7 +2714,9 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, 
Object *ref, Stream *s
   for (y = 0; y < maskHeight; y++) {
 maskDest = (unsigned char *) (maskBuffer + y * row_stride);
 pix = maskImgStr->getLine();
-maskColorMap->getGrayLine (pix, maskDest, maskWidth);
+if (likely(pix != nullptr)) {
+maskColorMap->getGrayLine (pix, maskDest, maskWidth);
+}
   }
 
   maskImgStr->close();
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2017-09-24 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit a1a4be92323ae45f1ecc16595438520309554eb0
Author: Carlos Garcia Campos 
Date:   Sun Sep 24 13:21:58 2017 +0200

cairo: do not use the custom downscaling for rendering images when using 
cairo >= 1.14

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 4d3cf02d..5a644f0a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -3077,7 +3077,13 @@ public:
   }
 }
 
-if (printing || scaledWidth >= width || scaledHeight >= height) {
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
+bool needsCustomDownscaling = false;
+#else
+bool needsCustomDownscaling = true;
+#endif
+
+if (!needsCustomDownscaling || printing || scaledWidth >= width || 
scaledHeight >= height) {
   // No downscaling. Create cairo image containing the source image data.
   unsigned char *buffer;
   int stride;
@@ -3191,7 +3197,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   cairo_matrix_t matrix;
   int width, height;
   int scaledWidth, scaledHeight;
-  cairo_filter_t filter = CAIRO_FILTER_BILINEAR;
+  cairo_filter_t filter = CAIRO_FILTER_BEST;
   RescaleDrawImage rescale;
 
   LOG (printf ("drawImage %dx%d\n", widthA, heightA));
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2016-12-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 1a6e4b65197391b23c2163b939d4787f2058a2e1
Author: Jason Crain 
Date:   Wed Dec 7 09:28:58 2016 -0600

cairo: initialize CairoOutputDev::antialias

Initialize CairoOutputDev::antialias to CAIRO_ANTIALIAS_DEFAULT.

Bug #98983

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index bd18cde..89d0c99 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -150,6 +150,7 @@ CairoOutputDev::CairoOutputDev() {
   inType3Char = gFalse;
   t3_glyph_has_bbox = gFalse;
   text_matrix_valid = gTrue;
+  antialias = CAIRO_ANTIALIAS_DEFAULT;
 
   groupColorSpaceStack = NULL;
   maskStack = NULL;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2016-07-02 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 9faa9b05171e46815924b48d31a7c45a1285c403
Author: Adrian Johnson 
Date:   Sun Jun 5 22:44:56 2016 +0930

Fix tiling patterns with BBox with non-zero x,y

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a734324..6cc9bdb 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -900,6 +900,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   cairo_t *old_cairo;
   double xMin, yMin, xMax, yMax;
   double width, height;
+  double scaleX, scaleY;
   int surface_width, surface_height;
   StrokePathClip *strokePathTmp;
   GBool adjusted_stroke_width_tmp;
@@ -924,6 +925,8 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   double heightX = 0, heightY = height;
   cairo_matrix_transform_distance (, , );
   surface_height = ceil (sqrt (heightX * heightX + heightY * heightY));
+  scaleX = surface_width / width;
+  scaleY = surface_height / height;
 
   surface = cairo_surface_create_similar (cairo_get_target (cairo),
  CAIRO_CONTENT_COLOR_ALPHA,
@@ -935,10 +938,12 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   cairo = cairo_create (surface);
   cairo_surface_destroy (surface);
   setContextAntialias(cairo, antialias);
-  cairo_scale (cairo, surface_width / width, surface_height / height);
 
   box.x1 = bbox[0]; box.y1 = bbox[1];
   box.x2 = bbox[2]; box.y2 = bbox[3];
+  cairo_scale (cairo, scaleX, scaleY);
+  cairo_translate (cairo, -box.x1, -box.y1);
+
   strokePathTmp = strokePathClip;
   strokePathClip = NULL;
   adjusted_stroke_width_tmp = adjusted_stroke_width;
@@ -964,7 +969,8 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   state->getUserClipBBox(, , , );
   cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
 
-  cairo_matrix_init_scale (, surface_width / width, surface_height / 
height);
+  cairo_matrix_init_scale (, scaleX, scaleY);
+  cairo_matrix_translate (, -box.x1, -box.y1);
   cairo_pattern_set_matrix (pattern, );
 
   cairo_transform (cairo, _matrix);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h utils/pdftocairo.1 utils/pdftocairo.cc

2016-05-20 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   24 
 poppler/CairoOutputDev.h  |4 ++
 utils/pdftocairo.1|   26 ++
 utils/pdftocairo.cc   |   66 +-
 4 files changed, 112 insertions(+), 8 deletions(-)

New commits:
commit 853e94995255591b35d9bdbeb0174476838097c0
Author: Adrian Johnson 
Date:   Sun Apr 17 16:02:57 2016 +0930

pdftocairo: add -antialias option

Bug 94977

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index b0987b3..9f892b2 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -206,6 +206,7 @@ void CairoOutputDev::setCairo(cairo_t *cairo)
/* save the initial matrix so that we can use it for type3 fonts. */
//XXX: is this sufficient? could we miss changes to the matrix somehow?
cairo_get_matrix(cairo, _matrix);
+   setAntialias(cairo, antialias);
   } else {
 this->cairo = NULL;
 this->cairo_shape = NULL;
@@ -228,6 +229,26 @@ void CairoOutputDev::setTextPage(TextPage *text)
   }
 }
 
+void CairoOutputDev::setAntialias(cairo_antialias_t antialias)
+{
+  this->antialias = antialias;
+  if (cairo)
+setAntialias (cairo, antialias);
+  if (cairo_shape)
+setAntialias (cairo_shape, antialias);
+}
+
+void CairoOutputDev::setAntialias(cairo_t *cr, cairo_antialias_t antialias)
+{
+  cairo_font_options_t *font_options;
+  cairo_set_antialias (cairo, antialias);
+  font_options = cairo_font_options_create ();
+  cairo_get_font_options (cr, font_options);
+  cairo_font_options_set_antialias (font_options, antialias);
+  cairo_set_font_options (cr, font_options);
+  cairo_font_options_destroy (font_options);
+}
+
 void CairoOutputDev::startDoc(PDFDoc *docA,
  CairoFontEngine *parentFontEngine) {
   doc = docA;
@@ -913,6 +934,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   old_cairo = cairo;
   cairo = cairo_create (surface);
   cairo_surface_destroy (surface);
+  setAntialias(cairo, antialias);
   cairo_scale (cairo, surface_width / width, surface_height / height);
 
   box.x1 = bbox[0]; box.y1 = bbox[1];
@@ -1611,6 +1633,7 @@ void CairoOutputDev::beginTransparencyGroup(GfxState * 
/*state*/, double * /*bbo
   cairo_surface_t *cairo_shape_surface = cairo_surface_create_similar_clip 
(cairo, CAIRO_CONTENT_ALPHA);
   cairo_shape = cairo_create (cairo_shape_surface);
   cairo_surface_destroy (cairo_shape_surface);
+  setAntialias(cairo_shape, antialias);
 
   /* the color doesn't matter as long as it is opaque */
   cairo_set_source_rgb (cairo_shape, 0, 0, 0);
@@ -1765,6 +1788,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 
 cairo_surface_t *source = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 
width, height);
 cairo_t *maskCtx = cairo_create(source);
+setAntialias(maskCtx, antialias);
 
 //XXX: hopefully this uses the correct color space */
 if (!alpha && groupColorSpaceStack->cs) {
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 103a326..3a6dbfa 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -266,6 +266,7 @@ public:
   void setCairo (cairo_t *cr);
   void setTextPage (TextPage *text);
   void setPrinting (GBool printing) { this->printing = printing; 
needFontUpdate = gTrue; }
+  void setAntialias(cairo_antialias_t antialias);
 
   void setInType3Char(GBool inType3Char) { this->inType3Char = inType3Char; }
   void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = 
t3_glyph_wy; }
@@ -288,6 +289,7 @@ protected:
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
   GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
 #endif
+  void setAntialias(cairo_t *cr, cairo_antialias_t antialias);
 
   GfxRGB fill_color, stroke_color;
   cairo_pattern_t *fill_pattern, *stroke_pattern;
@@ -340,7 +342,7 @@ protected:
   double t3_glyph_wx, t3_glyph_wy;
   GBool t3_glyph_has_bbox;
   double t3_glyph_bbox[4];
-
+  cairo_antialias_t antialias;
   GBool prescaleImages;
 
   TextPage *text;  // text for the current page
diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1
index 2211da7..5e30adf 100644
--- a/utils/pdftocairo.1
+++ b/utils/pdftocairo.1
@@ -167,6 +167,32 @@ Generate a monochrome file (PNG and TIFF only).
 .B \-gray
 Generate a grayscale file (PNG, JPEG, and TIFF only).
 .TP
+.B \-antialias
+Set the cairo antialias option used for text and drawing in image files (or 
rasterized regions in vector output). The options are:
+.RS
+.TP
+.B default
+Use the default antialiasing for the target device. This is the default 
setting if \-antialias is not used.
+.TP
+.B none
+Antialiasing is disabled.
+.TP
+.B gray
+Perform single-color antialiasing using shades of gray.
+.TP
+.B subpixel
+Perform antialiasing by taking advantage of the order of subpixel elements on 
devices such as 

[poppler] poppler/CairoOutputDev.cc

2016-04-02 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit db87dc7fa28537f7532328c278c05d8b60f90d6f
Author: Jason Crain 
Date:   Sun Feb 21 22:54:15 2016 -0600

cairo: save mask state and don't extend image mask

Don't extend an image mask pattern.  Save and restore the mask in
tilingPatternFill.

bug #94234

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index eab1ccc..a4c7a6a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -882,6 +882,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   int surface_width, surface_height;
   StrokePathClip *strokePathTmp;
   GBool adjusted_stroke_width_tmp;
+  cairo_pattern_t *maskTmp;
 
   width = bbox[2] - bbox[0];
   height = bbox[3] - bbox[1];
@@ -919,6 +920,8 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   strokePathTmp = strokePathClip;
   strokePathClip = NULL;
   adjusted_stroke_width_tmp = adjusted_stroke_width;
+  maskTmp = mask;
+  mask = NULL;
   gfx = new Gfx(doc, this, resDict, , NULL, NULL, NULL, gfxA->getXRef());
   if (paintType == 2)
 inUncoloredPattern = gTrue;
@@ -928,6 +931,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   delete gfx;
   strokePathClip = strokePathTmp;
   adjusted_stroke_width = adjusted_stroke_width_tmp;
+  mask = maskTmp;
 
   pattern = cairo_pattern_create_for_surface (cairo_get_target (cairo));
   cairo_destroy (cairo);
@@ -2413,7 +2417,6 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState 
*state, Object *ref, Stream
* images with CAIRO_FILTER_NEAREST to look really bad */
   cairo_pattern_set_filter (pattern,
interpolate ? CAIRO_FILTER_BEST : 
CAIRO_FILTER_FAST);
-  cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
 
   if (state->getFillColorSpace()->getMode() == csPattern) {
 cairo_matrix_init_translate (, 0, scaledHeight);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2016-04-02 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   38 ++
 poppler/CairoOutputDev.h  |1 +
 2 files changed, 31 insertions(+), 8 deletions(-)

New commits:
commit 7d8dfb09d2b9d69d4e80838ce58fdbd091bce7ec
Author: Jason Crain 
Date:   Sun Feb 28 16:18:05 2016 -0600

cairo: fix fillToStrokePathClip crash and rendering

The cairo backend can crash if the dash pattern changes between calling
clipToStrokePathClip and fillToStrokePathClip because fillToStrokePathClip
calls cairo_set_dash with the saved dash pattern but the current dash count.

Fixes the crash by removing the call to cairo_get_dash_count in
fillToStrokePathClip.  Makes strokePathClip reference counted because when
drawing tiling patterns it may need to be kept around for more than one 
drawing
operation.  Uses fillToStrokePathClip in a few more places to fix rendering.

bug #62905

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index d0d6cb4..eab1ccc 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -278,6 +278,9 @@ void CairoOutputDev::saveState(GfxState *state) {
   ms->mask_matrix = mask_matrix;
   ms->next = maskStack;
   maskStack = ms;
+
+  if (strokePathClip)
+strokePathClip->ref_count++;
 }
 
 void CairoOutputDev::restoreState(GfxState *state) {
@@ -305,6 +308,14 @@ void CairoOutputDev::restoreState(GfxState *state) {
 maskStack = ms->next;
 delete ms;
   }
+
+  if (strokePathClip && --strokePathClip->ref_count == 0) {
+delete strokePathClip->path;
+if (strokePathClip->dashes)
+  gfree (strokePathClip->dashes);
+gfree (strokePathClip);
+strokePathClip = NULL;
+  }
 }
 
 void CairoOutputDev::updateAll(GfxState *state) {
@@ -780,7 +791,14 @@ void CairoOutputDev::stroke(GfxState *state) {
   align_stroke_coords = gFalse;
   cairo_set_source (cairo, stroke_pattern);
   LOG(printf ("stroke\n"));
-  cairo_stroke (cairo);
+  if (strokePathClip) {
+cairo_push_group (cairo);
+cairo_stroke (cairo);
+cairo_pop_group_to_source (cairo);
+fillToStrokePathClip (state);
+  } else {
+cairo_stroke (cairo);
+  }
   if (cairo_shape) {
 doPath (cairo_shape, state, state->getPath());
 cairo_stroke (cairo_shape);
@@ -803,6 +821,11 @@ void CairoOutputDev::fill(GfxState *state) {
   if (mask) {
 cairo_save (cairo);
 cairo_clip (cairo);
+if (strokePathClip) {
+  cairo_push_group (cairo);
+  fillToStrokePathClip (state);
+  cairo_pop_group_to_source (cairo);
+}
 cairo_set_matrix (cairo, _matrix);
 cairo_mask (cairo, mask);
 cairo_restore (cairo);
@@ -1296,6 +1319,7 @@ void CairoOutputDev::clipToStrokePath(GfxState *state) {
   strokePathClip->cap = cairo_get_line_cap (cairo);
   strokePathClip->join = cairo_get_line_join (cairo);
   strokePathClip->miter = cairo_get_miter_limit (cairo);
+  strokePathClip->ref_count = 1;
 }
 
 void CairoOutputDev::fillToStrokePathClip(GfxState *state) {
@@ -1303,7 +1327,6 @@ void CairoOutputDev::fillToStrokePathClip(GfxState 
*state) {
 
   cairo_set_matrix (cairo, >ctm);
   cairo_set_line_width (cairo, strokePathClip->line_width);
-  strokePathClip->dash_count = cairo_get_dash_count (cairo);
   cairo_set_dash (cairo, strokePathClip->dashes, strokePathClip->dash_count, 
strokePathClip->dash_offset);
   cairo_set_line_cap (cairo, strokePathClip->cap);
   cairo_set_line_join (cairo, strokePathClip->join);
@@ -1312,12 +1335,6 @@ void CairoOutputDev::fillToStrokePathClip(GfxState 
*state) {
   cairo_stroke (cairo);
 
   cairo_restore (cairo);
-
-  delete strokePathClip->path;
-  if (strokePathClip->dashes)
-gfree (strokePathClip->dashes);
-  gfree (strokePathClip);
-  strokePathClip = NULL;
 }
 
 void CairoOutputDev::beginString(GfxState *state, GooString *s)
@@ -2425,6 +2442,11 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState 
*state, Object *ref, Stream
 
 cairo_rectangle (cairo, 0., 0., scaledWidth, scaledHeight);
 cairo_clip (cairo);
+if (strokePathClip) {
+  cairo_push_group (cairo);
+  fillToStrokePathClip (state);
+  cairo_pop_group_to_source (cairo);
+}
 cairo_mask (cairo, pattern);
 
 //cairo_get_matrix(cairo, );
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index c146ce0..0f88778 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -308,6 +308,7 @@ protected:
 cairo_line_cap_t cap;
 cairo_line_join_t join;
 double miter;
+int ref_count;
   } *strokePathClip;
 
   PDFDoc *doc; // the current document
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2015-12-04 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |  101 ++
 poppler/CairoOutputDev.h  |5 +-
 2 files changed, 105 insertions(+), 1 deletion(-)

New commits:
commit 47ffce08e75002aa0707107c76984e7e471d8afb
Author: Adrian Johnson 
Date:   Thu Jan 15 21:20:05 2015 +1030

cairo: Implement function shading using mesh gradients

Gfx draws function shadings by subdividing the shading until the
colors are the same or the maximum subdivision is reached then fills
each cell with the color of the mid point of the cell. The solid
colors can result in a pixelated appearance.

This patch implements a cairo specific version of the function shading
that uses mesh gradients to draw each cell. By setting the corner of
each patch to the shading color at that point, the mesh gradient will
interpolate the colors resulting in a smooth appearance.

Bug 88394

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 5781c08..56cd06d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -932,6 +932,107 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   return gTrue;
 }
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
+GBool CairoOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading 
*shading)
+{
+  // Function shaded fills are subdivided to rectangles that are the
+  // following size in device space.  Note when printing this size is
+  // in points.
+  const int subdivide_pixels = 10;
+
+  double x_begin, x_end, x1, x2;
+  double y_begin, y_end, y1, y2;
+  double x_step;
+  double y_step;
+  GfxColor color;
+  GfxRGB rgb;
+  double *matrix;
+  cairo_matrix_t mat;
+
+  matrix = shading->getMatrix();
+  mat.xx = matrix[0];
+  mat.yx = matrix[1];
+  mat.xy = matrix[2];
+  mat.yy = matrix[3];
+  mat.x0 = matrix[4];
+  mat.y0 = matrix[5];
+  if (cairo_matrix_invert()) {
+error(errSyntaxWarning, -1, "matrix not invertible\n");
+return gFalse;
+}
+
+  // get cell size in pattern space
+  x_step = y_step = subdivide_pixels;
+  cairo_matrix_transform_distance (, _step, _step);
+
+  cairo_pattern_destroy(fill_pattern);
+  fill_pattern = cairo_pattern_create_mesh ();
+  cairo_pattern_set_matrix(fill_pattern, );
+  shading->getDomain(_begin, _begin, _end, _end);
+
+  for (x1 = x_begin; x1 < x_end; x1 += x_step) {
+x2 = x1 + x_step;
+if (x2 > x_end)
+  x2 = x_end;
+
+for (y1 = y_begin; y1 < y_end; y1 += y_step) {
+  y2 = y1 + y_step;
+  if (y2 > y_end)
+   y2 = y_end;
+
+  cairo_mesh_pattern_begin_patch (fill_pattern);
+  cairo_mesh_pattern_move_to (fill_pattern, x1, y1);
+  cairo_mesh_pattern_line_to (fill_pattern, x2, y1);
+  cairo_mesh_pattern_line_to (fill_pattern, x2, y2);
+  cairo_mesh_pattern_line_to (fill_pattern, x1, y2);
+
+  shading->getColor(x1, y1, );
+  shading->getColorSpace()->getRGB(, );
+  cairo_mesh_pattern_set_corner_color_rgb (fill_pattern, 0,
+  colToDbl(rgb.r),
+  colToDbl(rgb.g),
+  colToDbl(rgb.b));
+
+  shading->getColor(x2, y1, );
+  shading->getColorSpace()->getRGB(, );
+  cairo_mesh_pattern_set_corner_color_rgb (fill_pattern, 1,
+  colToDbl(rgb.r),
+  colToDbl(rgb.g),
+  colToDbl(rgb.b));
+
+  shading->getColor(x2, y2, );
+  shading->getColorSpace()->getRGB(, );
+  cairo_mesh_pattern_set_corner_color_rgb (fill_pattern, 2,
+  colToDbl(rgb.r),
+  colToDbl(rgb.g),
+  colToDbl(rgb.b));
+
+  shading->getColor(x1, y2, );
+  shading->getColorSpace()->getRGB(, );
+  cairo_mesh_pattern_set_corner_color_rgb (fill_pattern, 3,
+  colToDbl(rgb.r),
+  colToDbl(rgb.g),
+  colToDbl(rgb.b));
+
+  cairo_mesh_pattern_end_patch (fill_pattern);
+}
+  }
+
+  double xMin, yMin, xMax, yMax;
+  // get the clip region bbox
+  state->getUserClipBBox(, , , );
+  state->moveTo(xMin, yMin);
+  state->lineTo(xMin, yMax);
+  state->lineTo(xMax, yMax);
+  state->lineTo(xMax, yMin);
+  state->closePath();
+  fill(state);
+  state->clearPath();
+
+  return gTrue;
+}
+#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) */
+
 GBool CairoOutputDev::axialShadedFill(GfxState *state, GfxAxialShading 
*shading, double tMin, double tMax) {
   double x0, y0, x1, y1;
   double dx, dy;
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 33dde0c..1c9a18c 100644
--- a/poppler/CairoOutputDev.h
+++ 

[poppler] poppler/CairoOutputDev.cc

2015-12-04 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

New commits:
commit d7717cf18d0db5663687690ccf66102e9a124025
Author: Jason Crain 
Date:   Fri Aug 22 00:51:36 2014 -0500

cairo: Scale radial pattern

Scale the radial pattern because cairo/pixman do not work well with a
very large or small scaled matrix.  See cairo bug #81657.

bug #22098

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 3916485..5781c08 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -963,18 +963,32 @@ GBool CairoOutputDev::axialShadedSupportExtend(GfxState 
*state, GfxAxialShading
 GBool CairoOutputDev::radialShadedFill(GfxState *state, GfxRadialShading 
*shading, double sMin, double sMax) {
   double x0, y0, r0, x1, y1, r1;
   double dx, dy, dr;
+  cairo_matrix_t matrix;
+  double scale;
 
   shading->getCoords(, , , , , );
   dx = x1 - x0;
   dy = y1 - y0;
   dr = r1 - r0;
+
+  // Cairo/pixman do not work well with a very large or small scaled
+  // matrix.  See cairo bug #81657.
+  //
+  // As a workaround, scale the pattern by the average of the vertical
+  // and horizontal scaling of the current transformation matrix.
+  cairo_get_matrix(cairo, );
+  scale = (sqrt(matrix.xx * matrix.xx + matrix.yx * matrix.yx)
+  + sqrt(matrix.xy * matrix.xy + matrix.yy * matrix.yy)) / 2;
+  cairo_matrix_init_scale(, scale, scale);
+
   cairo_pattern_destroy(fill_pattern);
-  fill_pattern = cairo_pattern_create_radial (x0 + sMin * dx,
- y0 + sMin * dy,
- r0 + sMin * dr,
- x0 + sMax * dx,
- y0 + sMax * dy,
- r0 + sMax * dr);
+  fill_pattern = cairo_pattern_create_radial ((x0 + sMin * dx) * scale,
+ (y0 + sMin * dy) * scale,
+ (r0 + sMin * dr) * scale,
+ (x0 + sMax * dx) * scale,
+ (y0 + sMax * dy) * scale,
+ (r0 + sMax * dr) * scale);
+  cairo_pattern_set_matrix(fill_pattern, );
   if (shading->getExtend0() && shading->getExtend1())
 cairo_pattern_set_extend (fill_pattern, CAIRO_EXTEND_PAD);
   else
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2015-09-16 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 2a48cab5e66a69ed1bf3e792efc109ddcad8d5ee
Author: Jason Crain 
Date:   Tue Sep 15 14:43:21 2015 -0500

cairo: Use mask for even-odd fill

Bug #84527

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 1e201d3..3916485 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -823,8 +823,16 @@ void CairoOutputDev::eoFill(GfxState *state) {
   cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_EVEN_ODD);
   cairo_set_source (cairo, fill_pattern);
   LOG(printf ("fill-eo\n"));
-  cairo_fill (cairo);
 
+  if (mask) {
+cairo_save (cairo);
+cairo_clip (cairo);
+cairo_set_matrix (cairo, _matrix);
+cairo_mask (cairo, mask);
+cairo_restore (cairo);
+  } else {
+cairo_fill (cairo);
+  }
   if (cairo_shape) {
 cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_EVEN_ODD);
 doPath (cairo_shape, state, state->getPath());
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2015-08-31 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   30 --
 1 file changed, 8 insertions(+), 22 deletions(-)

New commits:
commit 72c0162258f2630a3bb11b9c1078ec1ec2812788
Author: Jason Crain 
Date:   Tue Aug 18 01:34:10 2015 -0500

cairo: fix size of transparency group surface

Under rotation cairo_surface_create_similar_clip will create a surface
with incorect width/height.  Rely on cairo to do the correct
calculation.

Bug #66229

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a86ec12..20ae90d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1433,29 +1433,15 @@ static inline int splashFloor(SplashCoord x) {
 static
 cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, 
cairo_content_t content)
 {
-  double x1, y1, x2, y2;
-  int width, height;
-  cairo_clip_extents (cairo, , , , );
-  cairo_matrix_t matrix;
-  cairo_get_matrix (cairo, );
-  //cairo_matrix_transform_point(, , );
-  //cairo_matrix_transform_point(, , );*/
-  cairo_user_to_device(cairo, , );
-  cairo_user_to_device(cairo, , );
-  width = splashCeil(x2) - splashFloor(x1);
-  //XXX: negative matrix
-  height = splashCeil(y2) - splashFloor(y1);
-  height = splashFloor(y1) - splashCeil(y2);
-  cairo_surface_t *target = cairo_get_target (cairo);
-  cairo_surface_t *result;
-
-  result = cairo_surface_create_similar (target, content, width, height);
-  double x_offset, y_offset;
-cairo_surface_get_device_offset(target, _offset, _offset);
-cairo_surface_set_device_offset(result, x_offset, y_offset);
+  cairo_pattern_t *pattern;
+  cairo_surface_t *surface = NULL;
 
- 
-  return result;
+  cairo_push_group_with_content (cairo, content);
+  pattern = cairo_pop_group (cairo);
+  cairo_pattern_get_surface (pattern, );
+  cairo_surface_reference (surface);
+  cairo_pattern_destroy (pattern);
+  return surface;
 }
 
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/JBIG2Stream.cc poppler/JBIG2Stream.h poppler/Stream.cc

2015-01-23 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |  117 ++
 poppler/CairoOutputDev.h  |3 +
 poppler/JBIG2Stream.cc|9 ++-
 poppler/JBIG2Stream.h |4 +
 poppler/Stream.cc |   13 -
 5 files changed, 121 insertions(+), 25 deletions(-)

New commits:
commit f932315e559a7857d9c5642eb04efc0d2b717789
Author: suzuki toshiya mpsuz...@hiroshima-u.ac.jp
Date:   Tue Jan 20 22:05:29 2015 +1030

cairo: support embedding JBIG2 image data

http://lists.freedesktop.org/archives/poppler/2014-December/011183.html

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 4e8abcf..a770320 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -63,6 +63,7 @@
 #include CairoFontEngine.h
 #include CairoRescaleBox.h
 #include UnicodeMap.h
+#include JBIG2Stream.h
 //
 
 // #define LOG_CAIRO
@@ -2701,6 +2702,68 @@ static GBool 
colorMapHasIdentityDecodeMap(GfxImageColorMap *colorMap)
   return gTrue;
 }
 
+#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
+static cairo_status_t setMimeIdFromRef(cairo_surface_t *surface,
+  const char *mime_type,
+  const char *mime_id_prefix,
+  Ref ref)
+{
+  GooString *mime_id;
+  char *idBuffer;
+  cairo_status_t status;
+
+  mime_id = new GooString;
+
+  if (mime_id_prefix)
+mime_id-append(mime_id_prefix);
+
+  mime_id-appendf({0:d}-{1:d}, ref.gen, ref.num);
+
+  idBuffer = copyString(mime_id-getCString());
+  status = cairo_surface_set_mime_data (surface, mime_type,
+(const unsigned char *)idBuffer,
+mime_id-getLength(),
+gfree, idBuffer);
+  delete mime_id;
+  if (status)
+gfree (idBuffer);
+  return status;
+}
+#endif
+
+#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 14, 0)
+GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream  *str,
+ cairo_surface_t *image)
+{
+  JBIG2Stream *jb2Str = static_castJBIG2Stream *(str);
+  Object* globalsStr = jb2Str-getGlobalsStream();
+  char *globalsBuffer;
+  int globalsLength;
+
+  // nothing to do for JBIG2 stream without Globals
+  if (!globalsStr-isStream())
+return gTrue;
+
+  if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, NULL,
+   jb2Str-getGlobalsStreamRef()))
+return gFalse;
+
+  if (!getStreamData(globalsStr-getStream(), globalsBuffer, globalsLength))
+return gFalse;
+
+  if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2_GLOBAL,
+   (const unsigned char*)globalsBuffer,
+   globalsLength,
+   gfree, (void*)globalsBuffer))
+  {
+gfree (globalsBuffer);
+return gFalse;
+  }
+
+  return gTrue;
+}
+#endif
+
 void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
 GfxImageColorMap *colorMap, cairo_surface_t 
*image)
 {
@@ -2708,17 +2771,35 @@ void CairoOutputDev::setMimeData(GfxState *state, 
Stream *str, Object *ref,
   int len;
   Object obj;
   GfxColorSpace *colorSpace;
+  StreamKind  strKind = str-getKind();
+  const char *mime_type;
 
-  if (!printing || !(str-getKind() == strDCT || str-getKind() == strJPX))
+  if (!printing)
 return;
 
+  switch (strKind) {
+case strDCT:
+  mime_type = CAIRO_MIME_TYPE_JPEG;
+  break;
+case strJPX:
+  mime_type = CAIRO_MIME_TYPE_JP2;
+  break;
+#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 14, 0)
+case strJBIG2:
+  mime_type = CAIRO_MIME_TYPE_JBIG2;
+  break;
+#endif
+default:
+  return;
+  }
+
   str-getDict()-lookup(ColorSpace, obj);
   colorSpace = GfxColorSpace::parse(NULL, obj, this, state);
   obj.free();
 
   // colorspace in stream dict may be different from colorspace in jpx
   // data
-  if (str-getKind() == strJPX  colorSpace)
+  if (strKind == strJPX  colorSpace)
 return;
 
   // only embed mime data for gray, rgb, and cmyk colorspaces.
@@ -2746,31 +2827,27 @@ void CairoOutputDev::setMimeData(GfxState *state, 
Stream *str, Object *ref,
   if (!colorMapHasIdentityDecodeMap(colorMap))
 return;
 
+#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 14, 0)
+  if (strKind == strJBIG2  !setMimeDataForJBIG2Globals(str, image))
+return;
+#endif
+
   if (getStreamData (str-getNextStream(), strBuffer, len)) {
-cairo_status_t st;
+cairo_status_t status = CAIRO_STATUS_SUCCESS;
 
 #if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
 if (ref  ref-isRef()) {
-  Ref imgRef = ref-getRef();
-  GooString *surfaceId = new GooString(poppler-surface-);
-  surfaceId-appendf({0:d}-{1:d}, imgRef.gen, imgRef.num);
-  char *idBuffer = copyString(surfaceId-getCString());
-  st = 

[poppler] poppler/CairoOutputDev.cc poppler/Gfx.cc poppler/GfxState.cc poppler/GfxState.h poppler/Page.cc

2014-11-14 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc |4 
 poppler/Gfx.cc|   40 -
 poppler/GfxState.cc   |  197 ++
 poppler/GfxState.h|   31 +++
 poppler/Page.cc   |4 
 5 files changed, 188 insertions(+), 88 deletions(-)

New commits:
commit b7802ff39db270dda2aa20f005fb87c22ed34137
Author: Thomas Freitag thomas.frei...@alfa.de
Date:   Fri Nov 14 11:47:38 2014 +0100

Use Default colorspaces if present instead of Device colorspaces

Fixes part of #68986

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index e08fe5c..4e8abcf 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -25,7 +25,7 @@
 // Copyright (C) 2008, 2009 Chris Wilson ch...@chris-wilson.co.uk
 // Copyright (C) 2008, 2012 Hib Eris h...@hiberis.nl
 // Copyright (C) 2009, 2010 David Benjamin david...@mit.edu
-// Copyright (C) 2011-2013 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2011-2014 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2012 Patrick Pfeifer p2...@mailinator.com
 // Copyright (C) 2012 Jason Crain ja...@aquaticape.us
 //
@@ -2713,7 +2713,7 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream 
*str, Object *ref,
 return;
 
   str-getDict()-lookup(ColorSpace, obj);
-  colorSpace = GfxColorSpace::parse(obj, this, state);
+  colorSpace = GfxColorSpace::parse(NULL, obj, this, state);
   obj.free();
 
   // colorspace in stream dict may be different from colorspace in jpx
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6bf7ec5..64a9d7b 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -28,7 +28,7 @@
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
 // Copyright (C) 2009 M Joonas Pihlaja jpihl...@cc.helsinki.fi
-// Copyright (C) 2009-2013 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2009-2014 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2009 William Bader williamba...@hotmail.com
 // Copyright (C) 2009, 2010 David Benjamin david...@mit.edu
 // Copyright (C) 2010 Nils Höglund nils.hogl...@gmail.com
@@ -468,7 +468,7 @@ GfxPattern *GfxResources::lookupPattern(char *name, 
OutputDev *out, GfxState *st
   for (resPtr = this; resPtr; resPtr = resPtr-next) {
 if (resPtr-patternDict.isDict()) {
   if (!resPtr-patternDict.dictLookup(name, obj)-isNull()) {
-   pattern = GfxPattern::parse(obj, out, state);
+   pattern = GfxPattern::parse(resPtr, obj, out, state);
obj.free();
return pattern;
   }
@@ -487,7 +487,7 @@ GfxShading *GfxResources::lookupShading(char *name, 
OutputDev *out, GfxState *st
   for (resPtr = this; resPtr; resPtr = resPtr-next) {
 if (resPtr-shadingDict.isDict()) {
   if (!resPtr-shadingDict.dictLookup(name, obj)-isNull()) {
-   shading = GfxShading::parse(obj, out, state);
+   shading = GfxShading::parse(resPtr, obj, out, state);
obj.free();
return shading;
   }
@@ -1236,7 +1236,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
  blendingColorSpace = NULL;
  isolated = knockout = gFalse;
  if (!obj4.dictLookup(CS, obj5)-isNull()) {
-   blendingColorSpace = GfxColorSpace::parse(obj5, out, state);
+   blendingColorSpace = GfxColorSpace::parse(res, obj5, out, state);
  }
  obj5.free();
  if (obj4.dictLookup(I, obj5)-isBool()) {
@@ -1439,7 +1439,7 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
   state-setFillPattern(NULL);
   res-lookupColorSpace(DefaultGray, obj);
   if (!obj.isNull()) {
-colorSpace = GfxColorSpace::parse(obj, out, state);
+colorSpace = GfxColorSpace::parse(res, obj, out, state);
   }
   if (colorSpace == NULL) {
 colorSpace = new GfxDeviceGrayColorSpace();
@@ -1460,7 +1460,7 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) {
   state-setStrokePattern(NULL);
   res-lookupColorSpace(DefaultGray, obj);
   if (!obj.isNull()) {
-colorSpace = GfxColorSpace::parse(obj, out, state);
+colorSpace = GfxColorSpace::parse(res, obj, out, state);
   }
   if (colorSpace == NULL) {
 colorSpace = new GfxDeviceGrayColorSpace();
@@ -1481,7 +1481,7 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
 
   res-lookupColorSpace(DefaultCMYK, obj);
   if (!obj.isNull()) {
-colorSpace = GfxColorSpace::parse(obj, out, state);
+colorSpace = GfxColorSpace::parse(res, obj, out, state);
   }
   if (colorSpace == NULL) {
 colorSpace = new GfxDeviceCMYKColorSpace();
@@ -1506,7 +1506,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int 
numArgs) {
   state-setStrokePattern(NULL);
   res-lookupColorSpace(DefaultCMYK, obj);
   if (!obj.isNull()) {
-colorSpace = GfxColorSpace::parse(obj, out, state);
+colorSpace = GfxColorSpace::parse(res, obj, out, state);
   }
   if (colorSpace == NULL) {
 colorSpace = new GfxDeviceCMYKColorSpace();
@@ -1530,7 +1530,7 @@ void Gfx::opSetFillRGBColor(Object args[], 

[poppler] poppler/CairoOutputDev.cc

2014-11-01 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

New commits:
commit bd142810b9f66b017a58b3e1840d4d72794f1ef4
Author: Jason Crain ja...@aquaticape.us
Date:   Thu May 15 02:22:44 2014 -0500

cairo: Use matrix to determine pattern size

https://bugs.freedesktop.org/show_bug.cgi?id=33364

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 03130ac..e08fe5c 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -842,11 +842,13 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   cairo_pattern_t *pattern;
   cairo_surface_t *surface;
   cairo_matrix_t matrix;
+  cairo_matrix_t pattern_matrix;
   cairo_t *old_cairo;
   double xMin, yMin, xMax, yMax;
   double width, height;
   int surface_width, surface_height;
   StrokePathClip *strokePathTmp;
+  GBool adjusted_stroke_width_tmp;
 
   width = bbox[2] - bbox[0];
   height = bbox[3] - bbox[1];
@@ -855,8 +857,18 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
 return gFalse;
   /* TODO: implement the other cases here too */
 
-  surface_width = (int) ceil (width);
-  surface_height = (int) ceil (height);
+  // Find the width and height of the transformed pattern
+  cairo_get_matrix (cairo, matrix);
+  cairo_matrix_init (pattern_matrix, mat[0], mat[1], mat[2], mat[3], mat[4], 
mat[5]);
+  cairo_matrix_multiply (matrix, matrix, pattern_matrix);
+
+  double widthX = width, widthY = 0;
+  cairo_matrix_transform_distance (matrix, widthX, widthY);
+  surface_width = ceil (sqrt (widthX * widthX + widthY * widthY));
+
+  double heightX = 0, heightY = height;
+  cairo_matrix_transform_distance (matrix, heightX, heightY);
+  surface_height = ceil (sqrt (heightX * heightX + heightY * heightY));
 
   surface = cairo_surface_create_similar (cairo_get_target (cairo),
  CAIRO_CONTENT_COLOR_ALPHA,
@@ -867,11 +879,13 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   old_cairo = cairo;
   cairo = cairo_create (surface);
   cairo_surface_destroy (surface);
+  cairo_scale (cairo, surface_width / width, surface_height / height);
 
   box.x1 = bbox[0]; box.y1 = bbox[1];
   box.x2 = bbox[2]; box.y2 = bbox[3];
   strokePathTmp = strokePathClip;
   strokePathClip = NULL;
+  adjusted_stroke_width_tmp = adjusted_stroke_width;
   gfx = new Gfx(doc, this, resDict, box, NULL, NULL, NULL, gfxA-getXRef());
   if (paintType == 2)
 inUncoloredPattern = gTrue;
@@ -880,6 +894,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
 inUncoloredPattern = gFalse;
   delete gfx;
   strokePathClip = strokePathTmp;
+  adjusted_stroke_width = adjusted_stroke_width_tmp;
 
   pattern = cairo_pattern_create_for_surface (cairo_get_target (cairo));
   cairo_destroy (cairo);
@@ -893,8 +908,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   cairo_matrix_init_scale (matrix, surface_width / width, surface_height / 
height);
   cairo_pattern_set_matrix (pattern, matrix);
 
-  cairo_matrix_init (matrix, mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
-  cairo_transform (cairo, matrix);
+  cairo_transform (cairo, pattern_matrix);
   cairo_set_source (cairo, pattern);
   cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
   if (strokePathClip) {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2014-10-24 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e0179304cdef615fcf639046410d214fd5b5f276
Author: Adrian Johnson ajohn...@redneon.com
Date:   Sun Oct 19 21:36:39 2014 +1030

cairo: fix crash when no group color space

Bug 85137

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 3babb63..03130ac 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1624,7 +1624,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 cairo_t *maskCtx = cairo_create(source);
 
 //XXX: hopefully this uses the correct color space */
-if (!alpha) {
+if (!alpha  groupColorSpaceStack-cs) {
   GfxRGB backdropColorRGB;
   groupColorSpaceStack-cs-getRGB(backdropColor, backdropColorRGB);
   /* paint the backdrop */
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2014-07-24 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   64 ++
 1 file changed, 31 insertions(+), 33 deletions(-)

New commits:
commit 02c127b355bb8a98684a5d0af063c60b8bfd09dd
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Thu Jul 24 10:46:17 2014 +0200

cairo: Make sure we always push a transparency group in 
setSoftMaskFromImageMask()

Because that's what unsetSoftMaskFromImageMask() assumes.

https://bugs.freedesktop.org/show_bug.cgi?id=81624

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index f31b46b..c2827c6 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1880,46 +1880,44 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState 
*state, Object *ref, Stre
 delete imgStr;
 
 invert_bit = invert ? 1 : 0;
-if (pix ^ invert_bit)
-  return;
-
-cairo_save (cairo);
-cairo_rectangle (cairo, 0., 0., width, height);
-cairo_fill (cairo);
-cairo_restore (cairo);
-if (cairo_shape) {
-  cairo_save (cairo_shape);
-  cairo_rectangle (cairo_shape, 0., 0., width, height);
-  cairo_fill (cairo_shape);
-  cairo_restore (cairo_shape);
+if (!(pix ^ invert_bit)) {
+  cairo_save (cairo);
+  cairo_rectangle (cairo, 0., 0., width, height);
+  cairo_fill (cairo);
+  cairo_restore (cairo);
+  if (cairo_shape) {
+cairo_save (cairo_shape);
+cairo_rectangle (cairo_shape, 0., 0., width, height);
+cairo_fill (cairo_shape);
+cairo_restore (cairo_shape);
+  }
 }
-return;
-  }
+  } else {
+cairo_push_group_with_content (cairo, CAIRO_CONTENT_ALPHA);
 
-  cairo_push_group_with_content (cairo, CAIRO_CONTENT_ALPHA);
+/* shape is 1.0 for painted areas, 0.0 for unpainted ones */
 
-  /* shape is 1.0 for painted areas, 0.0 for unpainted ones */
+cairo_matrix_t matrix;
+cairo_get_matrix (cairo, matrix);
+//XXX: it is possible that we should only do sub pixel positioning if 
+// we are rendering fonts */
+if (!printing  prescaleImages  matrix.xy == 0.0  matrix.yx == 0.0) {
+  drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, 
inlineImg);
+} else {
+  drawImageMaskRegular(state, ref, str, width, height, invert, gFalse, 
inlineImg);
+}
 
-  cairo_matrix_t matrix;
-  cairo_get_matrix (cairo, matrix);
-  //XXX: it is possible that we should only do sub pixel positioning if 
-  // we are rendering fonts */
-  if (!printing  prescaleImages  matrix.xy == 0.0  matrix.yx == 0.0) {
-drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, 
inlineImg);
-  } else {
-drawImageMaskRegular(state, ref, str, width, height, invert, gFalse, 
inlineImg);
-  }
+if (state-getFillColorSpace()-getMode() == csPattern) {
+  cairo_set_source_rgb (cairo, 1, 1, 1);
+  cairo_set_matrix (cairo, mask_matrix);
+  cairo_mask (cairo, mask);
+}
 
-  if (state-getFillColorSpace()-getMode() == csPattern) {
-cairo_set_source_rgb (cairo, 1, 1, 1);
-cairo_set_matrix (cairo, mask_matrix);
-cairo_mask (cairo, mask);
+if (mask)
+  cairo_pattern_destroy (mask);
+mask = cairo_pop_group (cairo);
   }
 
-  if (mask)
-cairo_pattern_destroy (mask);
-  mask = cairo_pop_group (cairo);
-
   saveState(state);
   double bbox[4] = {0,0,1,1}; // dummy
   beginTransparencyGroup(state, bbox, state-getFillColorSpace(),
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2013-10-05 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 93e8b05fb2a6d225f048db6a3a735717433a5a13
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Sat Oct 5 11:20:04 2013 +0200

cairo: Do not set an invalid matrix in drawImage()

https://bugs.freedesktop.org/show_bug.cgi?id=70085

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 26760c8..77bd245 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2938,7 +2938,8 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   if (maskPattern) {
 if (!printing)
   cairo_clip (cairo);
-cairo_set_matrix (cairo, mask_matrix);
+if (mask)
+  cairo_set_matrix (cairo, mask_matrix);
 cairo_mask (cairo, maskPattern);
   } else {
 if (printing)
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2013-04-22 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   37 +++--
 1 file changed, 19 insertions(+), 18 deletions(-)

New commits:
commit 3c2a92b06a6541071bd1e555606bb2096de17ef6
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Sat Apr 20 16:41:56 2013 +0200

cairo: Always use the trasnfer function if present in setSoftMask

If the subtype is Alpha, the transparency group XObject G shall be
evaluated to compute a group alpha only. The colours of the constituent
objects shall be ignored and the colour compositing computations shall
not be performed. The transfer function TR shall then be applied to the
computed group alpha to produce the mask values.

We were using the transfer function only for luminosity soft masks.

https://bugs.freedesktop.org/show_bug.cgi?id=63587

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2ff84b6..37e0f1c 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1577,7 +1577,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 
   LOG(printf (set softMask\n));
 
-  if (alpha == false) {
+  if (!alpha || transferFunc) {
 /* We need to mask according to the luminocity of the group.
  * So we paint the group to an image surface convert it to a luminocity map
  * and then use that as the mask. */
@@ -1620,13 +1620,15 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
 cairo_t *maskCtx = cairo_create(source);
 
 //XXX: hopefully this uses the correct color space */
-GfxRGB backdropColorRGB;
-groupColorSpaceStack-cs-getRGB(backdropColor, backdropColorRGB);
-/* paint the backdrop */
-cairo_set_source_rgb(maskCtx,
-colToDbl(backdropColorRGB.r),
-colToDbl(backdropColorRGB.g),
-colToDbl(backdropColorRGB.b));
+if (!alpha) {
+  GfxRGB backdropColorRGB;
+  groupColorSpaceStack-cs-getRGB(backdropColor, backdropColorRGB);
+  /* paint the backdrop */
+  cairo_set_source_rgb(maskCtx,
+   colToDbl(backdropColorRGB.r),
+   colToDbl(backdropColorRGB.g),
+   colToDbl(backdropColorRGB.b));
+}
 cairo_paint(maskCtx);
 
 /* Copy source ctm to mask ctm and translate origin so that the
@@ -1653,15 +1655,14 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
 int stride = cairo_image_surface_get_stride(source)/4;
 for (int y=0; yheight; y++) {
   for (int x=0; xwidth; x++) {
-   int lum;
-   lum = luminocity(source_data[y*stride + x]);
-   if (transferFunc) {
- double lum_in, lum_out;
- lum_in = lum/256.0;
- transferFunc-transform(lum_in, lum_out);
- lum = (int)(lum_out * 255.0 + 0.5);
-   }
-   source_data[y*stride + x] = lum  24;
+   int lum = alpha ? fill_opacity : luminocity(source_data[y*stride + x]);
+if (transferFunc) {
+  double lum_in, lum_out;
+  lum_in = lum/256.0;
+  transferFunc-transform(lum_in, lum_out);
+  lum = (int)(lum_out * 255.0 + 0.5);
+}
+source_data[y*stride + x] = lum  24;
   }
 }
 cairo_surface_mark_dirty (source);
@@ -1681,7 +1682,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 }
 
 cairo_surface_destroy(source);
-  } else {
+  } else if (alpha) {
 mask = cairo_pattern_reference(group);
 cairo_get_matrix(cairo, mask_matrix);
   }
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2013-01-28 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   20 
 poppler/CairoOutputDev.h  |1 +
 2 files changed, 21 insertions(+)

New commits:
commit fbcd64386c1b189db6e06234577261973bdc88cc
Author: Adrian Johnson ajohn...@redneon.com
Date:   Fri Jan 25 22:24:50 2013 +1030

cairo: support uncolored tiling patterns

Bug 59179

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 10df30c..dfa3e0e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -144,6 +144,7 @@ CairoOutputDev::CairoOutputDev() {
   prescaleImages = gTrue;
   printing = gTrue;
   use_show_text_glyphs = gFalse;
+  inUncoloredPattern = gFalse;
   inType3Char = gFalse;
   t3_glyph_has_bbox = gFalse;
 
@@ -461,6 +462,9 @@ void CairoOutputDev::updateLineWidth(GfxState *state) {
 void CairoOutputDev::updateFillColor(GfxState *state) {
   GfxRGB color = fill_color;
 
+  if (inUncoloredPattern)
+return;
+
   state-getFillRGB(fill_color);
   if (cairo_pattern_get_type (fill_pattern) != CAIRO_PATTERN_TYPE_SOLID ||
   color.r != fill_color.r ||
@@ -481,6 +485,9 @@ void CairoOutputDev::updateFillColor(GfxState *state) {
 void CairoOutputDev::updateStrokeColor(GfxState *state) {
   GfxRGB color = stroke_color;
 
+  if (inUncoloredPattern)
+return;
+
   state-getStrokeRGB(stroke_color);
   if (cairo_pattern_get_type (fill_pattern) != CAIRO_PATTERN_TYPE_SOLID ||
   color.r != stroke_color.r ||
@@ -501,6 +508,9 @@ void CairoOutputDev::updateStrokeColor(GfxState *state) {
 void CairoOutputDev::updateFillOpacity(GfxState *state) {
   double opacity = fill_opacity;
 
+  if (inUncoloredPattern)
+return;
+
   fill_opacity = state-getFillOpacity();
   if (opacity != fill_opacity) {
 cairo_pattern_destroy(fill_pattern);
@@ -516,6 +526,9 @@ void CairoOutputDev::updateFillOpacity(GfxState *state) {
 void CairoOutputDev::updateStrokeOpacity(GfxState *state) {
   double opacity = stroke_opacity;
 
+  if (inUncoloredPattern)
+return;
+
   stroke_opacity = state-getStrokeOpacity();
   if (opacity != stroke_opacity) {
 cairo_pattern_destroy(stroke_pattern);
@@ -529,6 +542,9 @@ void CairoOutputDev::updateStrokeOpacity(GfxState *state) {
 }
 
 void CairoOutputDev::updateFillColorStop(GfxState *state, double offset) {
+  if (inUncoloredPattern)
+return;
+
   state-getFillRGB(fill_color);
 
   cairo_pattern_add_color_stop_rgba(fill_pattern, offset,
@@ -852,7 +868,11 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Gfx *gfxA, Catalog *cat
   strokePathTmp = strokePathClip;
   strokePathClip = NULL;
   gfx = new Gfx(doc, this, resDict, box, NULL, NULL, NULL, gfxA-getXRef());
+  if (paintType == 2)
+inUncoloredPattern = gTrue;
   gfx-display(str);
+  if (paintType == 2)
+inUncoloredPattern = gFalse;
   delete gfx;
   strokePathClip = strokePathTmp;
 
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index d35c899..483b161 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -319,6 +319,7 @@ protected:
   int utf8Count;
   int utf8Max;
   cairo_path_t *textClipPath;
+  GBool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2)
   GBool inType3Char;   // inside a Type 3 CharProc
   double t3_glyph_wx, t3_glyph_wy;
   GBool t3_glyph_has_bbox;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-12-01 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 1f279c32dcdc899b509fc00aaa57382bc8af90f3
Author: Albert Astals Cid aa...@kde.org
Date:   Sat Dec 1 20:37:52 2012 +0100

Update copyrights

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index f3fb49e..441ca45 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -27,6 +27,7 @@
 // Copyright (C) 2009, 2010 David Benjamin david...@mit.edu
 // Copyright (C) 2011, 2012 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2012 Patrick Pfeifer p2...@mailinator.com
+// Copyright (C) 2012 Jason Crain ja...@aquaticape.us
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-11-28 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bdb17da35de49b9fd1a549c3afd5e36004552080
Author: Hib Eris h...@hiberis.nl
Date:   Mon Nov 26 20:38:03 2012 +0100

cairo: Fix uninitaliazed warning in CairoOutputDev

Fix warning:

  CXXCairoOutputDev.lo
../../poppler/poppler/CairoOutputDev.cc: In member function 'virtual void 
RescaleDrawImage::getRow(int, uint32_t*)':
../../poppler/poppler/CairoOutputDev.cc:2813:25: warning: 'pix' may be used 
uninitialized in this function [-Wuninitialized]

https://bugs.freedesktop.org/show_bug.cgi?id=57571

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2772bd1..f3fb49e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2797,7 +2797,7 @@ public:
 int i;
 Guchar *pix;
 
-if (row_num == current_row)
+if (row_num = current_row)
   return;
 
 while (current_row   row_num) {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2012-11-21 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   46 ++
 poppler/CairoOutputDev.h  |5 +
 2 files changed, 51 insertions(+)

New commits:
commit e0d0177562ff546b59b3bc8eb68a08dc740d6f6c
Author: Adrian Johnson ajohn...@redneon.com
Date:   Wed Nov 14 22:44:20 2012 +1030

cairo: Fix crash in CairoImageOutputDev with setSoftMaskFromImageMask

Bug 57067

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index d29cbbe..456f826 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -3005,6 +3005,52 @@ void CairoImageOutputDev::drawImageMask(GfxState *state, 
Object *ref, Stream *st
   }
 }
 
+void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object 
*ref, Stream *str,
+   int width, int height, 
GBool invert,
+   GBool inlineImg, double 
*baseMatrix)
+{
+  cairo_t *cr;
+  cairo_surface_t *surface;
+  double x1, y1, x2, y2;
+  double *ctm;
+  double mat[6];
+  CairoImage *image;
+
+  ctm = state-getCTM();
+
+  mat[0] = ctm[0];
+  mat[1] = ctm[1];
+  mat[2] = -ctm[2];
+  mat[3] = -ctm[3];
+  mat[4] = ctm[2] + ctm[4];
+  mat[5] = ctm[3] + ctm[5];
+  x1 = mat[4];
+  y1 = mat[5];
+  x2 = x1 + width;
+  y2 = y1 + height;
+
+  image = new CairoImage (x1, y1, x2, y2);
+  saveImage (image);
+
+  if (imgDrawCbk  imgDrawCbk (numImages - 1, imgDrawCbkData)) {
+surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+cr = cairo_create (surface);
+setCairo (cr);
+cairo_translate (cr, 0, height);
+cairo_scale (cr, width, -height);
+
+CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, 
inlineImg, gFalse);
+if (state-getFillColorSpace()-getMode() == csPattern) {
+  cairo_mask (cairo, mask);
+}
+image-setImage (surface);
+
+setCairo (NULL);
+cairo_surface_destroy (surface);
+cairo_destroy (cr);
+  }
+}
+
 void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height, GfxImageColorMap 
*colorMap,
GBool interpolate, int *maskColors, GBool 
inlineImg)
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index df76975..a699a7b 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -465,6 +465,11 @@ public:
   Stream *maskStr,
   int maskWidth, int maskHeight,
   GBool maskInvert, GBool maskInterpolate);
+  virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream 
*str,
+int width, int height, GBool invert,
+GBool inlineImg, double *baseMatrix);
+  virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) 
{}
+
 
   //- transparency groups and soft masks
   virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-11-20 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

New commits:
commit f050717f986a6c2833876d14083363a540fa849a
Author: Adrian Johnson ajohn...@redneon.com
Date:   Wed Nov 14 23:50:10 2012 +1030

cairo: fix soft mask when image resolution != smask resolution

Both image and mask are drawn the same size (unit square) regardless
of the size of the image data.

Bug 57070

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 0f33d4e..d29cbbe 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2581,9 +2581,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, 
Object *ref, Stream *s
 
   cairo_set_source (cairo, pattern);
   if (!printing) {
-cairo_rectangle (cairo, 0., 0.,
-MIN (width, maskWidth) / (double)width,
-MIN (height, maskHeight) / (double)height);
+cairo_rectangle (cairo, 0., 0., 1., 1.);
 cairo_clip (cairo);
   }
   cairo_mask (cairo, maskPattern);
@@ -2592,9 +2590,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, 
Object *ref, Stream *s
 cairo_pop_group_to_source (cairo);
 cairo_save (cairo);
 if (!printing) {
-  cairo_rectangle (cairo, 0., 0.,
-  MIN (width, maskWidth) / (double)width,
-  MIN (height, maskHeight) / (double)height);
+  cairo_rectangle (cairo, 0., 0., 1., 1.);
   cairo_clip (cairo);
 }
 cairo_paint_with_alpha (cairo, fill_opacity);
@@ -2605,9 +2601,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, 
Object *ref, Stream *s
 cairo_save (cairo_shape);
 cairo_set_source (cairo_shape, pattern);
 if (!printing) {
-  cairo_rectangle (cairo_shape, 0., 0.,
-  MIN (width, maskWidth) / (double)width,
-  MIN (height, maskHeight) / (double)height);
+  cairo_rectangle (cairo_shape, 0., 0., 1., 1.);
   cairo_fill (cairo_shape);
 } else {
   cairo_mask (cairo_shape, pattern);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoRescaleBox.cc poppler/CairoRescaleBox.h

2012-11-18 Thread Adrian Johnson
 poppler/CairoOutputDev.cc  |  278 +++--
 poppler/CairoRescaleBox.cc |  177 +++-
 poppler/CairoRescaleBox.h  |   21 ++-
 3 files changed, 258 insertions(+), 218 deletions(-)

New commits:
commit 87fd5275514b63f13622b79a8fcfe443ccc4f45d
Author: Adrian Johnson ajohn...@redneon.com
Date:   Sun Nov 11 18:53:12 2012 +1030

cairo: make drawImage work with images  32767 in width/height

Cairo images are limited to 32767 in width and height due to the
16.16 format used by pixman. Make drawImage work with large images
by scaling down the image before a cairo image is created.

CairoRescaleBox.cc has been turned into a class with a virtual
function to get the next row of the source image. This allows the
rescale code to access the source data one row at a time to avoid
needing to allocate an image the size of the source image.

A RescaleDrawImage class derived from CairoRescaleBox has been
written to create the cairo source image to be used by drawImage. The
code from drawImage that created the cairo source image has been moved
into RescaleDrawImage::getSourceImage and RescaleDrawImage::getRow.

Bug 56858

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 2cd67c9..0f33d4e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1750,49 +1750,6 @@ void CairoOutputDev::getScaledSize(int  orig_width,
   }
 }
 
-cairo_surface_t *CairoOutputDev::downscaleSurface(cairo_surface_t 
*orig_surface) {
-  cairo_surface_t *dest_surface;
-  unsigned char *dest_buffer;
-  int dest_stride;
-  unsigned char *orig_buffer;
-  int orig_width, orig_height;
-  int orig_stride;
-  int scaledHeight;
-  int scaledWidth;
-  GBool res;
-
-  if (printing)
-return NULL;
-
-  orig_width = cairo_image_surface_get_width (orig_surface);
-  orig_height = cairo_image_surface_get_height (orig_surface);
-  getScaledSize (orig_width, orig_height, scaledWidth, scaledHeight);
-  if (scaledWidth = orig_width || scaledHeight = orig_height)
-return NULL;
-
-  dest_surface = cairo_surface_create_similar (orig_surface,
-  cairo_surface_get_content 
(orig_surface),
-  scaledWidth, scaledHeight);
-  dest_buffer = cairo_image_surface_get_data (dest_surface);
-  dest_stride = cairo_image_surface_get_stride (dest_surface);
-
-  orig_buffer = cairo_image_surface_get_data (orig_surface);
-  orig_stride = cairo_image_surface_get_stride (orig_surface);
-
-  res = downscale_box_filter((uint32_t *)orig_buffer,
-orig_stride, orig_width, orig_height,
-scaledWidth, scaledHeight, 0, 0,
-scaledWidth, scaledHeight,
-(uint32_t *)dest_buffer, dest_stride);
-  if (!res) {
-cairo_surface_destroy (dest_surface);
-return NULL;
-  }
-
-  return dest_surface;
-
-}
-
 cairo_filter_t
 CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
GBool interpolate)
@@ -2738,63 +2695,119 @@ void CairoOutputDev::setMimeData(Stream *str, Object 
*ref, cairo_surface_t *imag
   }
 }
 
-void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
-  int width, int height,
-  GfxImageColorMap *colorMap,
-  GBool interpolate,
-  int *maskColors, GBool inlineImg)
-{
-  cairo_surface_t *image;
-  cairo_pattern_t *pattern, *maskPattern;
+class RescaleDrawImage : public CairoRescaleBox {
+private:
   ImageStream *imgStr;
-  cairo_matrix_t matrix;
-  unsigned char *buffer;
-  int stride, i;
-  GfxRGB *lookup = NULL;
-  cairo_filter_t filter = CAIRO_FILTER_BILINEAR;
-
-  /* TODO: Do we want to cache these? */
-  imgStr = new ImageStream(str, width,
-  colorMap-getNumPixelComps(),
-  colorMap-getBits());
-  imgStr-reset();
+  GfxRGB *lookup;
+  int width;
+  GfxImageColorMap *colorMap;
+  int *maskColors;
+  int current_row;
+
+public:
+  cairo_surface_t *getSourceImage(Stream *str,
+  int widthA, int height,
+  int scaledWidth, int scaledHeight,
+  GBool printing,
+  GfxImageColorMap *colorMapA,
+  int *maskColorsA) {
+cairo_surface_t *image = NULL;
+int i;
+
+lookup = NULL;
+colorMap = colorMapA;
+maskColors = maskColorsA;
+width = widthA;
+current_row = -1;
+
+/* TODO: Do we want to cache these? */
+imgStr = new ImageStream(str, width,
+ colorMap-getNumPixelComps(),
+ colorMap-getBits());
+imgStr-reset();
 
 #if 0
-  /* ICCBased color space doesn't do any color 

[poppler] poppler/CairoOutputDev.cc

2012-11-02 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

New commits:
commit ae8fc0cbfc6123189e17b3cf1286e0540f181646
Author: Adrian Johnson ajohn...@redneon.com
Date:   Tue Oct 30 21:22:04 2012 +1030

cairo: support parameterized Gouraud shading

Bug 56463

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index bab4562..2cd67c9 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -945,10 +945,21 @@ GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState 
*state, GfxGouraudTrian
   fill_pattern = cairo_pattern_create_mesh ();
 
   for (i = 0; i  shading-getNTriangles(); i++) {
-shading-getTriangle(i,
-x0, y0, color[0],
-x1, y1, color[1],
-x2, y2, color[2]);
+if (shading-isParameterized()) {
+  double color0, color1, color2;
+  shading-getTriangle(i, x0, y0, color0,
+  x1, y1, color1,
+  x2, y2, color2);
+  shading-getParameterizedColor(color0, color[0]);
+  shading-getParameterizedColor(color1, color[1]);
+  shading-getParameterizedColor(color2, color[2]);
+} else {
+  shading-getTriangle(i,
+   x0, y0, color[0],
+   x1, y1, color[1],
+   x2, y2, color[2]);
+
+}
 
 cairo_mesh_pattern_begin_patch (fill_pattern);
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-04-02 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 4e940b14a6fddde9a1714976ff8045e26cbf7d40
Author: Adrian Johnson ajohn...@redneon.com
Date:   Mon Apr 2 20:03:11 2012 +0930

cairo: fix regression caused by mesh gradients

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index c021e4c..22fdaca 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -454,7 +454,8 @@ void CairoOutputDev::updateFillColor(GfxState *state) {
   GfxRGB color = fill_color;
 
   state-getFillRGB(fill_color);
-  if (color.r != fill_color.r ||
+  if (cairo_pattern_get_type (fill_pattern) != CAIRO_PATTERN_TYPE_SOLID ||
+  color.r != fill_color.r ||
   color.g != fill_color.g ||
   color.b != fill_color.b)
   {
@@ -473,7 +474,8 @@ void CairoOutputDev::updateStrokeColor(GfxState *state) {
   GfxRGB color = stroke_color;
 
   state-getStrokeRGB(stroke_color);
-  if (color.r != stroke_color.r ||
+  if (cairo_pattern_get_type (fill_pattern) != CAIRO_PATTERN_TYPE_SOLID ||
+  color.r != stroke_color.r ||
   color.g != stroke_color.g ||
   color.b != stroke_color.b)
   {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2012-03-23 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   40 
 poppler/CairoOutputDev.h  |4 ++--
 2 files changed, 22 insertions(+), 22 deletions(-)

New commits:
commit 7b57afea2e433fc7b6f359a62b1289f0e1da3267
Author: Adrian Johnson ajohn...@redneon.com
Date:   Sat Mar 24 08:27:34 2012 +1030

cairo: update cairo mesh pattern to 1.12 api

Now that a stable version of cairo with mesh gradient support is
released update poppler to use this api.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 6652a35..40c6fce 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -889,7 +889,7 @@ GBool CairoOutputDev::radialShadedSupportExtend(GfxState 
*state, GfxRadialShadin
   return (shading-getExtend0() == shading-getExtend1());
 }
 
-#if CAIRO_VERSION == CAIRO_VERSION_ENCODE(1, 11, 2)
+#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 12, 0)
 GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state, 
GfxGouraudTriangleShading *shading)
 {
   double x0, y0, x1, y1, x2, y2;
@@ -906,21 +906,21 @@ GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState 
*state, GfxGouraudTrian
 x1, y1, color[1],
 x2, y2, color[2]);
 
-cairo_pattern_mesh_begin_patch (fill_pattern);
+cairo_mesh_pattern_begin_patch (fill_pattern);
 
-cairo_pattern_mesh_move_to (fill_pattern, x0, y0);
-cairo_pattern_mesh_line_to (fill_pattern, x1, y1);
-cairo_pattern_mesh_line_to (fill_pattern, x2, y2);
+cairo_mesh_pattern_move_to (fill_pattern, x0, y0);
+cairo_mesh_pattern_line_to (fill_pattern, x1, y1);
+cairo_mesh_pattern_line_to (fill_pattern, x2, y2);
 
 for (j = 0; j  3; j++) {
shading-getColorSpace()-getRGB(color[j], rgb);
-   cairo_pattern_mesh_set_corner_color_rgb (fill_pattern, j,
+   cairo_mesh_pattern_set_corner_color_rgb (fill_pattern, j,
 colToDbl(rgb.r),
 colToDbl(rgb.g),
 colToDbl(rgb.b));
 }
 
-cairo_pattern_mesh_end_patch (fill_pattern);
+cairo_mesh_pattern_end_patch (fill_pattern);
   }
 
   double xMin, yMin, xMax, yMax;
@@ -949,33 +949,33 @@ GBool CairoOutputDev::patchMeshShadedFill(GfxState 
*state, GfxPatchMeshShading *
 GfxColor color;
 GfxRGB rgb;
 
-cairo_pattern_mesh_begin_patch (fill_pattern);
+cairo_mesh_pattern_begin_patch (fill_pattern);
 
-cairo_pattern_mesh_move_to (fill_pattern, patch-x[0][0], patch-y[0][0]);
-cairo_pattern_mesh_curve_to (fill_pattern,
+cairo_mesh_pattern_move_to (fill_pattern, patch-x[0][0], patch-y[0][0]);
+cairo_mesh_pattern_curve_to (fill_pattern,
patch-x[0][1], patch-y[0][1],
patch-x[0][2], patch-y[0][2],
patch-x[0][3], patch-y[0][3]);
 
-cairo_pattern_mesh_curve_to (fill_pattern,
+cairo_mesh_pattern_curve_to (fill_pattern,
patch-x[1][3], patch-y[1][3],
patch-x[2][3], patch-y[2][3],
patch-x[3][3], patch-y[3][3]);
 
-cairo_pattern_mesh_curve_to (fill_pattern,
+cairo_mesh_pattern_curve_to (fill_pattern,
patch-x[3][2], patch-y[3][2],
patch-x[3][1], patch-y[3][1],
patch-x[3][0], patch-y[3][0]);
 
-cairo_pattern_mesh_curve_to (fill_pattern,
+cairo_mesh_pattern_curve_to (fill_pattern,
patch-x[2][0], patch-y[2][0],
patch-x[1][0], patch-y[1][0],
patch-x[0][0], patch-y[0][0]);
 
-cairo_pattern_mesh_set_control_point (fill_pattern, 0, patch-x[1][1], 
patch-y[1][1]);
-cairo_pattern_mesh_set_control_point (fill_pattern, 1, patch-x[1][2], 
patch-y[1][2]);
-cairo_pattern_mesh_set_control_point (fill_pattern, 2, patch-x[2][2], 
patch-y[2][2]);
-cairo_pattern_mesh_set_control_point (fill_pattern, 3, patch-x[2][1], 
patch-y[2][1]);
+cairo_mesh_pattern_set_control_point (fill_pattern, 0, patch-x[1][1], 
patch-y[1][1]);
+cairo_mesh_pattern_set_control_point (fill_pattern, 1, patch-x[1][2], 
patch-y[1][2]);
+cairo_mesh_pattern_set_control_point (fill_pattern, 2, patch-x[2][2], 
patch-y[2][2]);
+cairo_mesh_pattern_set_control_point (fill_pattern, 3, patch-x[2][1], 
patch-y[2][1]);
 
 for (j = 0; j  4; j++) {
   int u, v;
@@ -1005,12 +1005,12 @@ GBool CairoOutputDev::patchMeshShadedFill(GfxState 
*state, GfxPatchMeshShading *
   }
 
   shading-getColorSpace()-getRGB(color, rgb);
-  cairo_pattern_mesh_set_corner_color_rgb (fill_pattern, j,
+  cairo_mesh_pattern_set_corner_color_rgb (fill_pattern, j,
   colToDbl(rgb.r),
   colToDbl(rgb.g),
   

[poppler] poppler/CairoOutputDev.cc

2012-02-19 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit aaae8996766f259dcc329755c7cccde7c916c1fb
Author: Adrian Johnson ajohn...@redneon.com
Date:   Thu Feb 16 22:22:15 2012 +1030

cairo: set mask matrix before drawing an image with a mask

Bug 40828

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 36d58c4..5dc8639 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2811,6 +2811,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   if (maskPattern) {
 if (!printing)
   cairo_clip (cairo);
+cairo_set_matrix (cairo, mask_matrix);
 cairo_mask (cairo, maskPattern);
   } else {
 if (printing)
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-02-15 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 119b6b752314c9b13440eddf5bd1d5cef2966e80
Author: Adrian Johnson ajohn...@redneon.com
Date:   Mon Feb 6 16:50:11 2012 +1030

cairo: don't read inline image streams twice

Bug 45668

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index ec28fb6..dab1e47 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2775,7 +2775,8 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
 
   cairo_surface_mark_dirty (image);
 
-  setMimeData(str, ref, image);
+  if (!inlineImg) /* don't read stream twice if it is an inline image */
+setMimeData(str, ref, image);
 
   pattern = cairo_pattern_create_for_surface (image);
   cairo_surface_destroy (image);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-01-20 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit ce1b6c7ca16847f07eeafc29c6503be6fa5a9a3d
Author: Patrick Pfeifer p2...@mailinator.com
Date:   Thu Jan 19 14:54:48 2012 +0100

cairo: Fix test for rotation

Fixes bug #14619.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 051f5d0..d49b87f 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1834,7 +1834,11 @@ void CairoOutputDev::drawImageMask(GfxState *state, 
Object *ref, Stream *str,
   cairo_get_matrix (cairo, matrix);
   //XXX: it is possible that we should only do sub pixel positioning if 
   // we are rendering fonts */
-  if (!printing  prescaleImages  matrix.xy == 0.0  matrix.yx == 0.0) {
+  if (!printing  prescaleImages
+  /* not rotated */
+   matrix.xy == 0  matrix.yx == 0
+  /* axes not flipped / not 180 deg rotated */
+   matrix.xx  0  (upsideDown() ? -1 : 1) * matrix.yy  0) {
 drawImageMaskPrescaled(state, ref, str, width, height, invert, 
interpolate, inlineImg);
   } else {
 drawImageMaskRegular(state, ref, str, width, height, invert, interpolate, 
inlineImg);
@@ -1969,6 +1973,8 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState 
*state, Object *ref, Stream
 
   /* cairo does a very poor job of scaling down images so we scale them 
ourselves */
 
+  LOG (printf (drawImageMaskPrescaled %dx%d\n, width, height));
+
   /* this scaling code is adopted from the splash image scaling code */
   cairo_get_matrix(cairo, matrix);
 #if 0
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-01-20 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a04fca6266bda6d04068f38f16fe492cb6b8677b
Author: Adrian Johnson ajohn...@redneon.com
Date:   Sat Jan 21 09:41:12 2012 +1030

cairo: use fabs when comparing the transformed line width

as the transform may cause a negative width.

Bug 43441

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index d49b87f..7ef36df 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -439,7 +439,7 @@ void CairoOutputDev::updateLineWidth(GfxState *state) {
 
   /* find out line width in device units */
   cairo_user_to_device_distance(cairo, x, y);
-  if (x = 1.0  y = 1.0) {
+  if (fabs(x) = 1.0  fabs(y) = 1.0) {
/* adjust width to at least one device pixel */
x = y = 1.0;
cairo_device_to_user_distance(cairo, x, y);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2012-01-19 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |8 ++--
 poppler/CairoOutputDev.h  |1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit e8e42988c5cebab2ffa5fe020f30a3a645e90b5f
Author: Adrian Johnson ajohn...@redneon.com
Date:   Mon Jan 16 21:25:19 2012 +1030

cairo: ensure paintTransparencyGroup uses same ctm as beginTransparencyGroup

Bug 29968

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index db7e654..051f5d0 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1396,6 +1396,7 @@ void CairoOutputDev::beginTransparencyGroup(GfxState * 
/*state*/, double * /*bbo
   ColorSpaceStack* css = new ColorSpaceStack;
   css-cs = blendingColorSpace;
   css-knockout = knockout;
+  cairo_get_matrix(cairo, css-group_matrix);
   css-next = groupColorSpaceStack;
   groupColorSpaceStack = css;
 
@@ -1452,10 +1453,12 @@ void CairoOutputDev::endTransparencyGroup(GfxState * 
/*state*/) {
 }
 
 void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * 
/*bbox*/) {
-  cairo_set_source (cairo, group);
-
   LOG(printf (paint transparency group\n));
 
+  cairo_save (cairo);
+  cairo_set_matrix (cairo, groupColorSpaceStack-group_matrix);
+  cairo_set_source (cairo, group);
+
   if (!mask) {
 //XXX: deal with mask  shape case
 if (shape) {
@@ -1495,6 +1498,7 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * 
/*state*/, double * /*bbo
   }
 
   popTransparencyGroup();
+  cairo_restore(cairo);
 }
 
 static int luminocity(uint32_t x)
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 949d459..b2e6fb2 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -348,6 +348,7 @@ protected:
   struct ColorSpaceStack {
 GBool knockout;
 GfxColorSpace *cs;
+cairo_matrix_t group_matrix;
 struct ColorSpaceStack *next;
   } * groupColorSpaceStack;
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-01-16 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 100488ec7db2d1f3e25bfda42c1603ca86696195
Author: Adrian Johnson ajohn...@redneon.com
Date:   Sun Jan 15 23:52:28 2012 +1030

cairo: restore temporary clip used in CairoOutputDev::fill when painting a 
mask

The clip is only used to clip the paint to the fill path so it should
be moved inside the save/restore.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index e2ecfda..db7e654 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -729,8 +729,8 @@ void CairoOutputDev::fill(GfxState *state) {
   LOG(printf (fill\n));
   //XXX: how do we get the path
   if (mask) {
-cairo_clip (cairo);
 cairo_save (cairo);
+cairo_clip (cairo);
 cairo_set_matrix (cairo, mask_matrix);
 cairo_mask (cairo, mask);
 cairo_restore (cairo);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2012-01-11 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 9b8b4232587831fdada37de033c272a3c5049c34
Author: Adrian Johnson ajohn...@redneon.com
Date:   Thu Jan 12 00:26:03 2012 +1030

cairo: avoid setting huge clip area when printing

Bug 44002

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index fae0136..e2ecfda 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2779,15 +2779,17 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
 
   cairo_save (cairo);
   cairo_set_source (cairo, pattern);
-  if (printing)
-cairo_rectangle (cairo, 0., 0., width, height);
-  else
+  if (!printing)
 cairo_rectangle (cairo, 0., 0., 1., 1.);
   if (maskPattern) {
-cairo_clip (cairo);
+if (!printing)
+  cairo_clip (cairo);
 cairo_mask (cairo, maskPattern);
   } else {
-cairo_fill (cairo);
+if (printing)
+  cairo_paint (cairo);
+else
+  cairo_fill (cairo);
   }
   cairo_restore (cairo);
 
@@ -2796,11 +2798,12 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   if (cairo_shape) {
 cairo_save (cairo_shape);
 cairo_set_source (cairo_shape, pattern);
-if (printing)
-  cairo_rectangle (cairo_shape, 0., 0., width, height);
-else
+if (printing) {
+  cairo_paint (cairo_shape);
+} else {
   cairo_rectangle (cairo_shape, 0., 0., 1., 1.);
-cairo_fill (cairo_shape);
+  cairo_fill (cairo_shape);
+}
 cairo_restore (cairo_shape);
   }
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2011-10-17 Thread Adrian Johnson
 poppler/CairoOutputDev.cc |   97 --
 poppler/CairoOutputDev.h  |6 +-
 2 files changed, 65 insertions(+), 38 deletions(-)

New commits:
commit 4bb34757dbbff780baba053371274c05b29771e1
Author: Adrian Johnson ajohn...@redneon.com
Date:   Mon Sep 19 21:11:44 2011 +0930

cairo: fix setSoftMask bugs

- Getting the clip extents in device space requires transforming all
  four corners of the clip extents and translating by the group device
  offset other wise the device extents will not be correct for rotated
  ctm.

- Adjust matrix to include translation of the clip extents origin
  since the mask surface does not start at (0,0).

- the ctm when called cairo_mask() needs to be the same as the ctm when
  the mask was created.

- implement transfer function in setSoftMask

Bug 41005

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 30c69f1..fae0136 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -78,6 +78,11 @@ static inline void printMatrix(cairo_matrix_t *matrix){
matrix-x0, matrix-y0);
 }
 
+
+#define MIN(a,b) (((a)  (b)) ? (a) : (b))
+#define MAX(a,b) (((a)  (b)) ? (a) : (b))
+
+
 //
 // CairoImage
 //
@@ -261,6 +266,7 @@ void CairoOutputDev::saveState(GfxState *state) {
 
   MaskStack *ms = new MaskStack;
   ms-mask = cairo_pattern_reference(mask);
+  ms-mask_matrix = mask_matrix;
   ms-next = maskStack;
   maskStack = ms;
 }
@@ -284,6 +290,7 @@ void CairoOutputDev::restoreState(GfxState *state) {
 if (mask)
   cairo_pattern_destroy(mask);
 mask = ms-mask;
+mask_matrix = ms-mask_matrix;
 maskStack = ms-next;
 delete ms;
   }
@@ -410,8 +417,6 @@ void CairoOutputDev::updateMiterLimit(GfxState *state) {
 cairo_set_miter_limit (cairo_shape, state-getMiterLimit());
 }
 
-#define MIN(a,b) (((a)  (b)) ? (a) : (b))
-
 void CairoOutputDev::updateLineWidth(GfxState *state) {
   LOG(printf (line width: %f\n, state-getLineWidth()));
   adjusted_stroke_width = gFalse;
@@ -725,7 +730,10 @@ void CairoOutputDev::fill(GfxState *state) {
   //XXX: how do we get the path
   if (mask) {
 cairo_clip (cairo);
+cairo_save (cairo);
+cairo_set_matrix (cairo, mask_matrix);
 cairo_mask (cairo, mask);
+cairo_restore (cairo);
   } else if (strokePathClip) {
 fillToStrokePathClip();
   } else {
@@ -1477,7 +1485,10 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * 
/*state*/, double * /*bbo
 if (status)
   printf(BAD status: %s\n, cairo_status_to_string(status));
   } else {
+cairo_save(cairo);
+cairo_set_matrix(cairo, mask_matrix);
 cairo_mask(cairo, mask);
+cairo_restore(cairo);
 
 cairo_pattern_destroy(mask);
 mask = NULL;
@@ -1486,14 +1497,14 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * 
/*state*/, double * /*bbo
   popTransparencyGroup();
 }
 
-static uint32_t luminocity(uint32_t x)
+static int luminocity(uint32_t x)
 {
   int r = (x  16)  0xff;
   int g = (x   8)  0xff;
   int b = (x   0)  0xff;
   // an arbitrary integer approximation of .3*r + .59*g + .11*b
   int y = (r*19661+g*38666+b*7209 + 32829)16;
-  return y  24;
+  return y;
 }
 
 
@@ -1509,24 +1520,39 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
  * So we paint the group to an image surface convert it to a luminocity map
  * and then use that as the mask. */
 
-double x1, y1, x2, y2, tmp;
+/* Get clip extents in device space */
+double x1, y1, x2, y2, x_min, y_min, x_max, y_max;
 cairo_clip_extents(cairo, x1, y1, x2, y2);
 cairo_user_to_device(cairo, x1, y1);
 cairo_user_to_device(cairo, x2, y2);
-if (x1  x2) {
-  tmp = x1;
-  x1 = x2;
-  x2 = tmp;
-}
+x_min = MIN(x1, x2);
+y_min = MIN(y1, y2);
+x_max = MAX(x1, x2);
+y_max = MAX(y1, y2);
+cairo_clip_extents(cairo, x1, y1, x2, y2);
+cairo_user_to_device(cairo, x1, y2);
+cairo_user_to_device(cairo, x2, y1);
+x_min = MIN(x_min,MIN(x1, x2));
+y_min = MIN(y_min,MIN(y1, y2));
+x_max = MAX(x_max,MAX(x1, x2));
+y_max = MAX(y_max,MAX(y1, y2));
+
+int width = (int)(ceil(x_max) - floor(x_min));
+int height = (int)(ceil(y_max) - floor(y_min));
 
-if (y1  y2) {
-  tmp = y1;
-  y1 = y2;
-  y2 = tmp;
+/* Get group device offset */
+double x_offset, y_offset;
+if (cairo_get_group_target(cairo) == cairo_get_target(cairo)) {
+  cairo_surface_get_device_offset(cairo_get_group_target(cairo), 
x_offset, y_offset);
+} else {
+  cairo_surface_t *pats;
+  cairo_pattern_get_surface(group, pats);
+  cairo_surface_get_device_offset(pats, x_offset, y_offset);
 }
 
-int width = (int)(ceil(x2) - floor(x1));
-int height = 

[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2011-08-22 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   52 +-
 poppler/CairoOutputDev.h  |   17 +--
 2 files changed, 66 insertions(+), 3 deletions(-)

New commits:
commit 3a574f13fa22b7c31eda0d0437f4094a5a39ff34
Author: Adrian Johnson ajohn...@redneon.com
Date:   Fri Aug 19 23:23:24 2011 +0930

cairo: fix stroke patterns

Since cairo still does not yet have cairo_stroke_to_path(), this
implements a workaround for stroke patterns. In clipToStrokePath, the
stroke path and stroke parameters are saved. In tilingPatternFill and
fill (used to draw shading patterns) if a stroke path clip has been
saved, the current pattern is stroked instead of filled using the
saved stroke.
Fixes bug #11719.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 08c28ec..cdca10d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -133,6 +133,7 @@ CairoOutputDev::CairoOutputDev() {
   stroke_opacity = 1.0;
   fill_opacity = 1.0;
   textClipPath = NULL;
+  strokePathClip = NULL;
   haveCSPattern = gFalse;
   cairo = NULL;
   currentFont = NULL;
@@ -673,6 +674,8 @@ void CairoOutputDev::fill(GfxState *state) {
   if (mask) {
 cairo_clip (cairo);
 cairo_mask (cairo, mask);
+  } else if (strokePathClip) {
+fillToStrokePathClip();
   } else {
 cairo_fill (cairo);
   }
@@ -713,6 +716,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Catalog *cat, Object *s
   double xMin, yMin, xMax, yMax;
   double width, height;
   int surface_width, surface_height;
+  StrokePathClip *strokePathTmp;
 
   width = bbox[2] - bbox[0];
   height = bbox[3] - bbox[1];
@@ -736,9 +740,12 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Catalog *cat, Object *s
 
   box.x1 = bbox[0]; box.y1 = bbox[1];
   box.x2 = bbox[2]; box.y2 = bbox[3];
+  strokePathTmp = strokePathClip;
+  strokePathClip = NULL;
   gfx = new Gfx(xref, this, resDict, catalog, box, NULL);
   gfx-display(str);
   delete gfx;
+  strokePathClip = strokePathTmp;
 
   pattern = cairo_pattern_create_for_surface (cairo_get_target (cairo));
   cairo_destroy (cairo);
@@ -756,7 +763,11 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Catalog *cat, Object *s
   cairo_transform (cairo, matrix);
   cairo_set_source (cairo, pattern);
   cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
-  cairo_fill (cairo);
+  if (strokePathClip) {
+fillToStrokePathClip();
+  } else {
+cairo_fill (cairo);
+  }
 
   cairo_pattern_destroy (pattern);
 
@@ -987,6 +998,45 @@ void CairoOutputDev::eoClip(GfxState *state) {
 
 void CairoOutputDev::clipToStrokePath(GfxState *state) {
   LOG(printf(clip-to-stroke-path\n));
+  strokePathClip = (StrokePathClip*)gmalloc (sizeof(*strokePathClip));
+  doPath (cairo, state, state-getPath());
+  strokePathClip-path = cairo_copy_path (cairo);
+  cairo_get_matrix (cairo, strokePathClip-ctm);
+  strokePathClip-line_width = cairo_get_line_width (cairo);
+  strokePathClip-dash_count = cairo_get_dash_count (cairo);
+  if (strokePathClip-dash_count) {
+strokePathClip-dashes = (double*) gmallocn (sizeof(double), 
strokePathClip-dash_count);
+cairo_get_dash (cairo, strokePathClip-dashes, 
strokePathClip-dash_offset);
+  } else {
+strokePathClip-dashes = NULL;
+  }
+  strokePathClip-cap = cairo_get_line_cap (cairo);
+  strokePathClip-join = cairo_get_line_join (cairo);
+  strokePathClip-miter = cairo_get_miter_limit (cairo);
+}
+
+void CairoOutputDev::fillToStrokePathClip() {
+  cairo_save (cairo);
+
+  cairo_set_matrix (cairo, strokePathClip-ctm);
+  cairo_set_line_width (cairo, strokePathClip-line_width);
+  strokePathClip-dash_count = cairo_get_dash_count (cairo);
+  cairo_set_dash (cairo, strokePathClip-dashes, strokePathClip-dash_count, 
strokePathClip-dash_offset);
+  cairo_set_line_cap (cairo, strokePathClip-cap);
+  cairo_set_line_join (cairo, strokePathClip-join);
+  cairo_set_miter_limit (cairo, strokePathClip-miter);
+
+  cairo_new_path (cairo);
+  cairo_append_path (cairo, strokePathClip-path);
+  cairo_stroke (cairo);
+
+  cairo_restore (cairo);
+
+  cairo_path_destroy (strokePathClip-path);
+  if (strokePathClip-dashes)
+gfree (strokePathClip-dashes);
+  gfree (strokePathClip);
+  strokePathClip = NULL;
 }
 
 void CairoOutputDev::beginString(GfxState *state, GooString *s)
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 67f7810..b8c0703 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -281,13 +281,26 @@ protected:
 GBool interpolate);
   GBool getStreamData (Stream *str, char **buffer, int *length);
   void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
-  
+  void fillToStrokePathClip();
+
   GfxRGB fill_color, stroke_color;
   cairo_pattern_t *fill_pattern, *stroke_pattern;
   double fill_opacity;
   double stroke_opacity;
   CairoFont *currentFont;
-  
+
+  struct StrokePathClip {
+

[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/OutputDev.h poppler/PreScanOutputDev.cc poppler/PreScanOutputDev.h poppler/PSOutputDev.cc poppler/PSOutputDev.h popp

2011-03-21 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc   |5 
 poppler/CairoOutputDev.h|   10 -
 poppler/Gfx.cc  |6 
 poppler/OutputDev.h |6 
 poppler/PSOutputDev.cc  |8 -
 poppler/PSOutputDev.h   |6 
 poppler/PreScanOutputDev.cc |   22 +++
 poppler/PreScanOutputDev.h  |   16 ++
 poppler/SplashOutputDev.cc  |  265 
 poppler/SplashOutputDev.h   |   12 +
 10 files changed, 334 insertions(+), 22 deletions(-)

New commits:
commit abf167af8b15e5f3b510275ce619e6fdb42edd40
Author: Thomas Freitag thomas.frei...@alfa.de
Date:   Mon Mar 21 21:34:46 2011 +

Implement tiling/patterns in SplashOutputDev

Fixes bug 13518

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index de0663c..477030a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -25,6 +25,7 @@
 // Copyright (C) 2008, 2009 Chris Wilson ch...@chris-wilson.co.uk
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
 // Copyright (C) 2009, 2010 David Benjamin david...@mit.edu
+// Copyright (C) 2011 Thomas Freitag thomas.frei...@alfa.de
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -690,8 +691,8 @@ void CairoOutputDev::eoFill(GfxState *state) {
 
 }
 
-GBool CairoOutputDev::tilingPatternFill(GfxState *state, Object *str,
-   int paintType, Dict *resDict,
+GBool CairoOutputDev::tilingPatternFill(GfxState *state, Catalog *cat, Object 
*str,
+   double *pmat, int paintType, Dict 
*resDict,
double *mat, double *bbox,
int x0, int y0, int x1, int y1,
double xStep, double yStep)
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 8ef2a93..730a23c 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -20,7 +20,7 @@
 // Copyright (C) 2006-2011 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2008, 2009, 2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
-// Copyright (C) 2010 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2010, 2011 Thomas Freitag thomas.frei...@alfa.de
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -158,8 +158,8 @@ public:
   virtual void fill(GfxState *state);
   virtual void eoFill(GfxState *state);
   virtual void clipToStrokePath(GfxState *state);
-  virtual GBool tilingPatternFill(GfxState *state, Object *str,
- int paintType, Dict *resDict,
+  virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str,
+ double *pmat, int paintType, Dict *resDict,
  double *mat, double *bbox,
  int x0, int y0, int x1, int y1,
  double xStep, double yStep);
@@ -411,8 +411,8 @@ public:
   virtual void stroke(GfxState *state) { }
   virtual void fill(GfxState *state) { }
   virtual void eoFill(GfxState *state) { }
-  virtual GBool tilingPatternFill(GfxState *state, Object *str,
- int paintType, Dict *resDict,
+  virtual GBool tilingPatternFill(GfxState *state, Catalog *cat, Object *str,
+ double *pmat, int paintType, Dict *resDict,
  double *mat, double *bbox,
  int x0, int y0, int x1, int y1,
  double xStep, double yStep) { return gTrue; }
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index daf50d3..dc5f8e3 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -28,7 +28,7 @@
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
 // Copyright (C) 2009 M Joonas Pihlaja jpihl...@cc.helsinki.fi
-// Copyright (C) 2009, 2010 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2009-2011 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2009 William Bader williamba...@hotmail.com
 // Copyright (C) 2009, 2010 David Benjamin david...@mit.edu
 // Copyright (C) 2010 Nils Höglund nils.hogl...@gmail.com
@@ -2082,8 +2082,8 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
 m1[4] = m[4];
 m1[5] = m[5];
 if (out-useTilingPatternFill() 
-   out-tilingPatternFill(state, tPat-getContentStream(),
-  tPat-getPaintType(), tPat-getResDict(),
+   out-tilingPatternFill(state, catalog, tPat-getContentStream(),
+  tPat-getMatrix(), tPat-getPaintType(), 
tPat-getResDict(),
   m1, tPat-getBBox(),
   xi0, yi0, xi1, yi1, xstep, ystep)) {

[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/OutputDev.h poppler/TextOutputDev.cc

2011-02-27 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc |2 +-
 poppler/CairoOutputDev.h  |2 +-
 poppler/Gfx.cc|2 +-
 poppler/OutputDev.h   |2 +-
 poppler/TextOutputDev.cc  |1 +
 5 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit bd4cc73e438a7d4d4a10c50c69e65b5bdc63ddf2
Author: Albert Astals Cid aa...@kde.org
Date:   Sun Feb 27 11:04:45 2011 +

Some more missing copyrights

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 35f2b45..2ee5167 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -18,7 +18,7 @@
 // Copyright (C) 2005, 2006 Kristian Høgsberg k...@redhat.com
 // Copyright (C) 2005, 2009 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2005 Nickolay V. Shmyrev nshmy...@yandex.ru
-// Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
+// Copyright (C) 2006-2011 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2008 Carl Worth cwo...@cworth.org
 // Copyright (C) 2008-2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index e6fde85..9404d6d 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2005-2008 Jeff Muizelaar j...@infidigm.net
 // Copyright (C) 2005, 2006 Kristian Høgsberg k...@redhat.com
 // Copyright (C) 2005 Nickolay V. Shmyrev nshmy...@yandex.ru
-// Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
+// Copyright (C) 2006-2011 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2008, 2009, 2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2010 Thomas Freitag thomas.frei...@alfa.de
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 9cff25f..daf50d3 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2006, 2007 Jeff Muizelaar j...@infidigm.net
 // Copyright (C) 2007, 2008 Brad Hards br...@kde.org
-// Copyright (C) 2007 Adrian Johnson ajohn...@redneon.com
+// Copyright (C) 2007, 2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2007, 2008 Iñigo Martínez inigomarti...@gmail.com
 // Copyright (C) 2007 Koji Otani s...@bbr.jp
 // Copyright (C) 2007 Krzysztof Kowalczyk kkowalc...@gmail.com
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index af016b6..65cfa2d 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -16,7 +16,7 @@
 // Copyright (C) 2005 Jonathan Blandford j...@redhat.com
 // Copyright (C) 2006 Thorkild Stray thork...@ifi.uio.no
 // Copyright (C) 2007 Jeff Muizelaar j...@infidigm.net
-// Copyright (C) 2007 Adrian Johnson ajohn...@redneon.com
+// Copyright (C) 2007, 2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2009, 2010 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2009 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2009 Albert Astals Cid aa...@kde.org
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 71b946e..a946ba6 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -24,6 +24,7 @@
 // Copyright (C) 2009 Kovid Goyal ko...@kovidgoyal.net
 // Copyright (C) 2010 Brian Ewins brian.ew...@gmail.com
 // Copyright (C) 2010 Suzuki Toshiya mpsuz...@hiroshima-u.ac.jp
+// Copyright (C) 2011 Sam Liao phy...@gmail.com
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2011-02-26 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |4 ++--
 poppler/CairoOutputDev.h  |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 7a68199b342eb3f33733f7d7446ede8f94130fba
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Sat Feb 26 11:09:27 2011 +0100

cairo: Check if cairo version is == 1.11.2 to use mesh gradients api

Cairo API has changed in 1.11.3.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 18fc480..7ffeb1f 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -816,7 +816,7 @@ GBool CairoOutputDev::radialShadedSupportExtend(GfxState 
*state, GfxRadialShadin
   return (shading-getExtend0() == shading-getExtend1());
 }
 
-#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
+#if CAIRO_VERSION == CAIRO_VERSION_ENCODE(1, 11, 2)
 GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state, 
GfxGouraudTriangleShading *shading)
 {
   double x0, y0, x1, y1, x2, y2;
@@ -953,7 +953,7 @@ GBool CairoOutputDev::patchMeshShadedFill(GfxState *state, 
GfxPatchMeshShading *
 
   return gTrue;
 }
-#endif /* CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2) */
+#endif /* CAIRO_VERSION == CAIRO_VERSION_ENCODE(1, 11, 2) */
 
 void CairoOutputDev::clip(GfxState *state) {
   doPath (cairo, state, state-getPath());
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 630590c..fa22059 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -107,7 +107,7 @@ public:
   // Does this device use functionShadedFill(), axialShadedFill(), and
   // radialShadedFill()?  If this returns false, these shaded fills
   // will be reduced to a series of other drawing operations.
-#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
+#if CAIRO_VERSION == CAIRO_VERSION_ENCODE(1, 11, 2)
   virtual GBool useShadedFills(int type) { return type = 7; }
 #else
   virtual GBool useShadedFills(int type) { return type  4; }
@@ -170,7 +170,7 @@ public:
   virtual GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading 
*shading);
   virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, 
double sMin, double sMax);
   virtual GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading 
*shading);
-#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
+#if CAIRO_VERSION == CAIRO_VERSION_ENCODE(1, 11, 2)
   virtual GBool gouraudTriangleShadedFill(GfxState *state, 
GfxGouraudTriangleShading *shading);
   virtual GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading 
*shading);
 #endif
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2011-02-26 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   28 
 poppler/CairoOutputDev.h  |2 +-
 2 files changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 22eb01d305ea2560d26417ca8df9c0465d4e9a82
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Sat Feb 26 12:17:49 2011 +0100

cairo: Fix a crash when rendering a document with inline images

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 7ffeb1f..35f2b45 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2422,7 +2422,7 @@ GBool CairoOutputDev::getStreamData (Stream *str, char 
**buffer, int *length)
   return gTrue;
 }
 
-void CairoOutputDev::setMimeData(Stream *str, Ref ref, cairo_surface_t *image)
+void CairoOutputDev::setMimeData(Stream *str, Object *ref, cairo_surface_t 
*image)
 {
   char *strBuffer;
   int len;
@@ -2444,16 +2444,20 @@ void CairoOutputDev::setMimeData(Stream *str, Ref ref, 
cairo_surface_t *image)
 cairo_status_t st;
 
 #if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
-GooString *surfaceId = new GooString(poppler-surface-);
-char *idBuffer = copyString(surfaceId-getCString());
-surfaceId-appendf({0:d}-{1:d}, ref.gen, ref.num);
-st = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_UNIQUE_ID,
-  (const unsigned char *)idBuffer,
-  surfaceId-getLength(),
-  gfree, idBuffer);
-if (st)
-  gfree(idBuffer);
-delete surfaceId;
+if (ref  ref-isRef()) {
+  Ref imgRef = ref-getRef();
+  GooString *surfaceId = new GooString(poppler-surface-);
+  char *idBuffer = copyString(surfaceId-getCString());
+
+  surfaceId-appendf({0:d}-{1:d}, imgRef.gen, imgRef.num);
+  st = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_UNIQUE_ID,
+(const unsigned char *)idBuffer,
+surfaceId-getLength(),
+gfree, idBuffer);
+  if (st)
+gfree(idBuffer);
+  delete surfaceId;
+}
 #endif
 
 st = cairo_surface_set_mime_data (image,
@@ -2579,7 +2583,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
 
   cairo_surface_mark_dirty (image);
 
-  setMimeData(str, ref-getRef(), image);
+  setMimeData(str, ref, image);
 
   pattern = cairo_pattern_create_for_surface (image);
   cairo_surface_destroy (image);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index fa22059..e6fde85 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -283,7 +283,7 @@ protected:
   cairo_filter_t getFilterForSurface(cairo_surface_t *image,
 GBool interpolate);
   GBool getStreamData (Stream *str, char **buffer, int *length);
-  void setMimeData(Stream *str, Ref ref, cairo_surface_t *image);
+  void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
   
   GfxRGB fill_color, stroke_color;
   cairo_pattern_t *fill_pattern, *stroke_pattern;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/OutputDev.h

2011-01-26 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |  139 ++
 poppler/CairoOutputDev.h  |   12 +++
 poppler/Gfx.cc|   10 ++-
 poppler/OutputDev.h   |2 
 4 files changed, 161 insertions(+), 2 deletions(-)

New commits:
commit e57c75fbd95ef8399b0785500f6893465bc808c3
Author: Adrian Johnson ajohn...@redneon.com
Date:   Mon Jan 24 19:48:09 2011 +1030

cairo: Implement Type 4,5,6,7 shadings using cairo mesh gradients

Fixes bugs #19076 and #32791.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 03e6c06..6bfe5a8 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -816,6 +816,145 @@ GBool CairoOutputDev::radialShadedSupportExtend(GfxState 
*state, GfxRadialShadin
   return (shading-getExtend0() == shading-getExtend1());
 }
 
+#if CAIRO_VERSION = CAIRO_VERSION_ENCODE(1, 11, 2)
+GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state, 
GfxGouraudTriangleShading *shading)
+{
+  double x0, y0, x1, y1, x2, y2;
+  GfxColor color[3];
+  int i, j;
+  GfxRGB rgb;
+
+  cairo_pattern_destroy(fill_pattern);
+  fill_pattern = cairo_pattern_create_mesh ();
+
+  for (i = 0; i  shading-getNTriangles(); i++) {
+shading-getTriangle(i,
+x0, y0, color[0],
+x1, y1, color[1],
+x2, y2, color[2]);
+
+cairo_pattern_mesh_begin_patch (fill_pattern);
+
+cairo_pattern_mesh_move_to (fill_pattern, x0, y0);
+cairo_pattern_mesh_line_to (fill_pattern, x1, y1);
+cairo_pattern_mesh_line_to (fill_pattern, x2, y2);
+
+for (j = 0; j  3; j++) {
+   shading-getColorSpace()-getRGB(color[j], rgb);
+   cairo_pattern_mesh_set_corner_color_rgb (fill_pattern, j,
+colToDbl(rgb.r),
+colToDbl(rgb.g),
+colToDbl(rgb.b));
+}
+
+cairo_pattern_mesh_end_patch (fill_pattern);
+  }
+
+  double xMin, yMin, xMax, yMax;
+  // get the clip region bbox
+  state-getUserClipBBox(xMin, yMin, xMax, yMax);
+  state-moveTo(xMin, yMin);
+  state-lineTo(xMin, yMax);
+  state-lineTo(xMax, yMax);
+  state-lineTo(xMax, yMin);
+  state-closePath();
+  fill(state);
+  state-clearPath();
+
+  return gTrue;
+}
+
+GBool CairoOutputDev::patchMeshShadedFill(GfxState *state, GfxPatchMeshShading 
*shading)
+{
+  int i, j, k;
+
+  cairo_pattern_destroy(fill_pattern);
+  fill_pattern = cairo_pattern_create_mesh ();
+
+  for (i = 0; i  shading-getNPatches(); i++) {
+GfxPatch *patch = shading-getPatch(i);
+GfxColor color;
+GfxRGB rgb;
+
+cairo_pattern_mesh_begin_patch (fill_pattern);
+
+cairo_pattern_mesh_move_to (fill_pattern, patch-x[0][0], patch-y[0][0]);
+cairo_pattern_mesh_curve_to (fill_pattern,
+   patch-x[0][1], patch-y[0][1],
+   patch-x[0][2], patch-y[0][2],
+   patch-x[0][3], patch-y[0][3]);
+
+cairo_pattern_mesh_curve_to (fill_pattern,
+   patch-x[1][3], patch-y[1][3],
+   patch-x[2][3], patch-y[2][3],
+   patch-x[3][3], patch-y[3][3]);
+
+cairo_pattern_mesh_curve_to (fill_pattern,
+   patch-x[3][2], patch-y[3][2],
+   patch-x[3][1], patch-y[3][1],
+   patch-x[3][0], patch-y[3][0]);
+
+cairo_pattern_mesh_curve_to (fill_pattern,
+   patch-x[2][0], patch-y[2][0],
+   patch-x[1][0], patch-y[1][0],
+   patch-x[0][0], patch-y[0][0]);
+
+cairo_pattern_mesh_set_control_point (fill_pattern, 0, patch-x[1][1], 
patch-y[1][1]);
+cairo_pattern_mesh_set_control_point (fill_pattern, 1, patch-x[1][2], 
patch-y[1][2]);
+cairo_pattern_mesh_set_control_point (fill_pattern, 2, patch-x[2][2], 
patch-y[2][2]);
+cairo_pattern_mesh_set_control_point (fill_pattern, 3, patch-x[2][1], 
patch-y[2][1]);
+
+for (j = 0; j  4; j++) {
+  int u, v;
+
+  switch (j) {
+   case 0:
+ u = 0; v = 0;
+ break;
+   case 1:
+ u = 0; v = 1;
+ break;
+   case 2:
+ u = 1; v = 1;
+ break;
+   case 3:
+ u = 1; v = 0;
+ break;
+  }
+
+  if (shading-isParameterized()) {
+   shading-getParameterizedColor (patch-color[u][v].c[0], color);
+  } else {
+   for (k = 0; k  shading-getColorSpace()-getNComps(); k++) {
+  // simply cast to the desired type; that's all what is needed.
+ color.c[k] = GfxColorComp (patch-color[u][v].c[k]);
+   }
+  }
+
+  shading-getColorSpace()-getRGB(color, rgb);
+  cairo_pattern_mesh_set_corner_color_rgb (fill_pattern, j,
+  colToDbl(rgb.r),
+  colToDbl(rgb.g),
+

[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h qt4/src qt4/tests

2011-01-21 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc   |2 +-
 poppler/CairoOutputDev.h|2 +-
 qt4/src/poppler-private.cc  |2 +-
 qt4/tests/check_strings.cpp |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 6cb8965fb8bce6da2a4460e86f592c1ea3a84a5c
Author: Albert Astals Cid aa...@kde.org
Date:   Fri Jan 21 18:43:21 2011 +

fix (C) years

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index bc0bfb9..03e6c06 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2005 Nickolay V. Shmyrev nshmy...@yandex.ru
 // Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2008 Carl Worth cwo...@cworth.org
-// Copyright (C) 2008-2010 Adrian Johnson ajohn...@redneon.com
+// Copyright (C) 2008-2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2008, 2009 Chris Wilson ch...@chris-wilson.co.uk
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 30acf81..72ca6a0 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -18,7 +18,7 @@
 // Copyright (C) 2005, 2006 Kristian Høgsberg k...@redhat.com
 // Copyright (C) 2005 Nickolay V. Shmyrev nshmy...@yandex.ru
 // Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
-// Copyright (C) 2008, 2009 Adrian Johnson ajohn...@redneon.com
+// Copyright (C) 2008, 2009, 2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2010 Thomas Freitag thomas.frei...@alfa.de
 //
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 9599af4..da19e98 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -1,7 +1,7 @@
 /* poppler-private.cc: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
  * Copyright (C) 2006 by Albert Astals Cid aa...@kde.org
- * Copyright (C) 2008, 2010 by Pino Toscano p...@kde.org
+ * Copyright (C) 2008, 2010, 2011 by Pino Toscano p...@kde.org
  * Inspired on code by
  * Copyright (C) 2004 by Albert Astals Cid tsdg...@terra.es
  * Copyright (C) 2004 by Enrico Ros eros@email.it
diff --git a/qt4/tests/check_strings.cpp b/qt4/tests/check_strings.cpp
index 1569a17..700ae9c 100644
--- a/qt4/tests/check_strings.cpp
+++ b/qt4/tests/check_strings.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, Pino Toscano p...@kde.org
+ * Copyright (C) 2010, 2011, Pino Toscano p...@kde.org
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2011-01-04 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   46 +++---
 poppler/CairoOutputDev.h  |1 +
 2 files changed, 32 insertions(+), 15 deletions(-)

New commits:
commit bebc530cbde7898759e1bd3629d2836ce0fb1d08
Author: Adrian Johnson ajohn...@redneon.com
Date:   Fri Dec 31 12:11:40 2010 +1030

cairo: Don't set JPX mime data if the stream specifies a colorspace

The stream colorspace overides, and may be different to, the
colorspace in the JPX data.

https://bugs.freedesktop.org/show_bug.cgi?id=32746

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 0507f8c..bc0bfb9 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2283,6 +2283,36 @@ GBool CairoOutputDev::getStreamData (Stream *str, char 
**buffer, int *length)
   return gTrue;
 }
 
+void CairoOutputDev::setMimeData(Stream *str, cairo_surface_t *image)
+{
+  char *strBuffer;
+  int len;
+  Object obj;
+
+  if (!printing || !(str-getKind() == strDCT || str-getKind() == strJPX))
+return;
+
+  // colorspace in stream dict may be different from colorspace in jpx
+  // data
+  if (str-getKind() == strJPX) {
+GBool hasColorSpace = !str-getDict()-lookup(ColorSpace, 
obj)-isNull();
+obj.free();
+if (hasColorSpace)
+  return;
+  }
+
+  if (getStreamData (str-getNextStream(), strBuffer, len)) {
+cairo_status_t st;
+st = cairo_surface_set_mime_data (image,
+ str-getKind() == strDCT ?
+ CAIRO_MIME_TYPE_JPEG : 
CAIRO_MIME_TYPE_JP2,
+ (const unsigned char *)strBuffer, len,
+ gfree, strBuffer);
+if (st)
+  gfree (strBuffer);
+  }
+}
+
 void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   int width, int height,
   GfxImageColorMap *colorMap,
@@ -2396,21 +2426,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
 
   cairo_surface_mark_dirty (image);
 
-  if (printing  (str-getKind() == strDCT || str-getKind() == strJPX)) {
-char *strBuffer;
-int len;
-
-if (getStreamData (str-getNextStream(), strBuffer, len)) {
-  cairo_status_t st;
-  st = cairo_surface_set_mime_data (image,
-   str-getKind() == strDCT ?
-   CAIRO_MIME_TYPE_JPEG : 
CAIRO_MIME_TYPE_JP2,
-   (const unsigned char *)strBuffer, len,
-   gfree, strBuffer);
-  if (st)
-gfree (strBuffer);
-}
-  }
+  setMimeData(str, image);
 
   pattern = cairo_pattern_create_for_surface (image);
   cairo_surface_destroy (image);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 26efadc..30acf81 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -275,6 +275,7 @@ protected:
   cairo_filter_t getFilterForSurface(cairo_surface_t *image,
 GBool interpolate);
   GBool getStreamData (Stream *str, char **buffer, int *length);
+  void setMimeData(Stream *str, cairo_surface_t *image);
   
   GfxRGB fill_color, stroke_color;
   cairo_pattern_t *fill_pattern, *stroke_pattern;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/PSOutputDev.cc poppler/PSOutputDev.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h

2010-09-27 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc  |   18 +++---
 poppler/CairoOutputDev.h   |2 --
 poppler/Gfx.cc |   21 +
 poppler/PSOutputDev.cc |   26 ++
 poppler/PSOutputDev.h  |3 +--
 poppler/SplashOutputDev.cc |   18 +++---
 poppler/SplashOutputDev.h  |4 +---
 7 files changed, 35 insertions(+), 57 deletions(-)

New commits:
commit aa0fd32a8501473832bce1b8b804dd3f9a45735b
Author: Albert Astals Cid aa...@kde.org
Date:   Mon Sep 27 22:39:09 2010 +0100

Consider render value when colorizing text

Fixes bug 2807

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 65fac76..f832074 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -606,15 +606,6 @@ void CairoOutputDev::updateFont(GfxState *state) {
   cairo_set_font_matrix (cairo, matrix);
 }
 
-void CairoOutputDev::updateRender(GfxState *state) {
-  int rm;
-  rm = state-getRender();
-  if (rm == 7  haveCSPattern) {
-haveCSPattern = gFalse;
-restoreState(state);
-  }
-}
-
 void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
   GfxSubpath *subpath;
   int i, j;
@@ -909,7 +900,7 @@ void CairoOutputDev::endString(GfxState *state)
 return;
   }
   
-  if (!(render  1)) {
+  if (!(render  1)  !haveCSPattern) {
 LOG (printf (fill string\n));
 cairo_set_source (cairo, fill_pattern);
 cairo_show_glyphs (cairo, glyphs, glyphCount);
@@ -930,7 +921,7 @@ void CairoOutputDev::endString(GfxState *state)
   }
 
   // clip
-  if (render  4) {
+  if (haveCSPattern || (render  4)) {
 LOG (printf (clip string\n));
 // append the glyph path to textClipPath.
 
@@ -1014,17 +1005,14 @@ void CairoOutputDev::type3D1(GfxState *state, double 
wx, double wy,
 }
 
 void CairoOutputDev::beginTextObject(GfxState *state) {
-  if (state-getFillColorSpace()-getMode() == csPattern) {
+  if (!(state-getRender()  4)  state-getFillColorSpace()-getMode() == 
csPattern) {
 haveCSPattern = gTrue;
 saveState(state);
-savedRender = state-getRender();
-state-setRender(7); // Set clip to text path
   }
 }
 
 void CairoOutputDev::endTextObject(GfxState *state) {
   if (haveCSPattern) {
-state-setRender(savedRender);
 haveCSPattern = gFalse;
 if (state-getFillColorSpace()-getMode() != csPattern) {
   if (textClipPath) {
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 02a4955..e003d83 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -150,7 +150,6 @@ public:
 
   //- update text state
   virtual void updateFont(GfxState *state);
-  virtual void updateRender(GfxState *state);
 
   //- path painting
   virtual void stroke(GfxState *state);
@@ -328,7 +327,6 @@ protected:
 
   GBool haveCSPattern; // set if text has been drawn with a
 //   clipping render mode because of pattern colorspace
-  int savedRender; // use if pattern colorspace
 };
 
 //
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 76dae02..7552fed 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3342,7 +3342,7 @@ void Gfx::opBeginText(Object args[], int numArgs) {
   out-updateTextMat(state);
   out-updateTextPos(state);
   fontChanged = gTrue;
-  if (out-supportTextCSPattern(state)) {
+  if (!(state-getRender()  4)  out-supportTextCSPattern(state)) {
 textHaveCSPattern = gTrue;
   }
 }
@@ -3397,10 +3397,23 @@ void Gfx::opSetTextLeading(Object args[], int numArgs) {
 }
 
 void Gfx::opSetTextRender(Object args[], int numArgs) {
+  int rm = state-getRender();
   state-setRender(args[0].getInt());
-  if (args[0].getInt() == 7) {
-textHaveCSPattern = gFalse;
-  }
+  if ((args[0].getInt()  4)  textHaveCSPattern  drawText) {
+GBool needFill = out-deviceHasTextClip(state);
+out-endTextObject(state);
+if (needFill) {
+  doPatternFill(gTrue);
+}
+out-restoreState(state);
+out-beginTextObject(state);
+out-updateTextMat(state);
+out-updateTextPos(state);
+textHaveCSPattern = gFalse;
+  } else if ((rm  4)  !(args[0].getInt()  4)  
out-supportTextCSPattern(state)  drawText) {
+   out-beginTextObject(state);
+textHaveCSPattern = gTrue;
+  }
   out-updateRender(state);
 }
 
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 179a494..f7e4b8c 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2007, 2008 Brad Hards br...@kde.org
 // Copyright (C) 2008, 2009 Koji Otani s...@bbr.jp
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
-// Copyright (C) 2009 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2009, 2010 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2009 Till Kamppeter till.kamppe...@gmail.com
 // Copyright (C) 2009 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2009 William Bader williamba...@hotmail.com
@@ -125,7 +125,7 @@ 

[poppler] poppler/CairoOutputDev.cc

2010-07-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 1e7f457ca1617fd8c958feef8dd7e694476dedd9
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Fri Jul 9 12:29:14 2010 +0200

[cairo] Use ceil to convert double to int in tilingPatternFill()

Fixes rendering of page 2 of document attached to bug #28954.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 01ff92c..65fac76 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -718,6 +718,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Object *str,
   cairo_t *old_cairo;
   double xMin, yMin, xMax, yMax;
   double width, height;
+  int surface_width, surface_height;
 
   width = bbox[2] - bbox[0];
   height = bbox[3] - bbox[1];
@@ -726,9 +727,12 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Object *str,
 return gFalse;
   /* TODO: implement the other cases here too */
 
+  surface_width = (int) ceil (width);
+  surface_height = (int) ceil (height);
+
   surface = cairo_surface_create_similar (cairo_get_target (cairo),
  CAIRO_CONTENT_COLOR_ALPHA,
- width, height);
+ surface_width, surface_height);
   if (cairo_surface_status (surface))
 return gFalse;
 
@@ -751,7 +755,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, 
Object *str,
   state-getUserClipBBox(xMin, yMin, xMax, yMax);
   cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
 
-  cairo_matrix_init_scale (matrix, (int)width / width, (int)height / height);
+  cairo_matrix_init_scale (matrix, surface_width / width, surface_height / 
height);
   cairo_pattern_set_matrix (pattern, matrix);
 
   cairo_matrix_init (matrix, mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-04-30 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 6b2983f89e87792a393880dab6dc1fedb748db2c
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Fri Apr 30 14:48:50 2010 +0200

[cairo] Set device offset and matrix to smask depending on the group target

It seems to fix all of my test cases. Fixes bug #27208.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 0ae0885..01ff92c 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1279,9 +1279,13 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
 
 /* make the device offset of the new mask match that of the group */
 double x_offset, y_offset;
-cairo_surface_t *pats;
-cairo_pattern_get_surface(group, pats);
-cairo_surface_get_device_offset(pats, x_offset, y_offset);
+if (cairo_get_group_target(cairo) == cairo_get_target(cairo)) {
+  cairo_surface_get_device_offset(cairo_get_group_target(cairo), 
x_offset, y_offset);
+} else {
+  cairo_surface_t *pats;
+  cairo_pattern_get_surface(group, pats);
+  cairo_surface_get_device_offset(pats, x_offset, y_offset);
+}
 cairo_surface_set_device_offset(source, x_offset, y_offset);
 
 /* paint the group */
@@ -1316,9 +1320,14 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
 
 /* setup the new mask pattern */
 mask = cairo_pattern_create_for_surface(source);
-cairo_matrix_t patMatrix;
-cairo_pattern_get_matrix(group, patMatrix);
-cairo_pattern_set_matrix(mask, patMatrix);
+
+if (cairo_get_group_target(cairo) == cairo_get_target(cairo)) {
+  cairo_pattern_set_matrix(mask, mat);
+} else {
+  cairo_matrix_t patMatrix;
+  cairo_pattern_get_matrix(group, patMatrix);
+  cairo_pattern_set_matrix(mask, patMatrix);
+}
 
 cairo_surface_destroy(source);
   } else {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-04-21 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 6b14c18d60cae130869f9a5c7688dfe880602224
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Wed Apr 21 19:56:49 2010 +0200

[cairo] Make sure we always use a new path in doPath()

Fixes document
http://acroeng.adobe.com/Test_Files/images/transparency/Untitled-2.pdf
when rendering with cairo backend.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 768fbba..0ae0885 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -618,6 +618,7 @@ void CairoOutputDev::updateRender(GfxState *state) {
 void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
   GfxSubpath *subpath;
   int i, j;
+  cairo_new_path (cairo);
   for (i = 0; i  path-getNumSubpaths(); ++i) {
 subpath = path-getSubpath(i);
 if (subpath-getNumPoints()  0) {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-04-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit bd8f44289770175a17ac45e4788b0d374cc93d5a
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Fri Apr 9 12:02:38 2010 +0200

Partially revert [cairo] Do not change device offset of mask surface

This partially reverts commit a32f6f9ebaed3e4827b9dc6cb37e307c2798f521.
It fixed bug #27208, but it's causing regressions on other documents.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index cf0b31c..52941d8 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1269,6 +1269,13 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
 cairo_get_matrix(cairo, mat);
 cairo_set_matrix(maskCtx, mat);
 
+/* make the device offset of the new mask match that of the group */
+double x_offset, y_offset;
+cairo_surface_t *pats;
+cairo_pattern_get_surface(group, pats);
+cairo_surface_get_device_offset(pats, x_offset, y_offset);
+cairo_surface_set_device_offset(source, x_offset, y_offset);
+
 /* paint the group */
 cairo_set_source(maskCtx, group);
 cairo_paint(maskCtx);
@@ -1301,7 +1308,9 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 
 /* setup the new mask pattern */
 mask = cairo_pattern_create_for_surface(source);
-cairo_pattern_set_matrix(mask, mat);
+cairo_matrix_t patMatrix;
+cairo_pattern_get_matrix(group, patMatrix);
+cairo_pattern_set_matrix(mask, patMatrix);
 
 cairo_surface_destroy(source);
   } else {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-04-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 51aefe1423a068e8c119c21a8791d265aecbeaf5
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Fri Apr 9 12:50:00 2010 +0200

[cairo] Implement colorizing image masks with pattern colorspace

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 52941d8..49fb191 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1511,6 +1511,9 @@ void CairoOutputDev::drawImageMask(GfxState *state, 
Object *ref, Stream *str,
 return;
   }
 
+  if (state-getFillColorSpace()-getMode() == csPattern)
+cairo_push_group_with_content (cairo, CAIRO_CONTENT_ALPHA);
+
   /* shape is 1.0 for painted areas, 0.0 for unpainted ones */
 
   cairo_matrix_t matrix;
@@ -1522,6 +1525,12 @@ void CairoOutputDev::drawImageMask(GfxState *state, 
Object *ref, Stream *str,
   } else {
 drawImageMaskRegular(state, ref, str, width, height, invert, interpolate, 
inlineImg);
   }
+
+  if (state-getFillColorSpace()-getMode() == csPattern) {
+if (mask)
+  cairo_pattern_destroy (mask);
+mask = cairo_pop_group (cairo);
+  }
 }
 
 void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream 
*str,
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-04-06 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 1422802f029483ad3e62a3a13e66b2d3990ac58f
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Tue Apr 6 12:32:12 2010 +0200

[cairo] Use current fill_opacity when drawing soft masked images

Fixes GNOME Bug https://bugzilla.gnome.org/show_bug.cgi?id=614915

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index c433fdb..cf0b31c 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2140,19 +2140,32 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState 
*state, Object *ref, Stream *s
   cairo_matrix_scale (maskMatrix, maskWidth, -maskHeight);
   cairo_pattern_set_matrix (maskPattern, maskMatrix);
 
-  if (!printing) {
+  if (fill_opacity != 1.0)
+cairo_push_group (cairo);
+  else
 cairo_save (cairo);
-cairo_set_source (cairo, pattern);
+
+  cairo_set_source (cairo, pattern);
+  if (!printing) {
 cairo_rectangle (cairo, 0., 0.,
 MIN (width, maskWidth) / (double)width,
 MIN (height, maskHeight) / (double)height);
 cairo_clip (cairo);
-cairo_mask (cairo, maskPattern);
-cairo_restore (cairo);
-  } else {
-cairo_set_source (cairo, pattern);
-cairo_mask (cairo, maskPattern);
   }
+  cairo_mask (cairo, maskPattern);
+
+  if (fill_opacity != 1.0) {
+cairo_pop_group_to_source (cairo);
+cairo_save (cairo);
+if (!printing) {
+  cairo_rectangle (cairo, 0., 0.,
+  MIN (width, maskWidth) / (double)width,
+  MIN (height, maskHeight) / (double)height);
+  cairo_clip (cairo);
+}
+cairo_paint_with_alpha (cairo, fill_opacity);
+  }
+  cairo_restore (cairo);
 
   if (cairo_shape) {
 cairo_save (cairo_shape);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-04-04 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

New commits:
commit a32f6f9ebaed3e4827b9dc6cb37e307c2798f521
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Sun Mar 28 18:43:14 2010 +0200

[cairo] Do not change device offset of mask surface

Also call cairo_paint() after set_source_rgb() to paint the background.
Fixes bug #27208.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index b066c9b..c433fdb 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1263,19 +1263,12 @@ void CairoOutputDev::setSoftMask(GfxState * state, 
double * bbox, GBool alpha,
 colToDbl(backdropColorRGB.r),
 colToDbl(backdropColorRGB.g),
 colToDbl(backdropColorRGB.b));
-
+cairo_paint(maskCtx);
 
 cairo_matrix_t mat;
 cairo_get_matrix(cairo, mat);
 cairo_set_matrix(maskCtx, mat);
 
-/* make the device offset of the new mask match that of the group */
-double x_offset, y_offset;
-cairo_surface_t *pats;
-cairo_pattern_get_surface(group, pats);
-cairo_surface_get_device_offset(pats, x_offset, y_offset);
-cairo_surface_set_device_offset(source, x_offset, y_offset);
-
 /* paint the group */
 cairo_set_source(maskCtx, group);
 cairo_paint(maskCtx);
@@ -1308,9 +1301,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 
 /* setup the new mask pattern */
 mask = cairo_pattern_create_for_surface(source);
-cairo_matrix_t patMatrix;
-cairo_pattern_get_matrix(group, patMatrix);
-cairo_pattern_set_matrix(mask, patMatrix);
+cairo_pattern_set_matrix(mask, mat);
 
 cairo_surface_destroy(source);
   } else {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-03-05 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit b21461e91ed671ef29fd3cf4780fda44f82a0679
Author: Adrian Johnson ajohn...@redneon.com
Date:   Fri Mar 5 15:14:08 2010 +0100

[cairo] Close image stream before resetting it again

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 5cad4e7..f5924ea 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2191,6 +2191,7 @@ GBool CairoOutputDev::getStreamData (Stream *str, char 
**buffer, int *length)
   char *strBuffer;
 
   len = 0;
+  str-close();
   str-reset();
   while (str-getChar() != EOF) len++;
   if (len == 0)
@@ -2198,6 +2199,7 @@ GBool CairoOutputDev::getStreamData (Stream *str, char 
**buffer, int *length)
 
   strBuffer = (char *)gmalloc (len);
 
+  str-close();
   str-reset();
   for (i = 0; i  len; ++i)
 strBuffer[i] = str-getChar();
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-03-05 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bc42ee05fceef0d0dd2ab0587c184dfc37cf29bf
Author: Albert Astals Cid aa...@kde.org
Date:   Fri Mar 5 18:54:32 2010 +

fix copyright year

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index f5924ea..b066c9b 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2005 Nickolay V. Shmyrev nshmy...@yandex.ru
 // Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2008 Carl Worth cwo...@cworth.org
-// Copyright (C) 2008, 2009 Adrian Johnson ajohn...@redneon.com
+// Copyright (C) 2008-2010 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2008, 2009 Chris Wilson ch...@chris-wilson.co.uk
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2010-01-27 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   37 +++--
 1 file changed, 35 insertions(+), 2 deletions(-)

New commits:
commit a945fe64e16ac9aa2577c5db05fc7f3fd4955b7b
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Wed Jan 27 16:15:40 2010 +0100

[cairo] Fix downscaling images when document is rotated

Fixes bug #26264.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 5ca86b8..a2a9ae5 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1344,6 +1344,30 @@ void CairoOutputDev::endMaskClip(GfxState *state) {
   clearSoftMask(state);
 }
 
+/* Taken from cairo/doc/tutorial/src/singular.c */
+static void
+get_singular_values (const cairo_matrix_t *matrix,
+double   *major,
+double   *minor)
+{
+   double xx = matrix-xx, xy = matrix-xy;
+   double yx = matrix-yx, yy = matrix-yy;
+
+   double a = xx*xx+yx*yx;
+   double b = xy*xy+yy*yy;
+   double k = xx*xy+yx*yy;
+
+   double f = (a+b) * .5;
+   double g = (a-b) * .5;
+   double delta = sqrt (g*g + k*k);
+
+   if (major)
+   *major = sqrt (f + delta);
+   if (minor)
+   *minor = sqrt (f - delta);
+}
+
+
 cairo_surface_t *CairoOutputDev::downscaleSurface(cairo_surface_t 
*orig_surface) {
   cairo_surface_t *dest_surface;
   unsigned char *dest_buffer;
@@ -1356,12 +1380,21 @@ cairo_surface_t 
*CairoOutputDev::downscaleSurface(cairo_surface_t *orig_surface)
   if (printing)
 return NULL;
 
+
+  orig_width = cairo_image_surface_get_width (orig_surface);
+  orig_height = cairo_image_surface_get_height (orig_surface);
+
   cairo_matrix_t matrix;
   cairo_get_matrix(cairo, matrix);
 
   /* this whole computation should be factored out */
-  double xScale = matrix.xx;
-  double yScale = matrix.yy;
+  double xScale;
+  double yScale;
+  if (orig_width  orig_height)
+get_singular_values (matrix, xScale, yScale);
+  else
+get_singular_values (matrix, yScale, xScale);
+
   int tx, tx2, ty, ty2; /* the integer co-oridinates of the resulting image */
   int scaledHeight;
   int scaledWidth;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/CairoRescaleBox.cc poppler/CairoRescaleBox.h poppler/Makefile.am

2010-01-24 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc  |   89 +++
 poppler/CairoOutputDev.h   |1 
 poppler/CairoRescaleBox.cc |  352 +
 poppler/CairoRescaleBox.h  |   12 +
 poppler/Makefile.am|4 
 5 files changed, 457 insertions(+), 1 deletion(-)

New commits:
commit 3160464b4b70c714c36234320878acab81b866cc
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Thu Nov 26 13:17:19 2009 +0100

[cairo] Use our own implementation to scale down images instead of cairo

This is a workaround for the low quality downscaling of pixman.
Rescaler implementation is a box filter that supports non-integer box
sizes written by Jeff Muizelaar.
Fixes bug #5589.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 9a0f3be..42ac3a8 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -58,6 +58,7 @@
 #include splash/SplashBitmap.h
 #include CairoOutputDev.h
 #include CairoFontEngine.h
+#include CairoRescaleBox.h
 //
 
 // #define LOG_CAIRO
@@ -1331,6 +1332,82 @@ void CairoOutputDev::endMaskClip(GfxState *state) {
   clearSoftMask(state);
 }
 
+cairo_surface_t *CairoOutputDev::downscaleSurface(cairo_surface_t 
*orig_surface) {
+  cairo_surface_t *dest_surface;
+  unsigned char *dest_buffer;
+  int dest_stride;
+  unsigned char *orig_buffer;
+  int orig_width, orig_height;
+  int orig_stride;
+  GBool res;
+
+  if (printing)
+return NULL;
+
+  cairo_matrix_t matrix;
+  cairo_get_matrix(cairo, matrix);
+
+  /* this whole computation should be factored out */
+  double xScale = matrix.xx;
+  double yScale = matrix.yy;
+  int tx, tx2, ty, ty2; /* the integer co-oridinates of the resulting image */
+  int scaledHeight;
+  int scaledWidth;
+  if (xScale = 0) {
+tx = splashRound(matrix.x0 - 0.01);
+tx2 = splashRound(matrix.x0 + xScale + 0.01) - 1;
+  } else {
+tx = splashRound(matrix.x0 + 0.01) - 1;
+tx2 = splashRound(matrix.x0 + xScale - 0.01);
+  }
+  scaledWidth = abs(tx2 - tx) + 1;
+  //scaledWidth = splashRound(fabs(xScale));
+  if (scaledWidth == 0) {
+// technically, this should draw nothing, but it generally seems
+// better to draw a one-pixel-wide stripe rather than throwing it
+// away
+scaledWidth = 1;
+  }
+  if (yScale = 0) {
+ty = splashFloor(matrix.y0 + 0.01);
+ty2 = splashCeil(matrix.y0 + yScale - 0.01);
+  } else {
+ty = splashCeil(matrix.y0 - 0.01);
+ty2 = splashFloor(matrix.y0 + yScale + 0.01);
+  }
+  scaledHeight = abs(ty2 - ty);
+  if (scaledHeight == 0) {
+scaledHeight = 1;
+  }
+
+  orig_width = cairo_image_surface_get_width (orig_surface);
+  orig_height = cairo_image_surface_get_height (orig_surface);
+  if (scaledWidth = orig_width || scaledHeight = orig_height)
+return NULL;
+
+  dest_surface = cairo_surface_create_similar (orig_surface,
+  cairo_surface_get_content 
(orig_surface),
+  scaledWidth, scaledHeight);
+  dest_buffer = cairo_image_surface_get_data (dest_surface);
+  dest_stride = cairo_image_surface_get_stride (dest_surface);
+
+  orig_buffer = cairo_image_surface_get_data (orig_surface);
+  orig_stride = cairo_image_surface_get_stride (orig_surface);
+
+  res = downscale_box_filter((uint32_t *)orig_buffer,
+orig_stride, orig_width, orig_height,
+scaledWidth, scaledHeight, 0, 0,
+scaledWidth, scaledHeight,
+(uint32_t *)dest_buffer, dest_stride);
+  if (!res) {
+cairo_surface_destroy (dest_surface);
+return NULL;
+  }
+
+  return dest_surface;
+
+}
+
 void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
   int width, int height, GBool invert,
   GBool interpolate, GBool inlineImg) {
@@ -2094,6 +2171,18 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   }
   gfree(lookup);
 
+  cairo_surface_t *scaled_surface;
+
+  scaled_surface = downscaleSurface (image);
+  if (scaled_surface) {
+if (cairo_surface_status (scaled_surface))
+  goto cleanup;
+cairo_surface_destroy (image);
+image = scaled_surface;
+width = cairo_image_surface_get_width (image);
+height = cairo_image_surface_get_height (image);
+  }
+
   cairo_surface_mark_dirty (image);
   pattern = cairo_pattern_create_for_surface (image);
   cairo_surface_destroy (image);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index fb9c0d7..266f0cb 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -268,6 +268,7 @@ public:
 
 protected:
   void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
+  cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface);
   
   GfxRGB fill_color, stroke_color;
   cairo_pattern_t 

[poppler] poppler/CairoOutputDev.cc

2009-11-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit 448f03cfc429d33bfa5527e3dc964ef5da10ee94
Author: Adrian Johnson ajohn...@redneon.com
Date:   Mon Nov 9 22:52:39 2009 +1030

Don't render the color white in type 3 glyphs in the cairo backend

PDF allows the g operator in Type 3 charprocs but cairo user fonts
will render any stroke or fill in the font color.

As the only PDFs I've seen with g in the charprocs are only using
the gray values 0 or 1, a workaround is to disable strokes and fills
of the charproc when the gray level is  0.5.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 500583a..ec9aaa5 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -638,6 +638,13 @@ void CairoOutputDev::doPath(cairo_t *cairo, GfxState 
*state, GfxPath *path) {
 }
 
 void CairoOutputDev::stroke(GfxState *state) {
+  if (inType3Char) {
+  GfxGray gray;
+  state-getFillGray(gray);
+  if (colToDbl(gray)  0.5)
+ return;
+  }
+
   doPath (cairo, state, state-getPath());
   cairo_set_source (cairo, stroke_pattern);
   LOG(printf (stroke\n));
@@ -649,6 +656,13 @@ void CairoOutputDev::stroke(GfxState *state) {
 }
 
 void CairoOutputDev::fill(GfxState *state) {
+  if (inType3Char) {
+  GfxGray gray;
+  state-getFillGray(gray);
+  if (colToDbl(gray)  0.5)
+ return;
+  }
+
   doPath (cairo, state, state-getPath());
   cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING);
   cairo_set_source (cairo, fill_pattern);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2009-11-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit c59d93061cf71d13916872a20aed37ecfbb3bfa4
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Mon Nov 9 18:32:55 2009 +0100

[cairo] Do nothing when image mask is 1x1 and the pixel is 0

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index ec9aaa5..5f283c3 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1328,6 +1328,20 @@ void CairoOutputDev::drawImageMask(GfxState *state, 
Object *ref, Stream *str,
 
   /* work around a cairo bug when scaling 1x1 surfaces */
   if (width == 1  height == 1) {
+ImageStream *imgStr;
+Guchar pix;
+int invert_bit;
+
+imgStr = new ImageStream(str, width, 1, 1);
+imgStr-reset();
+imgStr-getPixel(pix);
+imgStr-close();
+delete imgStr;
+
+invert_bit = invert ? 1 : 0;
+if (pix ^ invert_bit)
+  return;
+
 cairo_save (cairo);
 cairo_rectangle (cairo, 0., 0., width, height);
 cairo_fill (cairo);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2009-08-07 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   59 +-
 1 file changed, 38 insertions(+), 21 deletions(-)

New commits:
commit e4439ff527bb202d0239f78e647452983b733411
Author: Carlos Garcia Campos carlo...@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) {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h poppler/Gfx.cc poppler/OutputDev.h poppler/PSOutputDev.cc poppler/PSOutputDev.h

2009-07-31 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   28 +
 poppler/CairoOutputDev.h  |2 
 poppler/Gfx.cc|  141 +++---
 poppler/OutputDev.h   |2 
 poppler/PSOutputDev.cc|3 
 poppler/PSOutputDev.h |2 
 6 files changed, 117 insertions(+), 61 deletions(-)

New commits:
commit 53c3d636ad645a350b576160e1498726238a7bd1
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Fri Jul 31 18:23:57 2009 +0200

[cairo] Implement radialShadedFill in cairo backend using cairo gradients

Fixes bugs #10942, #14160

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 89335f8..e86ee12 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -683,6 +683,34 @@ GBool CairoOutputDev::axialShadedSupportExtend(GfxState 
*state, GfxAxialShading
   return (shading-getExtend0() == shading-getExtend1());
 }
 
+GBool CairoOutputDev::radialShadedFill(GfxState *state, GfxRadialShading 
*shading, double sMin, double sMax) {
+  double x0, y0, r0, x1, y1, r1;
+  double dx, dy, dr;
+
+  shading-getCoords(x0, y0, r0, x1, y1, r1);
+  dx = x1 - x0;
+  dy = y1 - y0;
+  dr = r1 - r0;
+  cairo_pattern_destroy(fill_pattern);
+  fill_pattern = cairo_pattern_create_radial (x0 + sMin * dx,
+ y0 + sMin * dy,
+ r0 + sMin * dr,
+ x0 + sMax * dx,
+ y0 + sMax * dy,
+ r0 + sMax * dr);
+  if (shading-getExtend0()  shading-getExtend1())
+cairo_pattern_set_extend (fill_pattern, CAIRO_EXTEND_PAD);
+  else
+cairo_pattern_set_extend (fill_pattern, CAIRO_EXTEND_NONE);
+
+  return gFalse;
+}
+
+GBool CairoOutputDev::radialShadedSupportExtend(GfxState *state, 
GfxRadialShading *shading)
+{
+  return (shading-getExtend0() == shading-getExtend1());
+}
+
 void CairoOutputDev::clip(GfxState *state) {
   doPath (cairo, state, state-getPath());
   cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index f2bcb55..071c171 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -153,6 +153,8 @@ public:
   virtual void eoFill(GfxState *state);
   virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, 
double tMin, double tMax);
   virtual GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading 
*shading);
+  virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, 
double sMin, double sMax);
+  virtual GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading 
*shading);
 
   //- path clipping
   virtual void clip(GfxState *state);
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4b8ff35..e71a0dd 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2652,11 +2652,7 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
   int ia, ib, k, n;
   double *ctm;
   double theta, alpha, angle, t;
-
-  if (out-useShadedFills() 
-  out-radialShadedFill(state, shading)) {
-return;
-  }
+  GBool needExtend = gTrue;
 
   // get the shading info
   shading-getCoords(x0, y0, r0, x1, y1, r1);
@@ -2753,6 +2749,11 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
 }
   }
 
+  if (out-useShadedFills() 
+  out-radialShadedFill(state, shading, sMin, sMax)) {
+return;
+  }
+
   // compute the number of steps into which circles must be divided to
   // achieve a curve flatness of 0.1 pixel in device space for the
   // largest circle (note that device space is 72 dpi when generating
@@ -2799,6 +2800,8 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
 shading-getColor(ta, colorA);
   }
 
+  needExtend = !out-radialShadedSupportExtend(state, shading);
+
   // fill the circles
   while (ia  radialMaxSplits) {
 
@@ -2849,63 +2852,67 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
   colorA.c[k] = (colorA.c[k] + colorB.c[k]) / 2;
 }
 state-setFillColor(colorA);
-out-updateFillColor(state);
-
-if (enclosed) {
-
-  // construct path for first circle (counterclockwise)
-  state-moveTo(xa + ra, ya);
-  for (k = 1; k  n; ++k) {
-   angle = ((double)k / (double)n) * 2 * M_PI;
-   state-lineTo(xa + ra * cos(angle), ya + ra * sin(angle));
-  }
-  state-closePath();
-
-  // construct and append path for second circle (clockwise)
-  state-moveTo(xb + rb, yb);
-  for (k = 1; k  n; ++k) {
-   angle = -((double)k / (double)n) * 2 * M_PI;
-   state-lineTo(xb + rb * cos(angle), yb + rb * sin(angle));
-  }
-  state-closePath();
-
-} else {
+if (out-useFillColorStop())
+  out-updateFillColorStop(state, (sa - sMin)/(sMax - sMin));
+else
+  out-updateFillColor(state);
 
-  // construct the first subpath (clockwise)
-  state-moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI),
-   

[poppler] poppler/CairoOutputDev.cc

2009-07-20 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   36 ++--
 1 file changed, 34 insertions(+), 2 deletions(-)

New commits:
commit f93f5e17d8f23f3e2862f3411f43a95b334e6c91
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Mon Jul 20 17:10:37 2009 +0200

[cairo] Improve performance when rendering one-channel images

It implements the same idea already used in SplashOutputDev, for
one-channel (monochrome/gray/separation) images we build a lookup table
so that we won't need to call colorMap-getRGBLine when filling the
image buffer. Fixes bug #18017.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a14f68a..0f9b621 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1798,7 +1798,8 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   ImageStream *imgStr;
   cairo_matrix_t matrix;
   unsigned char *buffer;
-  int stride;
+  int stride, i;
+  GfxRGB *lookup = NULL;
 
   /* TODO: Do we want to cache these? */
   imgStr = new ImageStream(str, width,
@@ -1822,12 +1823,42 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   if (cairo_surface_status (image))
 goto cleanup;
 
+  // special case for one-channel (monochrome/gray/separation) images:
+  // build a lookup table here
+  if (colorMap-getNumPixelComps() == 1) {
+int n;
+Guchar pix;
+
+n = 1  colorMap-getBits();
+lookup = (GfxRGB *)gmallocn(n, sizeof(GfxRGB));
+for (i = 0; i  n; ++i) {
+  pix = (Guchar)i;
+
+  colorMap-getRGB(pix, lookup[i]);
+}
+  }
+
   buffer = cairo_image_surface_get_data (image);
   stride = cairo_image_surface_get_stride (image);
   for (int y = 0; y  height; y++) {
 uint32_t *dest = (uint32_t *) (buffer + y * stride);
 Guchar *pix = imgStr-getLine();
-colorMap-getRGBLine (pix, dest, width);
+
+if (lookup) {
+  Guchar *p = pix;
+  GfxRGB rgb;
+
+  for (i = 0; i  width; i++) {
+rgb = lookup[*p];
+dest[i] =
+   ((int) colToByte(rgb.r)  16) |
+   ((int) colToByte(rgb.g)  8) |
+   ((int) colToByte(rgb.b)  0);
+   p++;
+  }
+} else {
+  colorMap-getRGBLine (pix, dest, width);
+}
 
 if (maskColors) {
   for (int x = 0; x  width; x++) {
@@ -1848,6 +1879,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
   }
 }
   }
+  gfree(lookup);
 
   pattern = cairo_pattern_create_for_surface (image);
   cairo_surface_destroy (image);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2009-07-09 Thread Chris Wilson
 poppler/CairoOutputDev.cc |   16 
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 454f7468c6a6a442a5064b5daa24d65ebf4fc6b6
Author: Chris Wilson ch...@chris-wilson.co.uk
Date:   Thu Jul 9 10:43:00 2009 +0100

[cairo] Fix drawImage() for non-1x1 images

Carlos noticed a nasty bug with converting drawImage() to use PAD + fill,
instead of NONE + paint. That is the image was being padded out far beyond
the correct output extents. The cause is that the caller pre-scales the
context for the image, so the output rectangle was many times the true
image size - obliterating large amounts of the page. The temporary fix is
to counter-act the scaling on the context. Longer term, after fixing all
painters to use PAD correctly, we need to review the callers to remove
unnecessary pre-scaling.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 79c5c76..a14f68a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1856,21 +1856,29 @@ void CairoOutputDev::drawImage(GfxState *state, Object 
*ref, Stream *str,
 
   LOG (printf (drawImageMask %dx%d\n, width, height));
 
-  cairo_matrix_init_translate (matrix, 0, height);
-  cairo_matrix_scale (matrix, width, -height);
-
-  cairo_pattern_set_matrix (pattern, matrix);
   cairo_pattern_set_filter (pattern,
interpolate ?
CAIRO_FILTER_BILINEAR : CAIRO_FILTER_FAST);
   cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
 
+  /* XXX Undo the transformation applied before drawImage(), once all
+   * painters have been fixed to use PAD we can then fix the callers
+   * not to apply useless transformations.
+   */
+  cairo_matrix_init_translate (matrix, 0, height);
+  cairo_matrix_scale (matrix, width, -height);
+  cairo_matrix_invert (matrix);
+
+  cairo_save (cairo);
+  cairo_transform (cairo, matrix);
   cairo_set_source (cairo, pattern);
   cairo_rectangle (cairo, 0., 0., width, height);
   cairo_fill (cairo);
+  cairo_restore (cairo);
 
   if (cairo_shape) {
 cairo_save (cairo_shape);
+cairo_transform (cairo_shape, matrix);
 cairo_rectangle (cairo_shape, 0., 0., width, height);
 cairo_set_source (cairo_shape, pattern);
 cairo_fill (cairo_shape);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2009-06-03 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   47 ++
 poppler/CairoOutputDev.h  |   19 ++
 2 files changed, 66 insertions(+)

New commits:
commit e521c1efaeba3f35d10e46bca3d9650dabd2d889
Author: Adrian Johnson ajohn...@redneon.com
Date:   Wed Jun 3 22:08:57 2009 +0930

Implement text in pattern colorspace for the cairo backend

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 5d4cb82..199e5ea 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -124,6 +124,7 @@ CairoOutputDev::CairoOutputDev() {
   stroke_opacity = 1.0;
   fill_opacity = 1.0;
   textClipPath = NULL;
+  haveCSPattern = gFalse;
   cairo = NULL;
   currentFont = NULL;
   prescaleImages = gTrue;
@@ -507,6 +508,15 @@ void CairoOutputDev::updateFont(GfxState *state) {
   cairo_set_font_matrix (cairo, matrix);
 }
 
+void CairoOutputDev::updateRender(GfxState *state) {
+  int rm;
+  rm = state-getRender();
+  if (rm == 7  haveCSPattern) {
+haveCSPattern = gFalse;
+restoreState(state);
+  }
+}
+
 void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
   GfxSubpath *subpath;
   int i, j;
@@ -758,7 +768,40 @@ void CairoOutputDev::type3D1(GfxState *state, double wx, 
double wy,
   t3_glyph_has_bbox = gTrue;
 }
 
+void CairoOutputDev::beginTextObject(GfxState *state) {
+  if (state-getFillColorSpace()-getMode() == csPattern) {
+haveCSPattern = gTrue;
+saveState(state);
+savedRender = state-getRender();
+state-setRender(7); // Set clip to text path
+  }
+}
+
 void CairoOutputDev::endTextObject(GfxState *state) {
+  if (haveCSPattern) {
+state-setRender(savedRender);
+haveCSPattern = gFalse;
+if (state-getFillColorSpace()-getMode() != csPattern) {
+  if (textClipPath) {
+   cairo_new_path (cairo);
+   cairo_append_path (cairo, textClipPath);
+   cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING);
+   cairo_set_source (cairo, fill_pattern);
+   cairo_fill (cairo);
+   if (cairo_shape) {
+ cairo_new_path (cairo_shape);
+ cairo_append_path (cairo_shape, textClipPath);
+ cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_WINDING);
+ cairo_fill (cairo_shape);
+   }
+   cairo_path_destroy (textClipPath);
+   textClipPath = NULL;
+  }
+  restoreState(state);
+  updateFillColor(state);
+}
+  }
+
   if (textClipPath) {
 // clip the accumulated text path
 cairo_append_path (cairo, textClipPath);
@@ -1057,6 +1100,10 @@ void CairoOutputDev::clearSoftMask(GfxState * /*state*/) 
{
   mask = NULL;
 }
 
+void CairoOutputDev::endMaskClip(GfxState *state) {
+  clearSoftMask(state);
+}
+
 void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg) {
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 5ec2bf0..7a9283f 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -135,6 +135,7 @@ public:
 
   //- update text state
   virtual void updateFont(GfxState *state);
+  virtual void updateRender(GfxState *state);
 
   //- path painting
   virtual void stroke(GfxState *state);
@@ -157,8 +158,22 @@ public:
   double dx, double dy,
   CharCode code, Unicode *u, int uLen);
   virtual void endType3Char(GfxState *state);
+  virtual void beginTextObject(GfxState *state);
+  virtual GBool deviceHasTextClip(GfxState *state) { return textClipPath  
haveCSPattern; }
   virtual void endTextObject(GfxState *state);
 
+  // If current colorspace is pattern,
+  // does this device support text in pattern colorspace?
+  virtual GBool supportTextCSPattern(GfxState *state) {
+  return state-getFillColorSpace()-getMode() == csPattern; }
+
+  // If current colorspace is pattern,
+  // need this device special handling for masks in pattern colorspace?
+  virtual GBool fillMaskCSPattern(GfxState * state) {
+  return state-getFillColorSpace()-getMode() == csPattern; }
+
+  virtual void endMaskClip(GfxState *state);
+
   //- grouping operators
   virtual void beginMarkedContent(char *name, Dict *properties);
   virtual void endMarkedContent(GfxState *state);  
@@ -276,6 +291,10 @@ protected:
   cairo_pattern_t *mask;
   struct MaskStack *next;
   } *maskStack;
+
+  GBool haveCSPattern; // set if text has been drawn with a
+//   clipping render mode because of pattern colorspace
+  int savedRender; // use if pattern colorspace
 };
 
 //
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2009-02-22 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 26a8217160c1eaeeadb92023b27e68f402e38dd0
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Sun Feb 22 18:14:15 2009 +0100

Check if cairo_shape is not NULL before using it.

We were checking shape instead. It fixes a crash with some documents.
See bug #17337.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 6e79785..822d66d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -282,7 +282,7 @@ void CairoOutputDev::setDefaultCTM(double *ctm) {
   matrix.y0 = ctm[5];
 
   cairo_transform (cairo, matrix);
-  if (shape)
+  if (cairo_shape)
   cairo_transform (cairo_shape, matrix);
 
   OutputDev::setDefaultCTM(ctm);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2008-11-12 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 17b18be4fd25f2ca2b4ed7382d9fda50410c44f1
Author: Adrian Johnson [EMAIL PROTECTED]
Date:   Wed Nov 12 20:40:57 2008 +1030

Ensure cairo font matrix is invertable

Fixes bugs #18254 and #18429

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 26b8010..8ac2201 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -410,7 +410,7 @@ void CairoOutputDev::updateStrokeOpacity(GfxState *state) {
 
 void CairoOutputDev::updateFont(GfxState *state) {
   cairo_font_face_t *font_face;
-  cairo_matrix_t matrix;
+  cairo_matrix_t matrix, invert_matrix;
 
   LOG(printf (updateFont() font=%s\n, 
state-getFont()-getName()-getCString()));
 
@@ -438,6 +438,19 @@ void CairoOutputDev::updateFont(GfxState *state) {
   matrix.yy = -m[3] * fontSize;
   matrix.x0 = 0;
   matrix.y0 = 0;
+
+ /* Make sure the font matrix is invertible before setting it.  cairo
+  * will blow up if we give it a matrix that's not invertible, so we
+  * need to check before passing it to cairo_set_font_matrix. Ignoring it
+  * is likely to give better results than not rendering anything at
+  * all. See #18254.
+  */
+  invert_matrix = matrix;
+  if (cairo_matrix_invert(invert_matrix)) {
+warning(font matrix not invertible\n);
+return;
+  }
+
   cairo_set_font_matrix (cairo, matrix);
 }
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2008-09-26 Thread Albert Astals Cid
 poppler/CairoOutputDev.cc |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit b3828203c4e594754957033ea826e8e22164fd5b
Author: Albert Astals Cid [EMAIL PROTECTED]
Date:   Fri Sep 26 23:08:14 2008 +0200

Carl agreed too, so CairoOutputDev.cc is done

Only miss, Marco Pesenti Gritti, Timothy Lee and Ed Catmur

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 254dfd8..03cc059 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -11,6 +11,9 @@
 //
 // Modified under the Poppler project - http://poppler.freedesktop.org
 //
+// All changes made under the Poppler project to this file are licensed
+// under GPL version 2 or later
+//
 // Copyright (C) 2005-2008 Jeff Muizelaar [EMAIL PROTECTED]
 // Copyright (C) 2005, 2006 Kristian Høgsberg [EMAIL PROTECTED]
 // Copyright (C) 2005 Albert Astals Cid [EMAIL PROTECTED]
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2008-08-21 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 15a73704ab6b009ca5e07c08f0b12d970adc387d
Author: Chris Wilson [EMAIL PROTECTED]
Date:   Tue Aug 19 09:18:03 2008 +0100

Memleak and invalid free.

CairoOutputDev::setSoftMask() fails to free the cairo_t and mask it uses
to draw the opaque soft mask and attempts to destroy a reference to a
surface it does not own (this bug was masked by the fact that a reference
was still being held by the unfreed cairo_t).

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 6d4267e..907bac8 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -122,6 +122,8 @@ CairoOutputDev::~CairoOutputDev() {
   cairo_pattern_destroy (fill_pattern);
   if (group)
 cairo_pattern_destroy (group);
+  if (mask)
+cairo_pattern_destroy (mask);
   if (shape)
 cairo_pattern_destroy (shape);
 }
@@ -821,6 +823,8 @@ static uint32_t luminocity(uint32_t x)
 /* XXX: do we need to deal with shape here? */
 void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha,
  Function * transferFunc, GfxColor * 
backdropColor) {
+  cairo_pattern_destroy(mask);
+
   if (alpha == false) {
 /* We need to mask according to the luminocity of the group.
  * So we paint the group to an image surface convert it to a luminocity map
@@ -858,6 +862,9 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * 
bbox, GBool alpha,
 cairo_set_source(maskCtx, group);
 cairo_paint(maskCtx);
 
+/* XXX status = cairo_status(maskCtx); */
+cairo_destroy(maskCtx);
+
 /* convert to a luminocity map */
 uint32_t *source_data = (uint32_t*)cairo_image_surface_get_data(source);
 /* get stride in units of 32 bits */
@@ -887,10 +894,8 @@ void CairoOutputDev::setSoftMask(GfxState * state, double 
* bbox, GBool alpha,
 cairo_pattern_set_matrix(mask, patMatrix);
 
 cairo_surface_destroy(source);
-cairo_surface_destroy(pats);
   } else {
-cairo_pattern_reference(group);
-mask = group;
+mask = cairo_pattern_reference(group);
   }
 
   popTransparencyGroup();
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2008-06-26 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |   18 +++---
 poppler/CairoOutputDev.h  |4 +++-
 2 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 5498d93e59a0b79e5add3dc6181d5e98ba689217
Author: Michael Vrable [EMAIL PROTECTED]
Date:   Fri Jun 20 21:42:34 2008 -0700

Use a single global FT_Library in CairoOutputDev

Cairo may internally keep references to the FreeType fonts loaded in
CairoFontEngine even after poppler is done with them.  Commit 42db4890e829
(Do not call FT_Done_Face on a live cairo_font_face_t) introduced a fix
for one use-after-free bug, by delaying deleting an FT_Face objects until
cairo is done with it.

That fix doesn't correct all the bugs.  An FT_Library object is created for
each CairoOutputDev object, and deleted when the CairoOutputDev goes away.
But the FT_Library object should not be deleted while fonts loaded using it
are still in use.  And cairo can keep references to fonts around more or
less indefinitely.

To more fully fix the problem, we can either:
 1. Keep a count of not-yet-deleted fonts associated with each FT_Library,
and wait to call FT_Done_FreeType until it drops to zero.
 2. Never call FT_Done_FreeType.

The second option is the simplest.  To avoid leaking memory FT_Library
objects, use a single global FT_Library instead of a per-CairoOutputDev
copy.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 7ae19a2..6d4267e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -74,10 +74,23 @@ void CairoImage::setImage (cairo_surface_t *image) {
 // CairoOutputDev
 //
 
+// We cannot tie the lifetime of an FT_Library object to that of
+// CairoOutputDev, since any FT_Faces created with it may end up with a
+// reference by Cairo which can be held long after the CairoOutputDev is
+// deleted.  The simplest way to avoid problems is to never tear down the
+// FT_Library instance; to avoid leaks, just use a single global instance
+// initialized the first time it is needed.
+FT_Library CairoOutputDev::ft_lib;
+GBool CairoOutputDev::ft_lib_initialized = gFalse;
+
 CairoOutputDev::CairoOutputDev() {
   xref = NULL;
 
-  FT_Init_FreeType(ft_lib);
+  if (!ft_lib_initialized) {
+FT_Init_FreeType(ft_lib);
+ft_lib_initialized = gTrue;
+  }
+
   fontEngine = NULL;
   glyphs = NULL;
   fill_pattern = NULL;
@@ -102,8 +115,7 @@ CairoOutputDev::~CairoOutputDev() {
   if (fontEngine) {
 delete fontEngine;
   }
-  FT_Done_FreeType(ft_lib);
-  
+
   if (cairo)
 cairo_destroy (cairo);
   cairo_pattern_destroy (stroke_pattern);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 5d2b658..fad6765 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -206,7 +206,9 @@ protected:
   
   XRef *xref;  // xref table for current document
 
-  FT_Library ft_lib;
+  static FT_Library ft_lib;
+  static GBool ft_lib_initialized;
+
   CairoFontEngine *fontEngine;
   cairo_t *cairo;
   cairo_matrix_t orig_matrix;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2008-06-19 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |4 ++--
 poppler/CairoOutputDev.h  |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit d6fb5dcb7b7596961800d9744d17b6adb8d9a2ad
Author: Michael Vrable [EMAIL PROTECTED]
Date:   Wed Jun 18 11:24:05 2008 -0700

Fix a crash in the cairo backend with Type 3 glyphs

Commit 86b7e8a3bee7 (Ensure cairo renders Type 3 glyphs with only the fill
color) introduced a bug into the Cairo backend, causing evince to crash
with the message
evince: cairo-pattern.c:679: cairo_pattern_destroy: Assertion
`((*(pattern-ref_count)-ref_count)  0)' failed.
Fix this by updating reference counts to the fill and stroke patterns when
modifying them in beginType3Char.

Simplify the code as well by not saving the old stroke pattern before
overriding it; this is already done since beginType3Char/endType3Char is
wrapped by calls to saveState/restoreState in Gfx::doShowText.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 05fe1a8..7ae19a2 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -616,13 +616,13 @@ GBool CairoOutputDev::beginType3Char(GfxState *state, 
double x, double y,
 cairo_set_matrix(cairo_shape, orig_matrix);
 cairo_transform(cairo_shape, matrix);
   }
-  old_stroke_pattern = stroke_pattern;
+  cairo_pattern_destroy(stroke_pattern);
+  cairo_pattern_reference(fill_pattern);
   stroke_pattern = fill_pattern;
   return gFalse;
 }
 
 void CairoOutputDev::endType3Char(GfxState *state) {
-  stroke_pattern = old_stroke_pattern;
   cairo_restore (cairo);
   if (cairo_shape) {
 cairo_restore (cairo_shape);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index f6f9e13..5d2b658 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -199,7 +199,7 @@ protected:
   void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
   
   GfxRGB fill_color, stroke_color;
-  cairo_pattern_t *fill_pattern, *stroke_pattern, *old_stroke_pattern;
+  cairo_pattern_t *fill_pattern, *stroke_pattern;
   double fill_opacity;
   double stroke_opacity;
   CairoFont *currentFont;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2008-06-09 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |3 +++
 poppler/CairoOutputDev.h  |2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 86b7e8a3bee74c5b89c451137cf9c2758ba6913f
Author: Adrian Johnson [EMAIL PROTECTED]
Date:   Sun Jun 8 18:00:05 2008 +0930

Ensure cairo renders Type 3 glyphs with only the fill color

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 57c3ac5..05fe1a8 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -616,10 +616,13 @@ GBool CairoOutputDev::beginType3Char(GfxState *state, 
double x, double y,
 cairo_set_matrix(cairo_shape, orig_matrix);
 cairo_transform(cairo_shape, matrix);
   }
+  old_stroke_pattern = stroke_pattern;
+  stroke_pattern = fill_pattern;
   return gFalse;
 }
 
 void CairoOutputDev::endType3Char(GfxState *state) {
+  stroke_pattern = old_stroke_pattern;
   cairo_restore (cairo);
   if (cairo_shape) {
 cairo_restore (cairo_shape);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 5d2b658..f6f9e13 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -199,7 +199,7 @@ protected:
   void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
   
   GfxRGB fill_color, stroke_color;
-  cairo_pattern_t *fill_pattern, *stroke_pattern;
+  cairo_pattern_t *fill_pattern, *stroke_pattern, *old_stroke_pattern;
   double fill_opacity;
   double stroke_opacity;
   CairoFont *currentFont;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2008-03-02 Thread Jeff Muizelaar
 poppler/CairoOutputDev.cc |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit ec01926e5a9dc16e200060497c43e79a1623698d
Author: Jeff Muizelaar [EMAIL PROTECTED]
Date:   Sun Mar 2 20:15:20 2008 -0500

Avoid setting a singular ctm

Ignoring singular ctm's gives a better result than having
our cairo context error and turn off. Related to #14398.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 43b1ca4..d69013a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -217,6 +217,20 @@ void CairoOutputDev::updateCTM(GfxState *state, double 
m11, double m12,
   matrix.x0 = m31;
   matrix.y0 = m32;
 
+  /* Make sure the matrix is invertible before setting it.
+   * cairo will blow up if we give it a matrix that's not
+   * invertible, so we need to check before passing it
+   * to cairo_transform. Ignoring it is likely to give better
+   * results than not rendering anything at all. See #14398
+   *
+   * Ideally, we could do the cairo_transform
+   * and then check if anything went wrong and fix it then
+   * instead of having to invert the matrix twice. */
+  if (cairo_matrix_invert(matrix)) {
+warning(matrix not invertible\n);
+return;
+  }
+
   cairo_transform (cairo, matrix);
   if (cairo_shape)
 cairo_transform (cairo_shape, matrix);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc

2008-02-21 Thread Carlos Garcia Campos
 poppler/CairoOutputDev.cc |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 053ecae534a4522d152b0139b6aed6da2059d760
Author: Carl Worth [EMAIL PROTECTED]
Date:   Wed Feb 20 17:21:27 2008 -0800

Keep cairo and cairo_shape consistent

The 'cairo_shape' state was not always being modified at the same
time as 'cairo'. In some cases this led to a sequence of ever
larger matrix scale factors until things just blew up.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 0bc0ab4..43b1ca4 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -158,11 +158,15 @@ void CairoOutputDev::drawLink(Link *link, Catalog 
*catalog) {
 void CairoOutputDev::saveState(GfxState *state) {
   LOG(printf (save\n));
   cairo_save (cairo);
+  if (cairo_shape)
+  cairo_save (cairo_shape);
 }
 
 void CairoOutputDev::restoreState(GfxState *state) {
   LOG(printf (restore\n));
   cairo_restore (cairo);
+  if (cairo_shape)
+  cairo_restore (cairo_shape);
 
   /* These aren't restored by cairo_restore() since we keep them in
* the output device. */
@@ -196,6 +200,8 @@ void CairoOutputDev::setDefaultCTM(double *ctm) {
   matrix.y0 = ctm[5];
 
   cairo_transform (cairo, matrix);
+  if (shape)
+  cairo_transform (cairo_shape, matrix);
 
   OutputDev::setDefaultCTM(ctm);
 }
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

2007-11-12 Thread Jeff Muizelaar
 poppler/CairoOutputDev.cc |  309 --
 poppler/CairoOutputDev.h  |8 +
 2 files changed, 303 insertions(+), 14 deletions(-)

New commits:
commit 6f8451cf9d19f57f658d1568643ecb0f953e1075
Author: Jeff Muizelaar [EMAIL PROTECTED]
Date:   Sun Nov 11 21:29:40 2007 -0500

Add support for knockout groups to the cairo backend

This is sort of hacky because we need to keep track of shape and opacity
seperately.  It is also probably not entirely correct. However, it should be
closer than previously.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 68258d2..ef6e42f 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -87,6 +87,9 @@ CairoOutputDev::CairoOutputDev() {
   groupColorSpaceStack = NULL;
   group = NULL;
   mask = NULL;
+  shape = NULL;
+  cairo_shape = NULL;
+  knockoutCount = 0;
 }
 
 CairoOutputDev::~CairoOutputDev() {
@@ -99,6 +102,10 @@ CairoOutputDev::~CairoOutputDev() {
 cairo_destroy (cairo);
   cairo_pattern_destroy (stroke_pattern);
   cairo_pattern_destroy (fill_pattern);
+  if (group)
+cairo_pattern_destroy (group);
+  if (shape)
+cairo_pattern_destroy (shape);
 }
 
 void CairoOutputDev::setCairo(cairo_t *cairo)
@@ -109,6 +116,7 @@ void CairoOutputDev::setCairo(cairo_t *cairo)
   warning(cairo context error: %s\n, cairo_status_to_string(status));
 }
 cairo_destroy (this-cairo);
+assert(!cairo_shape);
   }
   if (cairo != NULL) {
 this-cairo = cairo_reference (cairo);
@@ -117,6 +125,7 @@ void CairoOutputDev::setCairo(cairo_t *cairo)
cairo_get_matrix(cairo, orig_matrix);
   } else {
 this-cairo = NULL;
+this-cairo_shape = NULL;
   }
 }
 
@@ -197,6 +206,8 @@ void CairoOutputDev::updateCTM(GfxState *state, double m11, 
double m12,
   matrix.y0 = m32;
 
   cairo_transform (cairo, matrix);
+  if (cairo_shape)
+cairo_transform (cairo_shape, matrix);
   updateLineDash(state);
   updateLineJoin(state);
   updateLineCap(state);
@@ -210,6 +221,8 @@ void CairoOutputDev::updateLineDash(GfxState *state) {
 
   state-getLineDash(dashPattern, dashLength, dashStart);
   cairo_set_dash (cairo, dashPattern, dashLength, dashStart);
+  if (cairo_shape)
+cairo_set_dash (cairo_shape, dashPattern, dashLength, dashStart);
 }
 
 void CairoOutputDev::updateFlatness(GfxState *state) {
@@ -228,6 +241,8 @@ void CairoOutputDev::updateLineJoin(GfxState *state) {
 cairo_set_line_join (cairo, CAIRO_LINE_JOIN_BEVEL);
 break;
   }
+  if (cairo_shape)
+cairo_set_line_join (cairo_shape, cairo_get_line_join(cairo));
 }
 
 void CairoOutputDev::updateLineCap(GfxState *state) {
@@ -242,10 +257,14 @@ void CairoOutputDev::updateLineCap(GfxState *state) {
 cairo_set_line_cap (cairo, CAIRO_LINE_CAP_SQUARE);
 break;
   }
+  if (cairo_shape)
+cairo_set_line_cap (cairo_shape, cairo_get_line_cap(cairo));
 }
 
 void CairoOutputDev::updateMiterLimit(GfxState *state) {
   cairo_set_miter_limit (cairo, state-getMiterLimit());
+  if (cairo_shape)
+cairo_set_miter_limit (cairo_shape, state-getMiterLimit());
 }
 
 #define MIN(a,b) (((a)  (b)) ? (a) : (b))
@@ -261,6 +280,8 @@ void CairoOutputDev::updateLineWidth(GfxState *state) {
   } else {
 cairo_set_line_width (cairo, state-getLineWidth());
   }
+  if (cairo_shape)
+cairo_set_line_width (cairo_shape, cairo_get_line_width (cairo));
 }
 
 void CairoOutputDev::updateFillColor(GfxState *state) {
@@ -349,7 +370,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
   cairo_set_font_matrix (cairo, matrix);
 }
 
-void CairoOutputDev::doPath(GfxState *state, GfxPath *path) {
+void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
   GfxSubpath *subpath;
   int i, j;
   for (i = 0; i  path-getNumSubpaths(); ++i) {
@@ -379,40 +400,68 @@ void CairoOutputDev::doPath(GfxState *state, GfxPath 
*path) {
 }
 
 void CairoOutputDev::stroke(GfxState *state) {
-  doPath (state, state-getPath());
+  doPath (cairo, state, state-getPath());
   cairo_set_source (cairo, stroke_pattern);
   LOG(printf (stroke\n));
   cairo_stroke (cairo);
+  if (cairo_shape) {
+doPath (cairo_shape, state, state-getPath());
+cairo_stroke (cairo_shape);
+  }
 }
 
 void CairoOutputDev::fill(GfxState *state) {
-  doPath (state, state-getPath());
+  doPath (cairo, state, state-getPath());
   cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING);
   cairo_set_source (cairo, fill_pattern);
   LOG(printf (fill\n));
+  //XXX: how do we get the path
   cairo_fill (cairo);
+  if (cairo_shape) {
+cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_WINDING);
+doPath (cairo_shape, state, state-getPath());
+cairo_fill (cairo_shape);
+  }
 }
 
 void CairoOutputDev::eoFill(GfxState *state) {
-  doPath (state, state-getPath());
+  doPath (cairo, state, state-getPath());
   cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_EVEN_ODD);
   cairo_set_source (cairo, fill_pattern);
   LOG(printf (fill-eo\n));
   cairo_fill 

[poppler] poppler/CairoOutputDev.cc

2007-10-06 Thread Jeff Muizelaar
 poppler/CairoOutputDev.cc |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
diff-tree 1627fbbde8be01af3bdd2583f3439897a37d5215 (from 
3156d560c5eaf6970da422d0b09fd2e95bfe6d1d)
Author: Jeff Muizelaar [EMAIL PROTECTED]
Date:   Sat Oct 6 23:27:40 2007 -0400

Use maskWidth and maskHeight for reading from the mask image in 
CairoOutputDev::drawMaskedImage()

Previously, drawMaskedImage() was incorrectly using the image width and 
height which is
wrong when width != maskWidth or heigh != maskHeight. Fixes #12668.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a51b6b6..d2a57b6 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1046,10 +1046,10 @@ void CairoOutputDev::drawMaskedImage(Gfx
   
   invert_bit = maskInvert ? 1 : 0;
 
-  for (y = 0; y  height; y++) {
+  for (y = 0; y  maskHeight; y++) {
 pix = maskImgStr-getLine();
 maskDest = maskBuffer + y * row_stride;
-for (x = 0; x  width; x++) {
+for (x = 0; x  maskWidth; x++) {
   if (pix[x] ^ invert_bit)
*maskDest++ = 0;
   else
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/poppler: CairoOutputDev.cc,1.46,1.47

2006-12-20 Thread Jeff Muizelaar
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv4741/poppler

Modified Files:
CairoOutputDev.cc 
Log Message:
2006-12-20  Jeff Muizelaar  [EMAIL PROTECTED]

* poppler/GlobalParams.cc: Try to make zero-width lines as close to
one pixel wide as we can. Fixes #9393.


Index: CairoOutputDev.cc
===
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- CairoOutputDev.cc   12 Dec 2006 05:24:00 -  1.46
+++ CairoOutputDev.cc   20 Dec 2006 19:55:55 -  1.47
@@ -202,12 +202,18 @@
   cairo_set_miter_limit (cairo, state-getMiterLimit());
 }
 
+#define MIN(a,b) (a)  (b) ? (a) : (b)
+
 void CairoOutputDev::updateLineWidth(GfxState *state) {
   LOG(printf (line width: %f\n, state-getLineWidth()));
   if (state-getLineWidth() == 0.0) {
-  cairo_set_line_width (cairo, 72.0/300.0);
+/* find out how big pixels (device unit) are in the x and y directions
+ * choose the smaller of the two as our line width */
+double x = 1.0, y = 1.0;
+cairo_device_to_user_distance(cairo, x, y);
+cairo_set_line_width (cairo, MIN(fabs(x),fabs(y)));
   } else {
-  cairo_set_line_width (cairo, state-getLineWidth());
+cairo_set_line_width (cairo, state-getLineWidth());
   }
 }
 

___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/poppler: CairoOutputDev.cc,1.47,1.48

2006-12-20 Thread Jeff Muizelaar
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv3645/poppler

Modified Files:
CairoOutputDev.cc 
Log Message:
2006-12-20  Jeff Muizelaar  [EMAIL PROTECTED]

* poppler/CairoOutputDev.cc: Fix scaling of maskedImage masks. They
should be scaled to the size of the image not the size of the mask.
Fixes #9403.


Index: CairoOutputDev.cc
===
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- CairoOutputDev.cc   20 Dec 2006 19:55:55 -  1.47
+++ CairoOutputDev.cc   21 Dec 2006 01:01:30 -  1.48
@@ -621,7 +621,6 @@
   GfxRGB rgb;
   int alpha, i;
   cairo_matrix_t matrix;
-  cairo_matrix_t maskMatrix;
   int is_identity_transform;
 
   buffer = (unsigned char *)gmalloc (width * height * 4);
@@ -663,12 +662,9 @@
   cairo_matrix_init_translate (matrix, 0, height);
   cairo_matrix_scale (matrix, width, -height);
 
-  cairo_matrix_init_translate (maskMatrix, 0, maskHeight);
-  cairo_matrix_scale (maskMatrix, maskWidth, -maskHeight);
-
-
+  /* scale the mask to the size of the image unlike softMask */
   cairo_pattern_set_matrix (pattern, matrix);
-  cairo_pattern_set_matrix (maskPattern, maskMatrix);
+  cairo_pattern_set_matrix (maskPattern, matrix);
 
   cairo_pattern_set_filter (pattern, CAIRO_FILTER_BILINEAR);
   cairo_set_source (cairo, pattern);

___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/poppler: CairoOutputDev.cc,1.45,1.46

2006-12-11 Thread Jeff Muizelaar
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv2592/poppler

Modified Files:
CairoOutputDev.cc 
Log Message:
2006-12-12  Jeff Muizelaar  [EMAIL PROTECTED]

* poppler/CairoOutputDev.cc: Change a cairo_set_matrix to 
cairo_transform so that we don't blindly clobber the existing matrix.
Patch by Daniel Colascione.
Fixes #9190.


Index: CairoOutputDev.cc
===
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- CairoOutputDev.cc   7 Nov 2006 23:53:31 -   1.45
+++ CairoOutputDev.cc   12 Dec 2006 05:24:00 -  1.46
@@ -134,7 +134,7 @@
   matrix.x0 = ctm[4];
   matrix.y0 = ctm[5];
 
-  cairo_set_matrix (cairo, matrix);
+  cairo_transform (cairo, matrix);
 
   OutputDev::setDefaultCTM(ctm);
 }

___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler