[cairo-commit] 3 commits - src/cairo-clip.c src/cairo-clip-private.h src/cairo-script-surface.c src/cairo-surface-clipper.c test/clip-contexts.c test/clip-contexts.ref.png test/Makefile.am test/Makefile.sources
Chris Wilson
ickle at kemper.freedesktop.org
Sat Apr 10 08:03:31 PDT 2010
src/cairo-clip-private.h | 4 ++
src/cairo-clip.c | 40 ++++++++++++++++++++++--
src/cairo-script-surface.c | 6 +++
src/cairo-surface-clipper.c | 5 ---
test/Makefile.am | 1
test/Makefile.sources | 1
test/clip-contexts.c | 73 ++++++++++++++++++++++++++++++++++++++++++++
test/clip-contexts.ref.png |binary
8 files changed, 123 insertions(+), 7 deletions(-)
New commits:
commit 0899852c974099da9f8c5e493fa89b8d022646c5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Apr 10 16:00:45 2010 +0100
clip: Compare the whole clip when testing for equality.
Should fix test/clip-contexts
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index 05a10e6..815fbf8 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -87,6 +87,10 @@ _cairo_clip_init_copy_transformed (cairo_clip_t *clip,
cairo_private void
_cairo_clip_reset (cairo_clip_t *clip);
+cairo_private cairo_bool_t
+_cairo_clip_equal (const cairo_clip_t *clip_a,
+ const cairo_clip_t *clip_b);
+
#define _cairo_clip_fini(clip) _cairo_clip_reset (clip)
cairo_private cairo_status_t
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 6cdb710..dc1e4b8 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -228,9 +228,8 @@ _cairo_clip_intersect_path (cairo_clip_t *clip,
if (clip->path != NULL) {
if (clip->path->fill_rule == fill_rule &&
- (path->is_rectilinear ||
- (tolerance == clip->path->tolerance &&
- antialias == clip->path->antialias)) &&
+ (path->is_rectilinear || tolerance == clip->path->tolerance) &&
+ antialias == clip->path->antialias &&
_cairo_path_fixed_equal (&clip->path->path, path))
{
return CAIRO_STATUS_SUCCESS;
@@ -282,6 +281,41 @@ _cairo_clip_intersect_path (cairo_clip_t *clip,
return CAIRO_STATUS_SUCCESS;
}
+cairo_bool_t
+_cairo_clip_equal (const cairo_clip_t *clip_a,
+ const cairo_clip_t *clip_b)
+{
+ const cairo_clip_path_t *clip_path_a, *clip_path_b;
+
+ clip_path_a = clip_a->path;
+ clip_path_b = clip_b->path;
+
+ while (clip_path_a && clip_path_b) {
+ if (clip_path_a == clip_path_b)
+ return TRUE;
+
+ if (clip_path_a->is_rectilinear != clip_path_b->is_rectilinear)
+ return FALSE;
+
+ if (clip_path_a->fill_rule != clip_path_b->fill_rule)
+ return FALSE;
+
+ if (clip_path_a->tolerance != clip_path_b->tolerance)
+ return FALSE;
+
+ if (clip_path_a->antialias != clip_path_b->antialias)
+ return FALSE;
+
+ if (! _cairo_path_fixed_equal (&clip_path_a->path, &clip_path_b->path))
+ return FALSE;
+
+ clip_path_a = clip_path_a->prev;
+ clip_path_b = clip_path_b->prev;
+ }
+
+ return clip_path_a == clip_path_b; /* ie both NULL */
+}
+
cairo_status_t
_cairo_clip_clip (cairo_clip_t *clip,
const cairo_path_fixed_t *path,
diff --git a/src/cairo-surface-clipper.c b/src/cairo-surface-clipper.c
index d536f0c..9266d3b 100644
--- a/src/cairo-surface-clipper.c
+++ b/src/cairo-surface-clipper.c
@@ -75,11 +75,8 @@ _cairo_surface_clipper_set_clip (cairo_surface_clipper_t *clipper,
if (clip == NULL && clipper->clip.path == NULL)
return CAIRO_STATUS_SUCCESS;
- if (clip != NULL && clip->path == clipper->clip.path)
- return CAIRO_STATUS_SUCCESS;
-
if (clip != NULL && clipper->clip.path != NULL &&
- _cairo_path_fixed_equal (&clip->path->path, &clipper->clip.path->path))
+ _cairo_clip_equal (clip, &clipper->clip))
{
return CAIRO_STATUS_SUCCESS;
}
commit 557016a86a5a4487aeb6ab6392795eb709ee8bb5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Apr 10 15:59:13 2010 +0100
test: Add clip-contexts
This should exercise a bug found by Jeff Muizelaar that
cairo-surface-clipper was mistakenly thinking that clip operations on a
second context was a no-op as the topmost clip path matched that of the
previous context.
diff --git a/test/Makefile.am b/test/Makefile.am
index e7143a9..2b3205b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -168,6 +168,7 @@ REFERENCE_IMAGES = \
clear.svg12.rgb24.xfail.png \
clear-source.ref.png \
clip-all.ref.png \
+ clip-contexts.ref.png \
clip-device-offset.argb32.ref.png \
clip-device-offset.rgb24.ref.png \
clip-disjoint.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 860e05f..65e8186 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -17,6 +17,7 @@ test_sources = \
clear.c \
clear-source.c \
clip-all.c \
+ clip-contexts.c \
clip-disjoint.c \
clip-device-offset.c \
clip-empty.c \
diff --git a/test/clip-contexts.c b/test/clip-contexts.c
new file mode 100644
index 0000000..8f767e1
--- /dev/null
+++ b/test/clip-contexts.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Intel Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Intel Corporation makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * INTEL CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+/*
+ * Jeff Muizelaar found a bug on Quartz with cairo-surface-clipper, which was
+ * the topmost clip path from two different contexts and finding them equally
+ * incorrectly concluding that the operation was a no-op.
+ */
+
+#define SIZE 10
+#define CLIP_SIZE 2
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_t *cr2;
+
+ /* opaque background */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+
+ /* first create an empty, non-overlappiny clip */
+ cr2 = cairo_create (cairo_get_target (cr));
+ cairo_rectangle (cr2, 0, 0, SIZE/2-2, SIZE/2-2);
+ cairo_clip (cr2);
+
+ cairo_rectangle (cr2, SIZE/2+2, SIZE/2+2, SIZE/2-2, SIZE/2-2);
+ cairo_clip (cr2);
+
+ /* and apply the clip onto the surface, empty nothing should be painted */
+ cairo_set_source_rgba (cr2, 1, 0, 0, .5);
+ cairo_paint (cr2);
+
+ /* switch back to the original, and set only the last clip */
+ cairo_rectangle (cr, SIZE/2+2, SIZE/2+2, SIZE/2-2, SIZE/2-2);
+ cairo_clip (cr);
+
+ cairo_set_source_rgba (cr, 0, 0, 1, .5);
+ cairo_paint (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (clip_contexts,
+ "Test clipping with 2 separate contexts",
+ "clip", /* keywords */
+ NULL, /* requirements */
+ SIZE, SIZE,
+ NULL, draw)
diff --git a/test/clip-contexts.ref.png b/test/clip-contexts.ref.png
new file mode 100644
index 0000000..0d575a6
Binary files /dev/null and b/test/clip-contexts.ref.png differ
commit a9f506493371ac91494488e5ca38e57ceb5a10cb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Apr 7 22:44:02 2010 +0100
script: Another RGB16_565 warning.
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index a9f6be5..67366ad 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -1065,6 +1065,12 @@ _write_image_surface (cairo_output_stream_t *output,
data += stride;
}
break;
+ case CAIRO_FORMAT_RGB16_565:
+ for (row = image->height; row--; ) {
+ _cairo_output_stream_write (output, data, 2*width);
+ data += stride;
+ }
+ break;
case CAIRO_FORMAT_RGB24:
for (row = image->height; row--; ) {
int col;
More information about the cairo-commit
mailing list