summaryrefslogtreecommitdiff
path: root/draw/draw_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw/draw_device.c')
-rw-r--r--draw/draw_device.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 22cdc720..8042ce84 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -43,6 +43,7 @@ static void fz_knockout_begin(void *user)
fz_draw_device *dev = user;
fz_bbox bbox;
fz_pixmap *dest, *shape;
+ int isolated = dev->blendmode & FZ_BLEND_ISOLATED;
if ((dev->blendmode & FZ_BLEND_KNOCKOUT) == 0)
return;
@@ -57,10 +58,9 @@ static void fz_knockout_begin(void *user)
bbox = fz_intersect_bbox(bbox, dev->scissor);
dest = fz_new_pixmap_with_rect(dev->dest->colorspace, bbox);
- if (dev->blendmode & FZ_BLEND_ISOLATED)
+ if (isolated)
{
fz_clear_pixmap(dest);
- shape = dev->shape;
}
else
{
@@ -69,9 +69,19 @@ static void fz_knockout_begin(void *user)
do {
prev = dev->stack[--i].dest;
} while (prev == NULL);
+ fz_copy_pixmap_rect(dest, prev, bbox);
+ }
+
+ if (dev->blendmode == 0 && isolated)
+ {
+ /* We can render direct to any existing shape plane. If there
+ * isn't one, we don't need to make one. */
+ shape = dev->shape;
+ }
+ else
+ {
shape = fz_new_pixmap_with_rect(NULL, bbox);
fz_clear_pixmap(shape);
- fz_copy_pixmap_rect(dest, prev, bbox);
}
dev->stack[dev->top].blendmode = dev->blendmode;
dev->stack[dev->top].scissor = dev->scissor;
@@ -1149,13 +1159,22 @@ fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, int bl
if (isolated)
{
fz_clear_pixmap(dest);
+ }
+ else
+ {
+ fz_copy_pixmap_rect(dest, dev->dest, bbox);
+ }
+
+ if (blendmode == 0 && alpha == 1.0 && isolated)
+ {
+ /* We can render direct to any existing shape plane. If there
+ * isn't one, we don't need to make one. */
shape = dev->shape;
}
else
{
shape = fz_new_pixmap_with_rect(NULL, bbox);
fz_clear_pixmap(shape);
- fz_copy_pixmap_rect(dest, dev->dest, bbox);
}
dev->stack[dev->top].alpha = alpha;
@@ -1202,7 +1221,7 @@ fz_draw_end_group(void *user)
{
if (dev->shape)
{
- fz_paint_pixmap(dev->shape, shape, 255);
+ fz_paint_pixmap(dev->shape, shape, alpha * 255);
}
fz_drop_pixmap(shape);
}