summaryrefslogtreecommitdiff
path: root/fitz/res_pixmap.c
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2011-07-13 20:31:56 +0100
committerRobin Watts <robin.watts@artifex.com>2011-07-13 21:03:28 +0100
commit6913145eefde0e5c4cde9573d8d2cb2a35fd605d (patch)
treef79dc7269f4f562bdb168b572a37367e806e0190 /fitz/res_pixmap.c
parent2c4bbbfdc7413a68cad395c3c61ff8e62dceb18b (diff)
downloadmupdf-6913145eefde0e5c4cde9573d8d2cb2a35fd605d.tar.xz
Non-isolated group support, and fix Bug 692336.
Firstly, this takes on some of Zenikos patch to correct the clip stack handling that was broken by the fix to bug 692287 (in commit 2c3bbbf). This bug should now be solved. We add a new 'shape' field to the draw device structure (and clip stack). When we are inside non-isolated groups, this is set to be a pixmap where we accumulate the 'shape' of the objects drawn. When we come to blend back, if we are blending a non-isolated group back, we have to use a different blending function that takes account of the shape. Various internal groups (the page group, and groups used to force blending) are set to be isolated to avoid carrying shape planes around when this is not required. All our rendering code now has to know how to maintain the shape plane as well as doing the basic rendering.
Diffstat (limited to 'fitz/res_pixmap.c')
-rw-r--r--fitz/res_pixmap.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 27eac291..8b0047f1 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -133,6 +133,91 @@ fz_clear_pixmap_with_color(fz_pixmap *pix, int value)
}
void
+fz_copy_pixmap_rect(fz_pixmap *dest, const fz_pixmap *src, fz_bbox r)
+{
+ const char *srcp;
+ char *destp;
+ int y, w, destspan, srcspan;
+
+ if (r.x0 < dest->x)
+ r.x0 = dest->x;
+ if (r.x1 > dest->x+dest->w)
+ r.x1 = dest->x+dest->w;
+ if (r.y0 < dest->y)
+ r.y0 = dest->y;
+ if (r.y1 > dest->y+dest->h)
+ r.y1 = dest->y+dest->h;
+ if (r.x0 < src->x)
+ r.x0 = src->x;
+ if (r.x1 > src->x+src->w)
+ r.x1 = src->x+src->w;
+ if (r.y0 < src->y)
+ r.y0 = src->y;
+ if (r.y1 > src->y+src->h)
+ r.y1 = src->y+src->h;
+ w = r.x1 - r.x0;
+ y = r.y1 - r.y0;
+ if ((w <= 0) || (y <= 0))
+ return;
+ w *= src->n;
+ srcspan = src->w * src->n;
+ srcp = src->samples + srcspan * (r.y0 - src->y) + src->n * (r.x0 - src->x);
+ destspan = dest->w * dest->n;
+ destp = dest->samples + destspan * (r.y0-dest->y) + dest->n * (r.x0 - dest->x);
+ do
+ {
+ memcpy(destp, srcp, w);
+ srcp += srcspan;
+ destp += destspan;
+ }
+ while (--y);
+}
+
+void
+fz_clear_pixmap_rect_with_color(fz_pixmap *dest, int value, fz_bbox r)
+{
+ char *destp;
+ int x, y, w, k, destspan;
+
+ if (r.x0 < dest->x)
+ r.x0 = dest->x;
+ if (r.x1 > dest->x+dest->w)
+ r.x1 = dest->x+dest->w;
+ if (r.y0 < dest->y)
+ r.y0 = dest->y;
+ if (r.y1 > dest->y+dest->h)
+ r.y1 = dest->y+dest->h;
+ w = r.x1 - r.x0;
+ y = r.y1 - r.y0;
+ if ((w <= 0) || (y <= 0))
+ return;
+ destspan = dest->w * dest->n;
+ destp = dest->samples + destspan * (r.y0-dest->y) + dest->n * (r.x0 - dest->x);
+ if (value == 255)
+ do
+ {
+ memset(destp, 255, w * dest->n);
+ destp += destspan;
+ }
+ while (--y);
+ else
+ {
+ do
+ {
+ char *s = destp;
+ for (x = 0; x < w; x++)
+ {
+ for (k = 0; k < dest->n - 1; k++)
+ *s++ = value;
+ *s++ = 255;
+ }
+ destp += destspan;
+ }
+ while (--y);
+ }
+}
+
+void
fz_premultiply_pixmap(fz_pixmap *pix)
{
unsigned char *s = pix->samples;