[poppler] poppler/CairoOutputDev.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Nov 6 23:40:14 UTC 2021
poppler/CairoOutputDev.cc | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
New commits:
commit 0e8d7d11838dc16cdc6141c026def43710c8b326
Author: Adrian Johnson <ajohnson at redneon.com>
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(), &strBuffer, &len)) {
- 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(), &strBuffer, &len))
status = cairo_surface_set_mime_data(image, mime_type, (const unsigned char *)strBuffer, len, gfree, strBuffer);
- }
if (status)
gfree(strBuffer);
More information about the poppler
mailing list