From c55da771bca04fde528a4a104f3a8499d7327c2f Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Mon, 6 Oct 2014 10:21:51 +1030 Subject: [PATCH 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 | 15 +++++++++++---- poppler/CairoOutputDev.h | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index d25243f..5f6f813 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,10 +2674,11 @@ GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length) return gTrue; } -void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, cairo_surface_t *image) +void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, + GfxImageColorMap *colorMap, cairo_surface_t *image) { char *strBuffer; - int len; + int len, i; Object obj; GfxColorSpace *colorSpace; @@ -2715,6 +2716,12 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, cair } } + // only embed mime data if image decode map is identiy + for (i = 0; i < colorMap->getNumPixelComps(); i++) { + if (colorMap->getDecodeLow(i) != 0.0 || colorMap->getDecodeHigh(i) != 1.0) + return; + } + if (getStreamData (str->getNextStream(), &strBuffer, &len)) { cairo_status_t st; @@ -2932,7 +2939,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