[cairo-commit] src/cairo-surface.c
M. Joonas Pihlaja
joonas at kemper.freedesktop.org
Thu Jun 18 07:31:53 PDT 2009
src/cairo-surface.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
New commits:
commit 46eb56a99f72b364e3eabe46f9b2995ed0696bd3
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date: Thu Jun 18 16:42:53 2009 +0300
[cairo-surface] Handle the all clipped out case for regions.
Explicitly handle a region clip which represents that the
entire surface is clipped out by passing in a temporary
empty region to the backend set_clip_region() method.
Previously the passed in region may have been NULL even
when clip->all_clipped = TRUE.
Fixes a bug tickled by the clip-all test case which was
brought to light by 394e139213e8f6692115c4c24818bfeb5e6d456a.
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 0a927ff..15fdde3 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2548,6 +2548,35 @@ _cairo_surface_set_empty_clip_path (cairo_surface_t *surface,
return _cairo_surface_set_error (surface, status);
}
+/**
+ * _cairo_surface_set_empty_clip_region:
+ * @surface: the #cairo_surface_t to set the clip on
+ * @serial: the clip serial number associated with the clip path
+ *
+ * Create an empty clip region, one that represents the entire surface clipped
+ * out, and assigns the given clipping serial to the surface.
+ **/
+static cairo_status_t
+_cairo_surface_set_empty_clip_region (cairo_surface_t *surface,
+ unsigned int serial)
+{
+ cairo_region_t *region;
+ cairo_status_t status;
+
+ if (surface->status)
+ return surface->status;
+
+ region = cairo_region_create ();
+ status = region->status;
+
+ if (status == CAIRO_STATUS_SUCCESS)
+ status = _cairo_surface_set_clip_region (surface, region, serial);
+
+ cairo_region_destroy (region);
+
+ return _cairo_surface_set_error (surface, status);
+}
+
cairo_clip_t *
_cairo_surface_get_clip (cairo_surface_t *surface)
{
@@ -2583,9 +2612,8 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
clip->serial);
if (surface->backend->set_clip_region != NULL)
- return _cairo_surface_set_clip_region (surface,
- clip->region,
- clip->serial);
+ return _cairo_surface_set_empty_clip_region (surface,
+ clip->serial);
} else {
if (clip->path)
return _cairo_surface_set_clip_path (surface,
More information about the cairo-commit
mailing list