From 7d542c4ffb2da1b34db6b0de2df03ca9f6bef2ca Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Mon, 6 Oct 2014 10:21:51 +1030 Subject: [PATCH v2 2/2] cairo: only embed mime data if image decode map is identity https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/1317517 --- poppler/CairoOutputDev.cc | 19 ++++++++++++++++--- poppler/CairoOutputDev.h | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index d25243f..fdd97b5 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -2571,7 +2571,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s cairo_surface_mark_dirty (image); - setMimeData(state, str, ref, image); + setMimeData(state, str, ref, colorMap, image); pattern = cairo_pattern_create_for_surface (image); cairo_surface_destroy (image); @@ -2674,7 +2674,17 @@ GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length) return gTrue; } -void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, cairo_surface_t *image) +static GBool colorMapHasIdentityDecodeMap(GfxImageColorMap *colorMap) +{ + for (int i = 0; i < colorMap->getNumPixelComps(); i++) { + if (colorMap->getDecodeLow(i) != 0.0 || colorMap->getDecodeHigh(i) != 1.0) + return gFalse; + } + return gTrue; +} + +void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, + GfxImageColorMap *colorMap, cairo_surface_t *image) { char *strBuffer; int len; @@ -2715,6 +2725,9 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, cair } } + if (!colorMapHasIdentityDecodeMap(colorMap)) + return; + if (getStreamData (str->getNextStream(), &strBuffer, &len)) { cairo_status_t st; @@ -2932,7 +2945,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, filter = getFilterForSurface (image, interpolate); if (!inlineImg) /* don't read stream twice if it is an inline image */ - setMimeData(state, str, ref, image); + setMimeData(state, str, ref, colorMap, image); pattern = cairo_pattern_create_for_surface (image); cairo_surface_destroy (image); diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index bad88a8..3f91c4f 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -276,7 +276,8 @@ protected: cairo_filter_t getFilterForSurface(cairo_surface_t *image, GBool interpolate); GBool getStreamData (Stream *str, char **buffer, int *length); - void setMimeData(GfxState *state, Stream *str, Object *ref, cairo_surface_t *image); + void setMimeData(GfxState *state, Stream *str, Object *ref, + GfxImageColorMap *colorMap, cairo_surface_t *image); void fillToStrokePathClip(GfxState *state); void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y); -- 2.1.1