[cairo-commit] 2 commits - src/cairo-pdf-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Fri Jul 29 05:10:13 PDT 2011
src/cairo-pdf-surface.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
New commits:
commit ccf67c7d748aa10005fb47b4d565c34e41c1a327
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jul 29 13:06:49 2011 +0100
pdf: Don't remove the current clip if redundant
If the surface already has a clip set and that clip does not interfere
with the operation then we can leave it set.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 1e6b22c..d6f382b 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -5756,6 +5756,17 @@ _cairo_pdf_surface_set_clip (cairo_pdf_surface_t *surface,
clip = NULL;
}
+ if (clip == NULL) {
+ cairo_clip_t *current = surface->clipper.clip;
+
+ if (current && _cairo_clip_is_region (current) &&
+ cairo_region_contains_rectangle (_cairo_clip_get_region (current),
+ &composite->unbounded) == CAIRO_REGION_OVERLAP_IN)
+ {
+ return CAIRO_STATUS_SUCCESS;
+ }
+ }
+
return _cairo_surface_clipper_set_clip (&surface->clipper, clip);
}
commit 6ed0c6224b763e9cbcfb0d46f188883d8425bab5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jul 29 13:03:59 2011 +0100
pdf: Remove redundant clip regions
If the extents of the operation is wholly contained within the clip
region, then we can safely not invoke any clipping.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 2411f6d..1e6b22c 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -5743,6 +5743,21 @@ cleanup:
return status;
}
+static cairo_int_status_t
+_cairo_pdf_surface_set_clip (cairo_pdf_surface_t *surface,
+ cairo_composite_rectangles_t *composite)
+{
+ cairo_clip_t *clip = composite->clip;
+
+ if (_cairo_clip_is_region (clip) &&
+ cairo_region_contains_rectangle (_cairo_clip_get_region (clip),
+ &composite->unbounded) == CAIRO_REGION_OVERLAP_IN)
+ {
+ clip = NULL;
+ }
+
+ return _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+}
static cairo_int_status_t
_cairo_pdf_surface_paint (void *abstract_surface,
@@ -5777,7 +5792,7 @@ _cairo_pdf_surface_paint (void *abstract_surface,
assert (_cairo_pdf_surface_operation_supported (surface, op, source, &extents.bounded));
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_pdf_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -5910,7 +5925,7 @@ _cairo_pdf_surface_mask (void *abstract_surface,
assert (_cairo_pdf_surface_operation_supported (surface, op, source, &extents.bounded));
assert (_cairo_pdf_surface_operation_supported (surface, op, mask, &extents.bounded));
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_pdf_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -6019,7 +6034,7 @@ _cairo_pdf_surface_stroke (void *abstract_surface,
assert (_cairo_pdf_surface_operation_supported (surface, op, source, &extents.bounded));
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_pdf_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -6150,7 +6165,7 @@ _cairo_pdf_surface_fill (void *abstract_surface,
assert (_cairo_pdf_surface_operation_supported (surface, op, source, &extents.bounded));
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_pdf_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -6297,7 +6312,7 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
if (fill_op != stroke_op)
return CAIRO_INT_STATUS_UNSUPPORTED;
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_pdf_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -6443,7 +6458,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface,
assert (_cairo_pdf_surface_operation_supported (surface, op, source, &extents.bounded));
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_pdf_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
More information about the cairo-commit
mailing list