[cairo-commit] src/cairo-xcb-surface.c test/Makefile.am test/Makefile.sources test/operator-alpha-alpha.c test/operator-alpha-alpha.pdf.xfail.png test/operator-alpha-alpha.ps.xfail.png test/operator-alpha-alpha.ref.png test/operator-alpha-alpha.svg.xfail.png

Chris Wilson ickle at kemper.freedesktop.org
Mon Nov 9 08:59:57 PST 2009


 src/cairo-xcb-surface.c                 |    4 
 test/Makefile.am                        |    4 
 test/Makefile.sources                   |    1 
 test/operator-alpha-alpha.c             |  166 ++++++++++++++++++++++++++++++++
 test/operator-alpha-alpha.pdf.xfail.png |binary
 test/operator-alpha-alpha.ps.xfail.png  |binary
 test/operator-alpha-alpha.ref.png       |binary
 test/operator-alpha-alpha.svg.xfail.png |binary
 8 files changed, 171 insertions(+), 4 deletions(-)

New commits:
commit c181f9e9aeac375eed07aaab58d177e3476d5117
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Nov 7 19:29:30 2009 +0100

    Add new operator-alpha-alpha test
    
    Compositing of alpha-only sources is not throughly tested and
    as a consequence the misbehaviour of some backends is not
    shown by the test suite.
    
    [ickle: Added XFAILs for pdf, ps, svg.]

diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 1e47c98..8cd82f0 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1308,7 +1308,6 @@ _cairo_xcb_surface_composite (cairo_operator_t		op,
 
     status = _cairo_pattern_acquire_surfaces (src_pattern, mask_pattern,
 					      &dst->base,
-					      CAIRO_CONTENT_COLOR_ALPHA,
 					      src_x, src_y,
 					      mask_x, mask_y,
 					      width, height,
@@ -1673,7 +1672,6 @@ _cairo_xcb_surface_composite_trapezoids (cairo_operator_t	op,
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     status = _cairo_pattern_acquire_surface (pattern, &dst->base,
-					     CAIRO_CONTENT_COLOR_ALPHA,
 					     src_x, src_y, width, height,
 					     CAIRO_PATTERN_ACQUIRE_NO_REFLECT,
 					     (cairo_surface_t **) &src,
@@ -2766,7 +2764,6 @@ _cairo_xcb_surface_show_glyphs (void			*abstract_dst,
 
     if (src_pattern->type == CAIRO_PATTERN_TYPE_SOLID) {
         status = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
-						 CAIRO_CONTENT_COLOR_ALPHA,
                                                  0, 0, 1, 1,
 						 CAIRO_PATTERN_ACQUIRE_NONE,
                                                  (cairo_surface_t **) &src,
@@ -2783,7 +2780,6 @@ _cairo_xcb_surface_show_glyphs (void			*abstract_dst,
 	    goto BAIL;
 
         status = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
-						 CAIRO_CONTENT_COLOR_ALPHA,
                                                  glyph_extents.x, glyph_extents.y,
                                                  glyph_extents.width, glyph_extents.height,
 						 CAIRO_PATTERN_ACQUIRE_NO_REFLECT,
diff --git a/test/Makefile.am b/test/Makefile.am
index 8bbce94..af91f71 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -671,6 +671,10 @@ REFERENCE_IMAGES = \
 	operator-alpha.rgb24.ref.png \
 	operator-alpha.svg12.argb32.xfail.png \
 	operator-alpha.svg12.rgb24.xfail.png \
+	operator-alpha-alpha.ref.png \
+	operator-alpha-alpha.pdf.xfail.png \
+	operator-alpha-alpha.ps.xfail.png \
+	operator-alpha-alpha.svg.xfail.png \
 	operator-clear.ps2.argb32.ref.png \
 	operator-clear.ps3.argb32.ref.png \
 	operator-clear.quartz.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 82c761b..7c05dca 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -139,6 +139,7 @@ test_sources = \
 	nil-surface.c					\
 	operator.c					\
 	operator-alpha.c				\
+	operator-alpha-alpha.c				\
 	operator-clear.c				\
 	operator-source.c				\
 	over-above-source.c				\
diff --git a/test/operator-alpha-alpha.c b/test/operator-alpha-alpha.c
new file mode 100644
index 0000000..1522890
--- /dev/null
+++ b/test/operator-alpha-alpha.c
@@ -0,0 +1,166 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright 2002 University of Southern California
+ * Copyright 2005 Red Hat, Inc.
+ * Copyright 2007 Emmanuel Pacaud
+ * Copyright 2008 Benjamin Otte
+ * Copyright 2008 Chris Wilson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *      Owen Taylor <otaylor at redhat.com>
+ *      Kristian Høgsberg <krh at redhat.com>
+ *      Emmanuel Pacaud <emmanuel.pacaud at lapp.in2p3.fr>
+ *      Chris Wilson <chris at chris-wilson.co.uk>
+ *      Andrea Canciani <ranma42 at gmail.com>
+ */
+
+#include "cairo-test.h"
+
+#define STEPS 16
+#define START_OPERATOR	CAIRO_OPERATOR_CLEAR
+#define STOP_OPERATOR	CAIRO_OPERATOR_HSL_LUMINOSITY
+
+#define SIZE 3
+#define COUNT 6
+#define FULL_WIDTH  ((STEPS + 1) * COUNT - 1)
+#define FULL_HEIGHT ((COUNT + STOP_OPERATOR - START_OPERATOR) / COUNT) * (STEPS + 1)
+
+static void
+create_patterns (cairo_t *bg, cairo_t *fg)
+{
+    int x;
+
+    for (x = 0; x < STEPS; x++) {
+	double i = (double) x / (STEPS - 1);
+	cairo_set_source_rgba (bg, 0, 0, 0, i);
+	cairo_rectangle (bg, x, 0, 1, STEPS);
+	cairo_fill (bg);
+
+	cairo_set_source_rgba (fg, 0, 0, 0, i);
+	cairo_rectangle (fg, 0, x, STEPS, 1);
+	cairo_fill (fg);
+    }
+}
+
+/* expects a STEP*STEP pixel rectangle */
+static void
+do_composite (cairo_t *cr, cairo_operator_t op, cairo_surface_t *bg, cairo_surface_t *fg)
+{
+    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+    cairo_set_source_surface (cr, bg, 0, 0);
+    cairo_paint (cr);
+
+    cairo_set_operator (cr, op);
+    cairo_set_source_surface (cr, fg, 0, 0);
+    cairo_paint (cr);
+}
+
+static void
+subdraw (cairo_t *cr, int width, int height)
+{
+    size_t i = 0;
+    cairo_operator_t op;
+    cairo_t *bgcr, *fgcr;
+    cairo_surface_t *bg, *fg;
+
+    bg = cairo_surface_create_similar (cairo_get_target (cr),
+	    CAIRO_CONTENT_COLOR_ALPHA, SIZE * STEPS, SIZE * STEPS);
+    fg = cairo_surface_create_similar (cairo_get_target (cr),
+	    CAIRO_CONTENT_COLOR_ALPHA, SIZE * STEPS, SIZE * STEPS);
+    bgcr = cairo_create (bg);
+    fgcr = cairo_create (fg);
+    cairo_scale (bgcr, SIZE, SIZE);
+    cairo_scale (fgcr, SIZE, SIZE);
+    create_patterns (bgcr, fgcr);
+    cairo_destroy (bgcr);
+    cairo_destroy (fgcr);
+
+    for (op = START_OPERATOR; op <= STOP_OPERATOR; op++, i++) {
+	cairo_save (cr);
+	cairo_translate (cr,
+		SIZE * (STEPS + 1) * (i % COUNT),
+		SIZE * (STEPS + 1) * (i / COUNT));
+	cairo_rectangle (cr, 0, 0, SIZE * (STEPS + 1), SIZE * (STEPS+1));
+	cairo_clip (cr);
+	do_composite (cr, op, bg, fg);
+	cairo_restore (cr);
+    }
+
+    cairo_surface_destroy (fg);
+    cairo_surface_destroy (bg);
+}
+
+
+static cairo_surface_t *
+create_source (cairo_surface_t *target, int width, int height)
+{
+    cairo_surface_t *similar;
+    cairo_t *cr;
+
+    similar = cairo_surface_create_similar (target,
+					    CAIRO_CONTENT_ALPHA,
+					    width, height);
+    cr = cairo_create (similar);
+    cairo_surface_destroy (similar);
+
+    subdraw (cr, width, height);
+
+    similar = cairo_surface_reference (cairo_get_target (cr));
+    cairo_destroy (cr);
+
+    return similar;
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *source;
+
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    source = create_source (cairo_get_target (cr), width, height);
+    cairo_set_source_surface (cr, source, 0, 0);
+    cairo_surface_destroy (source);
+
+    cairo_paint (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (operator_alpha_alpha,
+	    "Tests result of compositing pure-alpha surfaces"
+	    "\nCompositing of pure-alpha sources is inconsistent across backends.",
+	    "alpha, similar, operator", /* keywords */
+	    NULL, /* requirements */
+	    FULL_WIDTH * SIZE, FULL_HEIGHT * SIZE,
+	    NULL, draw)
diff --git a/test/operator-alpha-alpha.pdf.xfail.png b/test/operator-alpha-alpha.pdf.xfail.png
new file mode 100644
index 0000000..0a06685
Binary files /dev/null and b/test/operator-alpha-alpha.pdf.xfail.png differ
diff --git a/test/operator-alpha-alpha.ps.xfail.png b/test/operator-alpha-alpha.ps.xfail.png
new file mode 100644
index 0000000..843c948
Binary files /dev/null and b/test/operator-alpha-alpha.ps.xfail.png differ
diff --git a/test/operator-alpha-alpha.ref.png b/test/operator-alpha-alpha.ref.png
new file mode 100644
index 0000000..695d0d0
Binary files /dev/null and b/test/operator-alpha-alpha.ref.png differ
diff --git a/test/operator-alpha-alpha.svg.xfail.png b/test/operator-alpha-alpha.svg.xfail.png
new file mode 100644
index 0000000..c7dc8cb
Binary files /dev/null and b/test/operator-alpha-alpha.svg.xfail.png differ


More information about the cairo-commit mailing list