summaryrefslogtreecommitdiff
path: root/fitz/base_geometry.c
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2011-07-06 16:32:33 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-07-08 19:26:34 +0100
commit2c4bbbfdc7413a68cad395c3c61ff8e62dceb18b (patch)
treec2299029fa26028103e533c2dce15aa18d9a8d76 /fitz/base_geometry.c
parent2f8acb0010c469c46682a298d66b108cc4c6cdd0 (diff)
downloadmupdf-2c4bbbfdc7413a68cad395c3c61ff8e62dceb18b.tar.xz
Clip area optimisations for displaylist case:
First, we add clipping rects to clipping functions. Various functions (the ones that handle clipping) are now additionally passed a rectangle that represents an additional bound for this clip in device space (i.e. it has already been mapped through the current ctm). Next, when constructing the displaylist, keep track of the bounding box for the contents of each clip. While writing the list, on every node we add, we add the bbox for that node to the enclosing clips content bbox (if there is an enclosing clip). When we pop a clip, write back to the corresponding push to update the bbox. This means if we get large clip regions, with only small areas used within them, we will only do the slow blending for those small areas. Finally, we fix a calculation in fz_bound_path which was incorrectly accounting for mitrelimits. This was showing up in testing on page 630 of the PDF reference v1.7.
Diffstat (limited to 'fitz/base_geometry.c')
-rw-r--r--fitz/base_geometry.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c
index 302ef966..00a85c9b 100644
--- a/fitz/base_geometry.c
+++ b/fitz/base_geometry.c
@@ -160,6 +160,36 @@ fz_round_rect(fz_rect f)
return i;
}
+fz_rect
+fz_intersect_rect(fz_rect a, fz_rect b)
+{
+ fz_rect r;
+ if (fz_is_infinite_rect(a)) return b;
+ if (fz_is_infinite_rect(b)) return a;
+ if (fz_is_empty_rect(a)) return fz_empty_rect;
+ if (fz_is_empty_rect(b)) return fz_empty_rect;
+ r.x0 = MAX(a.x0, b.x0);
+ r.y0 = MAX(a.y0, b.y0);
+ r.x1 = MIN(a.x1, b.x1);
+ r.y1 = MIN(a.y1, b.y1);
+ return (r.x1 < r.x0 || r.y1 < r.y0) ? fz_empty_rect : r;
+}
+
+fz_rect
+fz_union_rect(fz_rect a, fz_rect b)
+{
+ fz_rect r;
+ if (fz_is_infinite_rect(a)) return a;
+ if (fz_is_infinite_rect(b)) return b;
+ if (fz_is_empty_rect(a)) return b;
+ if (fz_is_empty_rect(b)) return a;
+ r.x0 = MIN(a.x0, b.x0);
+ r.y0 = MIN(a.y0, b.y0);
+ r.x1 = MAX(a.x1, b.x1);
+ r.y1 = MAX(a.y1, b.y1);
+ return r;
+}
+
fz_bbox
fz_intersect_bbox(fz_bbox a, fz_bbox b)
{