poppler/CairoOutputDev.cc | 18 ++++++++++++++++-- poppler/CairoOutputDev.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-)
New commits: commit 5aa854f70c8f563efe56dafa8bd6b3cdd5c95451 Author: Carlos Garcia Campos <[email protected]> Date: Sun Feb 6 13:24:35 2011 +0100 cairo: Use the new cairo unique id to set the surface id when printing Set the unique surface id when attaching jpeg images to the surface so that cairo can reuse the mime data even when a new surface is created with the same mime data. This reduces the size of the output file when printing. diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 6bfe5a8..18fc480 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, cairo_surface_t *image) +void CairoOutputDev::setMimeData(Stream *str, Ref ref, cairo_surface_t *image) { char *strBuffer; int len; @@ -2442,6 +2442,20 @@ void CairoOutputDev::setMimeData(Stream *str, cairo_surface_t *image) if (getStreamData (str->getNextStream(), &strBuffer, &len)) { 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; +#endif + st = cairo_surface_set_mime_data (image, str->getKind() == strDCT ? CAIRO_MIME_TYPE_JPEG : CAIRO_MIME_TYPE_JP2, @@ -2565,7 +2579,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, cairo_surface_mark_dirty (image); - setMimeData(str, image); + setMimeData(str, ref->getRef(), image); pattern = cairo_pattern_create_for_surface (image); cairo_surface_destroy (image); diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index 8e25575..630590c 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, cairo_surface_t *image); + void setMimeData(Stream *str, Ref ref, cairo_surface_t *image); GfxRGB fill_color, stroke_color; cairo_pattern_t *fill_pattern, *stroke_pattern; _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
