[cairo-commit] src/cairo-ps-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Fri Jul 29 05:13:59 PDT 2011
src/cairo-ps-surface.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
New commits:
commit 488c94220d46f10a0fa8fa4dfb1beda88d80988e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jul 29 13:12:48 2011 +0100
ps: Apply the clip reduction techniques from pdf
If the clip wholly covers the operation, we do not need to set one, and
if the current clip similarly covers the operation we do not to unset
it.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 4b8ce80..4d1c321 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -3557,6 +3557,34 @@ _cairo_ps_surface_get_font_options (void *abstract_surface,
}
static cairo_int_status_t
+_cairo_ps_surface_set_clip (cairo_ps_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;
+ }
+
+ 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);
+}
+
+
+static cairo_int_status_t
_cairo_ps_surface_paint (void *abstract_surface,
cairo_operator_t op,
const cairo_pattern_t *source,
@@ -3584,7 +3612,7 @@ _cairo_ps_surface_paint (void *abstract_surface,
"%% _cairo_ps_surface_paint\n");
#endif
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_ps_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -3665,7 +3693,7 @@ _cairo_ps_surface_stroke (void *abstract_surface,
"%% _cairo_ps_surface_stroke\n");
#endif
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_ps_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -3727,7 +3755,7 @@ _cairo_ps_surface_fill (void *abstract_surface,
if (unlikely (status))
return status;
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_ps_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
@@ -3804,7 +3832,7 @@ _cairo_ps_surface_show_glyphs (void *abstract_surface,
"%% _cairo_ps_surface_show_glyphs\n");
#endif
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
+ status = _cairo_ps_surface_set_clip (surface, &extents);
if (unlikely (status))
return status;
More information about the cairo-commit
mailing list