[cairo-commit] test/.gitignore test/Makefile.am test/rgb24-ignore-alpha.c test/rgb24-ignore-alpha-ref.png

Carl Worth cworth at kemper.freedesktop.org
Wed Sep 5 14:45:56 PDT 2007


 test/.gitignore                 |    1 
 test/Makefile.am                |    1 
 test/rgb24-ignore-alpha-ref.png |binary
 test/rgb24-ignore-alpha.c       |   65 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+)

New commits:
diff-tree 0682b9a9c18640c284c7cc8ba8792a329414998e (from 84a2c8968a57ed7593db1515718115218072bc0d)
Author: Carl Worth <cworth at cworth.org>
Date:   Tue Sep 4 16:47:49 2007 -0700

    Add rgb24-ignore-alpha test
    
    This test demonstrates a bug when compositing an rgb24 image over an argb32
    image, (the implementation appears to be examining the alpha channel
    rather than ignoring it).

diff --git a/test/.gitignore b/test/.gitignore
index 4758b3d..6553274 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -106,6 +106,7 @@ ps-features.ps
 push-group
 radial-gradient
 random-intersections
+rgb24-ignore-alpha
 svg2png
 svg-clip
 svg-clip.svg
diff --git a/test/Makefile.am b/test/Makefile.am
index e5474a2..ee789d8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -81,6 +81,7 @@ radial-gradient			\
 random-intersections		\
 rectangle-rounding-error	\
 rectilinear-stroke		\
+rgb24-ignore-alpha		\
 rotate-image-surface-paint	\
 scale-down-source-surface-paint	\
 scale-source-surface-paint	\
diff --git a/test/rgb24-ignore-alpha-ref.png b/test/rgb24-ignore-alpha-ref.png
new file mode 100644
index 0000000..ab1d8fa
Binary files /dev/null and b/test/rgb24-ignore-alpha-ref.png differ
diff --git a/test/rgb24-ignore-alpha.c b/test/rgb24-ignore-alpha.c
new file mode 100644
index 0000000..bb5ec35
--- /dev/null
+++ b/test/rgb24-ignore-alpha.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+#define WIDTH  2
+#define HEIGHT 2
+
+cairo_test_t test = {
+    "rgb24-ignore-alpha",
+    "Test that when using an RGB24 image as a source, there is no alpha channel",
+    WIDTH, HEIGHT,
+    draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *surface;
+    /* Four green pixels with different "alpha" values, (but which
+     * should be entirely ignored). */
+    uint32_t colors[4] = {
+	0xff00ff00, 0x8800ff00,
+	0x4400ff00, 0x0000ff00
+    };
+
+    surface = cairo_image_surface_create_for_data ((unsigned char *) colors,
+						   CAIRO_FORMAT_RGB24, 2, 2, 8);
+
+    cairo_set_source_surface (cr, surface, 0, 0);
+    cairo_paint (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+    return cairo_test (&test);
+}


More information about the cairo-commit mailing list