[poppler] 3 commits - poppler/CairoOutputDev.cc
Chris Wilson
ickle at kemper.freedesktop.org
Fri Nov 6 09:51:32 PST 2009
poppler/CairoOutputDev.cc | 105 ++++++++++++++++++++++++++++------------------
1 file changed, 66 insertions(+), 39 deletions(-)
New commits:
commit 32ea667ec8f18311539123c7b80c7ab4767070cb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 11 19:17:52 2009 +0100
[cairo] Mark images dirty
After directly manipulating the pixel values we need to mark the surface
as dirty. This means that cairo will refresh any caches it may have taken
of the surface will the new data.
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index b7a84cc..500583a 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1262,6 +1262,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha,
}
}
+ cairo_surface_mark_dirty (source);
/* setup the new mask pattern */
mask = cairo_pattern_create_for_surface(source);
@@ -1378,6 +1379,7 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
}
}
+ cairo_surface_mark_dirty (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
if (cairo_pattern_status (pattern))
@@ -1636,6 +1638,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
}
free(pixBuf);
+ cairo_surface_mark_dirty (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
if (cairo_pattern_status (pattern)) {
@@ -1751,6 +1754,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
maskImgStr->close();
delete maskImgStr;
+ cairo_surface_mark_dirty (maskImage);
maskPattern = cairo_pattern_create_for_surface (maskImage);
cairo_surface_destroy (maskImage);
if (cairo_pattern_status (maskPattern))
@@ -1783,6 +1787,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
colorMap->getRGBLine (pix, dest, width);
}
+ cairo_surface_mark_dirty (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
if (cairo_pattern_status (pattern))
@@ -1871,6 +1876,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
maskImgStr->close();
delete maskImgStr;
+ cairo_surface_mark_dirty (maskImage);
maskPattern = cairo_pattern_create_for_surface (maskImage);
cairo_surface_destroy (maskImage);
if (cairo_pattern_status (maskPattern))
@@ -1903,6 +1909,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
colorMap->getRGBLine (pix, dest, width);
}
+ cairo_surface_mark_dirty (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
if (cairo_pattern_status (pattern))
@@ -2047,6 +2054,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
}
gfree(lookup);
+ cairo_surface_mark_dirty (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image);
if (cairo_pattern_status (pattern))
commit 10a41150c4067bb3ab85e25dae76e0968a6cd586
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 11 19:17:06 2009 +0100
[cairo] Use colToDbl() to avoid rounding error.
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 772de15..b7a84cc 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -421,9 +421,9 @@ void CairoOutputDev::updateFillColor(GfxState *state) {
color.b != fill_color.b)
{
cairo_pattern_destroy(fill_pattern);
- fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
- fill_color.g / 65535.0,
- fill_color.b / 65535.0,
+ fill_pattern = cairo_pattern_create_rgba(colToDbl(fill_color.r),
+ colToDbl(fill_color.g),
+ colToDbl(fill_color.b),
fill_opacity);
LOG(printf ("fill color: %d %d %d\n",
@@ -440,9 +440,9 @@ void CairoOutputDev::updateStrokeColor(GfxState *state) {
color.b != stroke_color.b)
{
cairo_pattern_destroy(stroke_pattern);
- stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
- stroke_color.g / 65535.0,
- stroke_color.b / 65535.0,
+ stroke_pattern = cairo_pattern_create_rgba(colToDbl(stroke_color.r),
+ colToDbl(stroke_color.g),
+ colToDbl(stroke_color.b),
stroke_opacity);
LOG(printf ("stroke color: %d %d %d\n",
@@ -456,9 +456,9 @@ void CairoOutputDev::updateFillOpacity(GfxState *state) {
fill_opacity = state->getFillOpacity();
if (opacity != fill_opacity) {
cairo_pattern_destroy(fill_pattern);
- fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
- fill_color.g / 65535.0,
- fill_color.b / 65535.0,
+ fill_pattern = cairo_pattern_create_rgba(colToDbl(fill_color.r),
+ colToDbl(fill_color.g),
+ colToDbl(fill_color.b),
fill_opacity);
LOG(printf ("fill opacity: %f\n", fill_opacity));
@@ -471,9 +471,9 @@ void CairoOutputDev::updateStrokeOpacity(GfxState *state) {
stroke_opacity = state->getStrokeOpacity();
if (opacity != stroke_opacity) {
cairo_pattern_destroy(stroke_pattern);
- stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
- stroke_color.g / 65535.0,
- stroke_color.b / 65535.0,
+ stroke_pattern = cairo_pattern_create_rgba(colToDbl(stroke_color.r),
+ colToDbl(stroke_color.g),
+ colToDbl(stroke_color.b),
stroke_opacity);
LOG(printf ("stroke opacity: %f\n", stroke_opacity));
@@ -484,9 +484,9 @@ void CairoOutputDev::updateFillColorStop(GfxState *state, double offset) {
state->getFillRGB(&fill_color);
cairo_pattern_add_color_stop_rgba(fill_pattern, offset,
- fill_color.r / 65535.0,
- fill_color.g / 65535.0,
- fill_color.b / 65535.0,
+ colToDbl(fill_color.r),
+ colToDbl(fill_color.g),
+ colToDbl(fill_color.b),
fill_opacity);
LOG(printf ("fill color stop: %f (%d, %d, %d)\n",
offset, fill_color.r, fill_color.g, fill_color.b));
@@ -1217,9 +1217,10 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha,
GfxRGB backdropColorRGB;
groupColorSpaceStack->cs->getRGB(backdropColor, &backdropColorRGB);
/* paint the backdrop */
- cairo_set_source_rgb(maskCtx, backdropColorRGB.r / 65535.0,
- backdropColorRGB.g / 65535.0,
- backdropColorRGB.b / 65535.0);
+ cairo_set_source_rgb(maskCtx,
+ colToDbl(backdropColorRGB.r),
+ colToDbl(backdropColorRGB.g),
+ colToDbl(backdropColorRGB.b));
cairo_matrix_t mat;
commit c9491319689f04edd57adda7ee85f84f17fd1c47
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 11 18:07:17 2009 +0100
[cairo] Reduce the number of redundant pattern creations
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 19d1245..772de15 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -222,10 +222,10 @@ void CairoOutputDev::startDoc(XRef *xrefA, Catalog *catalogA,
void CairoOutputDev::startPage(int pageNum, GfxState *state) {
/* set up some per page defaults */
cairo_pattern_destroy(fill_pattern);
- fill_pattern = cairo_pattern_create_rgb(0., 0., 0.);
-
cairo_pattern_destroy(stroke_pattern);
- stroke_pattern = cairo_pattern_create_rgb(0., 0., 0.);
+
+ fill_pattern = cairo_pattern_create_rgb(0., 0., 0.);
+ stroke_pattern = cairo_pattern_reference(fill_pattern);
if (text)
text->startPage(state);
@@ -413,53 +413,71 @@ void CairoOutputDev::updateLineWidth(GfxState *state) {
}
void CairoOutputDev::updateFillColor(GfxState *state) {
- state->getFillRGB(&fill_color);
+ GfxRGB color = fill_color;
- cairo_pattern_destroy(fill_pattern);
- fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
- fill_color.g / 65535.0,
- fill_color.b / 65535.0,
- fill_opacity);
+ state->getFillRGB(&fill_color);
+ if (color.r != fill_color.r ||
+ color.g != fill_color.g ||
+ color.b != fill_color.b)
+ {
+ cairo_pattern_destroy(fill_pattern);
+ fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
+ fill_color.g / 65535.0,
+ fill_color.b / 65535.0,
+ fill_opacity);
- LOG(printf ("fill color: %d %d %d\n",
- fill_color.r, fill_color.g, fill_color.b));
+ LOG(printf ("fill color: %d %d %d\n",
+ fill_color.r, fill_color.g, fill_color.b));
+ }
}
void CairoOutputDev::updateStrokeColor(GfxState *state) {
+ GfxRGB color = stroke_color;
+
state->getStrokeRGB(&stroke_color);
+ if (color.r != stroke_color.r ||
+ color.g != stroke_color.g ||
+ color.b != stroke_color.b)
+ {
+ cairo_pattern_destroy(stroke_pattern);
+ stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
+ stroke_color.g / 65535.0,
+ stroke_color.b / 65535.0,
+ stroke_opacity);
- cairo_pattern_destroy(stroke_pattern);
- stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
- stroke_color.g / 65535.0,
- stroke_color.b / 65535.0,
- stroke_opacity);
-
- LOG(printf ("stroke color: %d %d %d\n",
- stroke_color.r, stroke_color.g, stroke_color.b));
+ LOG(printf ("stroke color: %d %d %d\n",
+ stroke_color.r, stroke_color.g, stroke_color.b));
+ }
}
void CairoOutputDev::updateFillOpacity(GfxState *state) {
- fill_opacity = state->getFillOpacity();
+ double opacity = fill_opacity;
- cairo_pattern_destroy(fill_pattern);
- fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
- fill_color.g / 65535.0,
- fill_color.b / 65535.0,
- fill_opacity);
+ fill_opacity = state->getFillOpacity();
+ if (opacity != fill_opacity) {
+ cairo_pattern_destroy(fill_pattern);
+ fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0,
+ fill_color.g / 65535.0,
+ fill_color.b / 65535.0,
+ fill_opacity);
- LOG(printf ("fill opacity: %f\n", fill_opacity));
+ LOG(printf ("fill opacity: %f\n", fill_opacity));
+ }
}
void CairoOutputDev::updateStrokeOpacity(GfxState *state) {
+ double opacity = stroke_opacity;
+
stroke_opacity = state->getStrokeOpacity();
+ if (opacity != stroke_opacity) {
+ cairo_pattern_destroy(stroke_pattern);
+ stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
+ stroke_color.g / 65535.0,
+ stroke_color.b / 65535.0,
+ stroke_opacity);
- cairo_pattern_destroy(stroke_pattern);
- stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0,
- stroke_color.g / 65535.0,
- stroke_color.b / 65535.0,
- stroke_opacity);
-
- LOG(printf ("stroke opacity: %f\n", stroke_opacity));
+ LOG(printf ("stroke opacity: %f\n", stroke_opacity));
+ }
}
void CairoOutputDev::updateFillColorStop(GfxState *state, double offset) {
More information about the poppler
mailing list