[cairo-commit] 5 commits - pixman/src test/.gitignore
test/Makefile.am test/source-clip.c test/source-clip-ref.png
test/source-clip-scale.c test/source-clip-scale-ref.png
test/source-clip-scale-svg-ref.png
Carl Worth
cworth at kemper.freedesktop.org
Thu Aug 17 13:36:16 PDT 2006
pixman/src/fbcompose.c | 38 +++++++--------
test/.gitignore | 1
test/Makefile.am | 2
test/source-clip-ref.png |binary
test/source-clip-scale-ref.png |binary
test/source-clip-scale-svg-ref.png |binary
test/source-clip-scale.c | 90 +++++++++++++++++++++++++++++++++++++
test/source-clip.c | 38 +++++++--------
8 files changed, 130 insertions(+), 39 deletions(-)
New commits:
diff-tree ccf60202d32aa6ade83231e7255ca20e38f216be (from 72e25648c4c4bc82ddd938aa4e05887a293f0d8b)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Aug 17 13:34:26 2006 -0700
Add SVG-specific reference image for source-clip-scale test
The difference here is that the SVG backend uses a meta-surface for
its similar surface, so there are no rasterization/filtering
artefacts when scaling the source surface.
diff --git a/test/source-clip-scale-svg-ref.png b/test/source-clip-scale-svg-ref.png
new file mode 100644
index 0000000..87c2917
Binary files /dev/null and b/test/source-clip-scale-svg-ref.png differ
diff-tree 72e25648c4c4bc82ddd938aa4e05887a293f0d8b (from 64d2feb9f62d32f8189ea6a43420782e0c4a9373)
Author: Vladimir Vukicevic <vladimirv at gmail.com>
Date: Thu Aug 17 13:28:58 2006 -0700
pixman: Use pSourceClip rather than pCompositeClip when fetching
This fixes the source-clip-scale test failures for most backends.
diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 67ac83d..4958241 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -3092,8 +3092,8 @@ static void fbFetchTransformed(PicturePt
if (pict->filter == PIXMAN_FILTER_NEAREST || pict->filter == PIXMAN_FILTER_FAST)
{
if (pict->repeat == RepeatNormal) {
- if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- box = pict->pCompositeClip->extents;
+ if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
+ box = pict->pSourceClip->extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3128,7 +3128,7 @@ static void fbFetchTransformed(PicturePt
y = MOD(v.vector[1]>>16, pict->pDrawable->height);
x = MOD(v.vector[0]>>16, pict->pDrawable->width);
}
- if (pixman_region_contains_point (pict->pCompositeClip, x, y, &box))
+ if (pixman_region_contains_point (pict->pSourceClip, x, y, &box))
buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
else
buffer[i] = 0;
@@ -3140,8 +3140,8 @@ static void fbFetchTransformed(PicturePt
}
}
} else {
- if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- box = pict->pCompositeClip->extents;
+ if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
+ box = pict->pSourceClip->extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3175,7 +3175,7 @@ static void fbFetchTransformed(PicturePt
y = v.vector[1]>>16;
x = v.vector[0]>>16;
}
- if (pixman_region_contains_point (pict->pCompositeClip, x, y, &box))
+ if (pixman_region_contains_point (pict->pSourceClip, x, y, &box))
buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
else
buffer[i] = 0;
@@ -3194,8 +3194,8 @@ static void fbFetchTransformed(PicturePt
unit.vector[1] -= unit.vector[2]/2;
if (pict->repeat == RepeatNormal) {
- if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- box = pict->pCompositeClip->extents;
+ if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
+ box = pict->pSourceClip->extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3298,14 +3298,14 @@ static void fbFetchTransformed(PicturePt
b = bits + (y1 + pict->pDrawable->y)*stride;
- tl = pixman_region_contains_point(pict->pCompositeClip, x1, y1, &box)
+ tl = pixman_region_contains_point(pict->pSourceClip, x1, y1, &box)
? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
- tr = pixman_region_contains_point(pict->pCompositeClip, x2, y1, &box)
+ tr = pixman_region_contains_point(pict->pSourceClip, x2, y1, &box)
? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
b = bits + (y2 + pict->pDrawable->y)*stride;
- bl = pixman_region_contains_point(pict->pCompositeClip, x1, y2, &box)
+ bl = pixman_region_contains_point(pict->pSourceClip, x1, y2, &box)
? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
- br = pixman_region_contains_point(pict->pCompositeClip, x2, y2, &box)
+ br = pixman_region_contains_point(pict->pSourceClip, x2, y2, &box)
? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
@@ -3329,8 +3329,8 @@ static void fbFetchTransformed(PicturePt
}
}
} else {
- if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- box = pict->pCompositeClip->extents;
+ if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
+ box = pict->pSourceClip->extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3431,14 +3431,14 @@ static void fbFetchTransformed(PicturePt
b = bits + (y1 + pict->pDrawable->y)*stride;
x_off = x1 + pict->pDrawable->x;
- tl = pixman_region_contains_point(pict->pCompositeClip, x1, y1, &box)
+ tl = pixman_region_contains_point(pict->pSourceClip, x1, y1, &box)
? fetch(b, x_off, indexed) : 0;
- tr = pixman_region_contains_point(pict->pCompositeClip, x2, y1, &box)
+ tr = pixman_region_contains_point(pict->pSourceClip, x2, y1, &box)
? fetch(b, x_off + 1, indexed) : 0;
b += stride;
- bl = pixman_region_contains_point(pict->pCompositeClip, x1, y2, &box)
+ bl = pixman_region_contains_point(pict->pSourceClip, x1, y2, &box)
? fetch(b, x_off, indexed) : 0;
- br = pixman_region_contains_point(pict->pCompositeClip, x2, y2, &box)
+ br = pixman_region_contains_point(pict->pSourceClip, x2, y2, &box)
? fetch(b, x_off + 1, indexed) : 0;
ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
@@ -3500,7 +3500,7 @@ static void fbFetchTransformed(PicturePt
for (x = x1; x < x2; x++) {
if (*p) {
int tx = (pict->repeat == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
- if (pixman_region_contains_point (pict->pCompositeClip, tx, ty, &box)) {
+ if (pixman_region_contains_point (pict->pSourceClip, tx, ty, &box)) {
FbBits *b = bits + (ty + pict->pDrawable->y)*stride;
CARD32 c = fetch(b, tx + pict->pDrawable->x, indexed);
diff-tree 64d2feb9f62d32f8189ea6a43420782e0c4a9373 (from 524507c39f2f495af426a8c41c6311efe3eb633f)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Aug 17 10:37:46 2006 -0700
Harmonize implementations of source-clip and source-clip-scale to make similarities more evident.
diff --git a/test/.gitignore b/test/.gitignore
index 51ed65c..40332f9 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -102,6 +102,7 @@ set-source
show-glyphs-many
show-text-current-point
source-clip
+source-clip-scale
source-surface-scale-paint
surface-finish-twice
surface-pattern
diff --git a/test/source-clip-ref.png b/test/source-clip-ref.png
index 8df2bff..22454be 100644
Binary files a/test/source-clip-ref.png and b/test/source-clip-ref.png differ
diff --git a/test/source-clip-scale-ref.png b/test/source-clip-scale-ref.png
index 972f41d..1519ff8 100644
Binary files a/test/source-clip-scale-ref.png and b/test/source-clip-scale-ref.png differ
diff --git a/test/source-clip-scale.c b/test/source-clip-scale.c
index a785710..cc24969 100644
--- a/test/source-clip-scale.c
+++ b/test/source-clip-scale.c
@@ -27,13 +27,13 @@
#include "cairo-test.h"
#include <stdio.h>
-#define SIZE 40
+#define SIZE 12
static cairo_test_draw_function_t draw;
cairo_test_t test = {
"source-clip-scale",
- "Test a leftover clip on a source surface not affecting compositing",
+ "Test that a source surface is not affected by a clip when scaling",
SIZE * 2, SIZE,
draw
};
@@ -41,54 +41,44 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- cairo_surface_t *surf2;
+ cairo_surface_t *source;
cairo_t *cr2;
- /* cr: Fill the destination with our red background that should
- * get covered
- */
- cairo_set_source_rgb (cr, 1, 0, 0);
- cairo_paint (cr);
-
- surf2 = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, SIZE, SIZE);
- cr2 = cairo_create (surf2);
+ source = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ SIZE, SIZE);
+ cr2 = cairo_create (source);
- /* cr2: Fill temp surface with green */
+ /* Fill the source surface with green */
cairo_set_source_rgb (cr2, 0, 1, 0);
cairo_paint (cr2);
- /* cr2: Make a blue square in the middle */
- cairo_set_source_rgb (cr2, 0, 0, 2);
+ /* Draw a blue square in the middle of the source with clipping.
+ * Note that we are only clipping within a save/restore block but
+ * the buggy behavior demonstrates that the clip remains present
+ * on the surface. */
cairo_save (cr2);
- cairo_new_path (cr2);
- cairo_rectangle (cr2, 10, 10, SIZE-20, SIZE-20);
+ cairo_rectangle (cr2,
+ SIZE / 4, SIZE / 4,
+ SIZE / 2, SIZE / 2);
cairo_clip (cr2);
+ cairo_set_source_rgb (cr2, 0, 0, 1);
cairo_paint (cr2);
cairo_restore (cr2);
- /* If this is uncommented, the test works as expected, because this
- * forces the clip to be reset on surf2.
- */
- /*
- cairo_new_path (cr2);
- cairo_rectangle (cr2, 0, 0, 0, 0);
- cairo_fill (cr2);
- */
-
- /* If this scale is commented out, the test displays
- * the green-and-blue square on the left side of the result.
- *
- * The correct "pass" image is the green-and-blue square image stretched
- * by 2x. With this scale, however, only the blue (clipped) portion
- * of the src shows through.
- */
+ /* Fill the destination surface with solid red (should not appear
+ * in final result) */
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_paint (cr);
+
+ /* Now draw the source surface onto the destination with scaling. */
cairo_scale (cr, 2.0, 1.0);
- cairo_set_source_surface (cr, surf2, 0, 0);
+ cairo_set_source_surface (cr, source, 0, 0);
cairo_paint (cr);
cairo_destroy (cr2);
- cairo_surface_destroy (surf2);
+ cairo_surface_destroy (source);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/source-clip.c b/test/source-clip.c
index 4243bf0..cb9386a 100644
--- a/test/source-clip.c
+++ b/test/source-clip.c
@@ -27,13 +27,13 @@
#include "cairo-test.h"
#include <stdio.h>
-#define SIZE 50
+#define SIZE 12
static cairo_test_draw_function_t draw;
cairo_test_t test = {
"source-clip",
- "Test using a surface with an active clip as a source",
+ "Test that a source surface is not affected by a clip",
SIZE, SIZE,
draw
};
@@ -41,43 +41,41 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- cairo_pattern_t *pattern;
- cairo_surface_t *source_surface;
+ cairo_surface_t *source;
cairo_t *cr2;
- source_surface = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR_ALPHA,
- SIZE, SIZE);
+ source = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ SIZE, SIZE);
- cr2 = cairo_create (source_surface);
+ cr2 = cairo_create (source);
- /* Fill the source surface with solid black */
- cairo_set_source_rgb (cr2, 0, 0, 0);
+ /* Fill the source surface with green */
+ cairo_set_source_rgb (cr2, 0, 1, 0);
cairo_paint (cr2);
- /* Now leave a clip in place */
+ /* Draw a blue square in the middle of the source with clipping,
+ * and leave the clip there. */
cairo_rectangle (cr2,
SIZE / 4, SIZE / 4,
SIZE / 2, SIZE / 2);
cairo_clip (cr2);
+ cairo_set_source_rgb (cr2, 0, 0, 1);
+ cairo_paint (cr2);
- /* Fill the destination surface with solid white */
- cairo_set_source_rgb (cr, 1, 1, 1);
+ /* Fill the destination surface with solid red (should not appear
+ * in final result) */
+ cairo_set_source_rgb (cr, 1, 0, 0);
cairo_paint (cr);
/* Now draw the source surface onto the destination surface */
- pattern = cairo_pattern_create_for_surface (source_surface);
- cairo_set_source (cr, pattern);
+ cairo_set_source_surface (cr, source, 0, 0);
cairo_paint (cr);
- /* As the clip shouldn't matter, the result should be solid black */
-
cairo_destroy (cr2);
- cairo_pattern_destroy (pattern);
- cairo_surface_destroy (source_surface);
+ cairo_surface_destroy (source);
return CAIRO_TEST_SUCCESS;
-
}
int
diff-tree 524507c39f2f495af426a8c41c6311efe3eb633f (from afb50580ce0eaefe466ff63a2e0e597f35317f6b)
Author: Carl Worth <cworth at cworth.org>
Date: Wed Aug 16 16:18:18 2006 -0700
Rename src-clip test to source-clip-scale
diff --git a/test/Makefile.am b/test/Makefile.am
index 5b9e20c..068319d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -65,8 +65,8 @@ self-intersecting \
set-source \
show-text-current-point \
source-clip \
+source-clip-scale \
source-surface-scale-paint \
-src-clip \
surface-finish-twice \
surface-pattern \
text-antialias-gray \
@@ -302,6 +302,7 @@ show-text-current-point-ref.png \
show-text-current-point-ps-argb32-ref.png \
show-text-current-point-svg-ref.png \
source-clip-ref.png \
+source-clip-scale-ref.png \
source-surface-scale-paint-ref.png \
source-surface-scale-paint-rgb24-ref.png \
surface-pattern-ref.png \
diff --git a/test/source-clip-scale-ref.png b/test/source-clip-scale-ref.png
new file mode 100644
index 0000000..972f41d
Binary files /dev/null and b/test/source-clip-scale-ref.png differ
diff --git a/test/source-clip-scale.c b/test/source-clip-scale.c
new file mode 100644
index 0000000..a785710
--- /dev/null
+++ b/test/source-clip-scale.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright © 2005 Mozilla 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
+ * Mozilla Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Mozilla Corporation makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL MOZILLA 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: Vladimir Vukicevic <vladimir at pobox.com>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 40
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "source-clip-scale",
+ "Test a leftover clip on a source surface not affecting compositing",
+ SIZE * 2, SIZE,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surf2;
+ cairo_t *cr2;
+
+ /* cr: Fill the destination with our red background that should
+ * get covered
+ */
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_paint (cr);
+
+ surf2 = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, SIZE, SIZE);
+ cr2 = cairo_create (surf2);
+
+ /* cr2: Fill temp surface with green */
+ cairo_set_source_rgb (cr2, 0, 1, 0);
+ cairo_paint (cr2);
+
+ /* cr2: Make a blue square in the middle */
+ cairo_set_source_rgb (cr2, 0, 0, 2);
+ cairo_save (cr2);
+ cairo_new_path (cr2);
+ cairo_rectangle (cr2, 10, 10, SIZE-20, SIZE-20);
+ cairo_clip (cr2);
+ cairo_paint (cr2);
+ cairo_restore (cr2);
+
+ /* If this is uncommented, the test works as expected, because this
+ * forces the clip to be reset on surf2.
+ */
+ /*
+ cairo_new_path (cr2);
+ cairo_rectangle (cr2, 0, 0, 0, 0);
+ cairo_fill (cr2);
+ */
+
+ /* If this scale is commented out, the test displays
+ * the green-and-blue square on the left side of the result.
+ *
+ * The correct "pass" image is the green-and-blue square image stretched
+ * by 2x. With this scale, however, only the blue (clipped) portion
+ * of the src shows through.
+ */
+ cairo_scale (cr, 2.0, 1.0);
+
+ cairo_set_source_surface (cr, surf2, 0, 0);
+ cairo_paint (cr);
+
+ cairo_destroy (cr2);
+ cairo_surface_destroy (surf2);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
diff --git a/test/src-clip-ref.png b/test/src-clip-ref.png
deleted file mode 100644
index 972f41d..0000000
Binary files a/test/src-clip-ref.png and /dev/null differ
diff --git a/test/src-clip.c b/test/src-clip.c
deleted file mode 100644
index 7e576c2..0000000
--- a/test/src-clip.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright © 2005 Mozilla 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
- * Mozilla Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Mozilla Corporation makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL MOZILLA 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: Vladimir Vukicevic <vladimir at pobox.com>
- */
-
-#include <math.h>
-#include "cairo-test.h"
-#include <stdio.h>
-
-#define SIZE 40
-
-static cairo_test_draw_function_t draw;
-
-cairo_test_t test = {
- "src-clip",
- "Test a leftover clip on a source surface not affecting compositing",
- SIZE * 2, SIZE,
- draw
-};
-
-static cairo_test_status_t
-draw (cairo_t *cr, int width, int height)
-{
- cairo_surface_t *surf2;
- cairo_t *cr2;
-
- /* cr: Fill the destination with our red background that should
- * get covered
- */
- cairo_set_source_rgb (cr, 1, 0, 0);
- cairo_paint (cr);
-
- surf2 = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, SIZE, SIZE);
- cr2 = cairo_create (surf2);
-
- /* cr2: Fill temp surface with green */
- cairo_set_source_rgb (cr2, 0, 1, 0);
- cairo_paint (cr2);
-
- /* cr2: Make a blue square in the middle */
- cairo_set_source_rgb (cr2, 0, 0, 2);
- cairo_save (cr2);
- cairo_new_path (cr2);
- cairo_rectangle (cr2, 10, 10, SIZE-20, SIZE-20);
- cairo_clip (cr2);
- cairo_paint (cr2);
- cairo_restore (cr2);
-
- /* If this is uncommented, the test works as expected, because this
- * forces the clip to be reset on surf2.
- */
- /*
- cairo_new_path (cr2);
- cairo_rectangle (cr2, 0, 0, 0, 0);
- cairo_fill (cr2);
- */
-
- /* If this scale is commented out, the test displays
- * the green-and-blue square on the left side of the result.
- *
- * The correct "pass" image is the green-and-blue square image stretched
- * by 2x. With this scale, however, only the blue (clipped) portion
- * of the src shows through.
- */
- cairo_scale (cr, 2.0, 1.0);
-
- cairo_set_source_surface (cr, surf2, 0, 0);
- cairo_paint (cr);
-
- cairo_destroy (cr2);
- cairo_surface_destroy (surf2);
-
- return CAIRO_TEST_SUCCESS;
-}
-
-int
-main (void)
-{
- return cairo_test (&test);
-}
diff-tree afb50580ce0eaefe466ff63a2e0e597f35317f6b (from 540db69aefd9874d71af6102c5f9572288de09be)
Author: Vladimir Vukicevic <vladimirv at gmail.com>
Date: Wed Aug 16 16:04:24 2006 -0700
Add src-clip test case to demonstrate bug with clipping applying to a source surface.
diff --git a/test/Makefile.am b/test/Makefile.am
index effa321..5b9e20c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -66,6 +66,7 @@ set-source \
show-text-current-point \
source-clip \
source-surface-scale-paint \
+src-clip \
surface-finish-twice \
surface-pattern \
text-antialias-gray \
diff --git a/test/src-clip-ref.png b/test/src-clip-ref.png
new file mode 100644
index 0000000..972f41d
Binary files /dev/null and b/test/src-clip-ref.png differ
diff --git a/test/src-clip.c b/test/src-clip.c
new file mode 100644
index 0000000..7e576c2
--- /dev/null
+++ b/test/src-clip.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright © 2005 Mozilla 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
+ * Mozilla Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Mozilla Corporation makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL MOZILLA 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: Vladimir Vukicevic <vladimir at pobox.com>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 40
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "src-clip",
+ "Test a leftover clip on a source surface not affecting compositing",
+ SIZE * 2, SIZE,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surf2;
+ cairo_t *cr2;
+
+ /* cr: Fill the destination with our red background that should
+ * get covered
+ */
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_paint (cr);
+
+ surf2 = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, SIZE, SIZE);
+ cr2 = cairo_create (surf2);
+
+ /* cr2: Fill temp surface with green */
+ cairo_set_source_rgb (cr2, 0, 1, 0);
+ cairo_paint (cr2);
+
+ /* cr2: Make a blue square in the middle */
+ cairo_set_source_rgb (cr2, 0, 0, 2);
+ cairo_save (cr2);
+ cairo_new_path (cr2);
+ cairo_rectangle (cr2, 10, 10, SIZE-20, SIZE-20);
+ cairo_clip (cr2);
+ cairo_paint (cr2);
+ cairo_restore (cr2);
+
+ /* If this is uncommented, the test works as expected, because this
+ * forces the clip to be reset on surf2.
+ */
+ /*
+ cairo_new_path (cr2);
+ cairo_rectangle (cr2, 0, 0, 0, 0);
+ cairo_fill (cr2);
+ */
+
+ /* If this scale is commented out, the test displays
+ * the green-and-blue square on the left side of the result.
+ *
+ * The correct "pass" image is the green-and-blue square image stretched
+ * by 2x. With this scale, however, only the blue (clipped) portion
+ * of the src shows through.
+ */
+ cairo_scale (cr, 2.0, 1.0);
+
+ cairo_set_source_surface (cr, surf2, 0, 0);
+ cairo_paint (cr);
+
+ cairo_destroy (cr2);
+ cairo_surface_destroy (surf2);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
More information about the cairo-commit
mailing list