[cairo-commit] 3 commits - test/create-from-png.c test/Makefile.refs test/Makefile.sources test/reference test/subsurface-scale.c
Chris Wilson
ickle at kemper.freedesktop.org
Fri Sep 23 05:39:19 PDT 2011
test/Makefile.refs | 3
test/Makefile.sources | 1
test/create-from-png.c | 29 +++-----
test/reference/subsurface-scale.base.ref.png |binary
test/reference/subsurface-scale.ref.png |binary
test/reference/text-pattern.ref.png |binary
test/subsurface-scale.c | 93 +++++++++++++++++++++++++++
7 files changed, 109 insertions(+), 17 deletions(-)
New commits:
commit 2c34f028a787a7e33e3410f09d6cc00caacf0a08
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Sep 23 13:37:51 2011 +0100
test: Exercise scaling from an atlas through a subsurface
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/test/Makefile.refs b/test/Makefile.refs
index 1abb533..3a40b47 100644
--- a/test/Makefile.refs
+++ b/test/Makefile.refs
@@ -2533,6 +2533,8 @@ REFERENCE_IMAGES = \
reference/subsurface-repeat.ref.png \
reference/subsurface-repeat.traps.argb32.ref.png \
reference/subsurface-repeat.traps.rgb24.ref.png \
+ reference/subsurface-scale.base.ref.png \
+ reference/subsurface-scale.ref.png \
reference/subsurface-similar-repeat.base.argb32.ref.png \
reference/subsurface-similar-repeat.base.rgb24.ref.png \
reference/subsurface-similar-repeat.ref.png \
@@ -2665,7 +2667,6 @@ REFERENCE_IMAGES = \
reference/text-pattern.quartz.argb32.ref.png \
reference/text-pattern.quartz.rgb24.ref.png \
reference/text-pattern.ref.png \
- reference/text-pattern.rgb24.ref.png \
reference/text-pattern.svg.argb32.ref.png \
reference/text-pattern.svg.rgb24.ref.png \
reference/text-pattern.traps.argb32.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index b7d2165..f9aa66c 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -300,6 +300,7 @@ test_sources = \
subsurface-modify-child.c \
subsurface-modify-parent.c \
subsurface-outside-target.c \
+ subsurface-scale.c \
subsurface-similar-repeat.c \
surface-finish-twice.c \
surface-pattern.c \
diff --git a/test/reference/subsurface-scale.base.ref.png b/test/reference/subsurface-scale.base.ref.png
new file mode 100644
index 0000000..41ff4f4
Binary files /dev/null and b/test/reference/subsurface-scale.base.ref.png differ
diff --git a/test/reference/subsurface-scale.ref.png b/test/reference/subsurface-scale.ref.png
new file mode 100644
index 0000000..41ff4f4
Binary files /dev/null and b/test/reference/subsurface-scale.ref.png differ
diff --git a/test/subsurface-scale.c b/test/subsurface-scale.c
new file mode 100644
index 0000000..d5e2d95
--- /dev/null
+++ b/test/subsurface-scale.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2009 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 not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Intel 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"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *region[5];
+ const char *text = "Cairo";
+ int i;
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_rectangle (cr, 0, 20, 200, 60);
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_fill (cr);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ for (i = 0; i < 5; i++) {
+ cairo_t *cr_region;
+ cairo_text_extents_t extents;
+ char buf[2] = { text[i], '\0' };
+
+ region[i] = cairo_surface_create_for_rectangle (cairo_get_target (cr),
+ 20 * i, 0, 20, 20);
+
+ cr_region = cairo_create (region[i]);
+ cairo_surface_destroy (region[i]);
+
+ cairo_select_font_face (cr_region, "@cairo:",
+ CAIRO_FONT_WEIGHT_NORMAL,
+ CAIRO_FONT_SLANT_NORMAL);
+ cairo_set_font_size (cr_region, 20);
+ cairo_text_extents (cr_region, buf, &extents);
+ cairo_move_to (cr_region,
+ 10 - (extents.width/2 + extents.x_bearing),
+ 10 - (extents.height/2 + extents.y_bearing));
+ cairo_show_text (cr_region, buf);
+
+ region[i] = cairo_surface_reference (cairo_get_target (cr_region));
+ cairo_destroy (cr_region);
+ }
+
+ cairo_scale (cr, 2, 2);
+ for (i = 0; i < 5; i++) {
+ cairo_set_source_surface (cr, region[5-i-1], 20 * i, 20);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
+ cairo_rectangle (cr, 20*i, 20, 20, 20);
+ cairo_fill (cr);
+ }
+
+ for (i = 0; i < 5; i++) {
+ cairo_set_source_surface (cr, region[5-i-1], 20 * i, 40);
+ cairo_paint_with_alpha (cr, .5);
+ }
+
+ for (i = 0; i < 5; i++)
+ cairo_surface_destroy (region[i]);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (subsurface_scale,
+ "Tests clipping of both source and destination using subsurfaces",
+ "subsurface", /* keywords */
+ NULL, /* requirements */
+ 200, 120,
+ NULL, draw)
commit 9b3b84976ac255a5d1ce472ff4bcb623e34d5fc3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Sep 23 13:20:32 2011 +0100
test: refresh text-pattern reference
diff --git a/test/reference/text-pattern.ref.png b/test/reference/text-pattern.ref.png
index df438a5..578cc62 100644
Binary files a/test/reference/text-pattern.ref.png and b/test/reference/text-pattern.ref.png differ
commit 7e5e2dd5e184c73264dd2359ca151cc0689c63d6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Sep 23 13:20:14 2011 +0100
test/create-from-png: Update to point to new reference/ images
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/test/create-from-png.c b/test/create-from-png.c
index 585fac2..0112faf 100644
--- a/test/create-from-png.c
+++ b/test/create-from-png.c
@@ -49,8 +49,8 @@ draw (cairo_t *cr, int width, int height)
char *filename;
cairo_surface_t *surface;
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.ref.png");
+ xasprintf (&filename, "%s/reference/%s",
+ ctx->srcdir, "create-from-png.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
@@ -82,6 +82,7 @@ static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
char *filename;
+ char *path;
cairo_surface_t *surface;
cairo_status_t status;
cairo_test_status_t result = CAIRO_TEST_SUCCESS;
@@ -126,8 +127,8 @@ preamble (cairo_test_context_t *ctx)
return result;
/* cheekily test error propagation from the user write funcs as well ... */
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.ref.png");
+ xasprintf (&path, "%s/reference", ctx->srcdir);
+ xasprintf (&filename, "%s/%s", path, "create-from-png.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
@@ -177,8 +178,7 @@ preamble (cairo_test_context_t *ctx)
return result;
/* check that loading alpha/opaque PNGs generate the correct surfaces */
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.alpha.ref.png");
+ xasprintf (&filename, "%s/%s", path, "create-from-png.alpha.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
@@ -198,8 +198,7 @@ preamble (cairo_test_context_t *ctx)
if (result != CAIRO_TEST_SUCCESS)
return result;
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.ref.png");
+ xasprintf (&filename, "%s/%s", path, "create-from-png.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
@@ -220,8 +219,7 @@ preamble (cairo_test_context_t *ctx)
return result;
/* check paletted PNGs */
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.indexed-alpha.ref.png");
+ xasprintf (&filename, "%s/%s", path, "create-from-png.indexed-alpha.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
@@ -241,8 +239,7 @@ preamble (cairo_test_context_t *ctx)
if (result != CAIRO_TEST_SUCCESS)
return result;
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.indexed.ref.png");
+ xasprintf (&filename, "%s/%s", path, "create-from-png.indexed.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
@@ -263,8 +260,7 @@ preamble (cairo_test_context_t *ctx)
return result;
/* check grayscale PNGs */
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.gray-alpha.ref.png");
+ xasprintf (&filename, "%s/%s", path, "create-from-png.gray-alpha.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
@@ -284,8 +280,7 @@ preamble (cairo_test_context_t *ctx)
if (result != CAIRO_TEST_SUCCESS)
return result;
- xasprintf (&filename, "%s/%s", ctx->srcdir,
- "create-from-png.gray.ref.png");
+ xasprintf (&filename, "%s/%s", path, "create-from-png.gray.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
@@ -303,6 +298,8 @@ preamble (cairo_test_context_t *ctx)
free (filename);
cairo_surface_destroy (surface);
+ free (path);
+
return result;
}
More information about the cairo-commit
mailing list