[cairo-commit] test/Makefile.sources test/reference test/text-antialias-subpixel.c

Uli Schlachter psychon at kemper.freedesktop.org
Thu Oct 13 04:43:11 PDT 2011


 test/Makefile.sources                                       |    1 
 test/reference/text-antialias-subpixel-bgr.image16.ref.png  |binary
 test/reference/text-antialias-subpixel-bgr.ref.png          |binary
 test/reference/text-antialias-subpixel-rgb.image16.ref.png  |binary
 test/reference/text-antialias-subpixel-rgb.ref.png          |binary
 test/reference/text-antialias-subpixel-vbgr.image16.ref.png |binary
 test/reference/text-antialias-subpixel-vbgr.ref.png         |binary
 test/reference/text-antialias-subpixel-vrgb.image16.ref.png |binary
 test/reference/text-antialias-subpixel-vrgb.ref.png         |binary
 test/text-antialias-subpixel.c                              |  123 ++++++++++++
 10 files changed, 124 insertions(+)

New commits:
commit 9208df1630a535d473f656575c61a0ccf0c2a89c
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Oct 13 12:46:03 2011 +0200

    test: Add text-antialias-subpixel-{,v}{bgr,rgb}
    
    There were no tests for any subpixel order but rgb, so let's write something for
    all four possibilities.
    
    This is mostly copy&paste from test/text-antialias.c (and
    text-antialias-subpixel-rgb does the same thing as text-antialias-subpixel).
    
    Test for: https://bugs.freedesktop.org/show_bug.cgi?id=40456
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/test/Makefile.sources b/test/Makefile.sources
index 48a8f12..d6f82a8 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -315,6 +315,7 @@ test_sources = \
 	surface-pattern-scale-down-extend.c		\
 	surface-pattern-scale-up.c			\
 	text-antialias.c				\
+	text-antialias-subpixel.c			\
 	text-cache-crash.c				\
 	text-glyph-range.c				\
 	text-pattern.c					\
diff --git a/test/reference/text-antialias-subpixel-bgr.image16.ref.png b/test/reference/text-antialias-subpixel-bgr.image16.ref.png
new file mode 100644
index 0000000..5a4e193
Binary files /dev/null and b/test/reference/text-antialias-subpixel-bgr.image16.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-bgr.ref.png b/test/reference/text-antialias-subpixel-bgr.ref.png
new file mode 100644
index 0000000..fa64fa7
Binary files /dev/null and b/test/reference/text-antialias-subpixel-bgr.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-rgb.image16.ref.png b/test/reference/text-antialias-subpixel-rgb.image16.ref.png
new file mode 100644
index 0000000..cf049b9
Binary files /dev/null and b/test/reference/text-antialias-subpixel-rgb.image16.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-rgb.ref.png b/test/reference/text-antialias-subpixel-rgb.ref.png
new file mode 100644
index 0000000..09da5fa
Binary files /dev/null and b/test/reference/text-antialias-subpixel-rgb.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-vbgr.image16.ref.png b/test/reference/text-antialias-subpixel-vbgr.image16.ref.png
new file mode 100644
index 0000000..6ef721a
Binary files /dev/null and b/test/reference/text-antialias-subpixel-vbgr.image16.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-vbgr.ref.png b/test/reference/text-antialias-subpixel-vbgr.ref.png
new file mode 100644
index 0000000..13bdaf6
Binary files /dev/null and b/test/reference/text-antialias-subpixel-vbgr.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-vrgb.image16.ref.png b/test/reference/text-antialias-subpixel-vrgb.image16.ref.png
new file mode 100644
index 0000000..cb3586b
Binary files /dev/null and b/test/reference/text-antialias-subpixel-vrgb.image16.ref.png differ
diff --git a/test/reference/text-antialias-subpixel-vrgb.ref.png b/test/reference/text-antialias-subpixel-vrgb.ref.png
new file mode 100644
index 0000000..91d5abf
Binary files /dev/null and b/test/reference/text-antialias-subpixel-vrgb.ref.png differ
diff --git a/test/text-antialias-subpixel.c b/test/text-antialias-subpixel.c
new file mode 100644
index 0000000..6a65059
--- /dev/null
+++ b/test/text-antialias-subpixel.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ * Copyright © 2011 Uli Schlachter
+ *
+ * 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
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. 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: Uli Schlachter <psychon at znc.in>
+ *
+ * Based on test/text-antialias.c
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define WIDTH  31
+#define HEIGHT 22
+#define TEXT_SIZE 12
+
+static cairo_test_status_t
+draw (cairo_t *cr, cairo_subpixel_order_t order)
+{
+    cairo_text_extents_t extents;
+    cairo_font_options_t *font_options;
+    const char black[] = "black", blue[] = "blue";
+
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
+    cairo_paint (cr);
+
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
+			    CAIRO_FONT_SLANT_NORMAL,
+			    CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_set_font_size (cr, TEXT_SIZE);
+
+    font_options = cairo_font_options_create ();
+    cairo_get_font_options (cr, font_options);
+    cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
+    cairo_font_options_set_subpixel_order (font_options, order);
+    cairo_set_font_options (cr, font_options);
+
+    cairo_font_options_destroy (font_options);
+
+    cairo_set_source_rgb (cr, 0, 0, 0); /* black */
+    cairo_text_extents (cr, black, &extents);
+    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
+    cairo_show_text (cr, black);
+    cairo_translate (cr, 0, -extents.y_bearing + 1);
+
+    cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
+    cairo_text_extents (cr, blue, &extents);
+    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
+    cairo_show_text (cr, blue);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+draw_rgb (cairo_t *cr, int width, int height)
+{
+    return draw (cr, CAIRO_SUBPIXEL_ORDER_RGB);
+}
+
+static cairo_test_status_t
+draw_bgr (cairo_t *cr, int width, int height)
+{
+    return draw (cr, CAIRO_SUBPIXEL_ORDER_BGR);
+}
+
+static cairo_test_status_t
+draw_vrgb (cairo_t *cr, int width, int height)
+{
+    return draw (cr, CAIRO_SUBPIXEL_ORDER_VRGB);
+}
+
+static cairo_test_status_t
+draw_vbgr (cairo_t *cr, int width, int height)
+{
+    return draw (cr, CAIRO_SUBPIXEL_ORDER_VBGR);
+}
+
+CAIRO_TEST (text_antialias_subpixel_rgb,
+	    "Tests text rendering with rgb subpixel antialiasing",
+	    "text", /* keywords */
+	    "target=raster", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, draw_rgb)
+
+CAIRO_TEST (text_antialias_subpixel_bgr,
+	    "Tests text rendering with bgr subpixel antialiasing",
+	    "text", /* keywords */
+	    "target=raster", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, draw_bgr)
+
+CAIRO_TEST (text_antialias_subpixel_vrgb,
+	    "Tests text rendering with vertical rgb subpixel antialiasing",
+	    "text", /* keywords */
+	    "target=raster", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, draw_vrgb)
+
+CAIRO_TEST (text_antialias_subpixel_vbgr,
+	    "Tests text rendering with vertical bgr subpixel antialiasing",
+	    "text", /* keywords */
+	    "target=raster", /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, draw_vbgr)


More information about the cairo-commit mailing list