[cairo-commit] Branch '1.10' - 4 commits - src/cairo-path-fixed.c src/cairo-quartz-surface.c test/Makefile.am test/Makefile.sources test/show-glyphs-advance.c test/show-glyphs-advance.image16.ref.png test/show-glyphs-advance.ps.ref.png test/show-glyphs-advance.quartz.ref.png test/show-glyphs-advance.ref.png test/show-glyphs-advance.svg.ref.png test/stroke-open-box.c test/stroke-open-box.ref.png

Andrea Canciani ranma42 at kemper.freedesktop.org
Sat Mar 19 08:09:52 PDT 2011


 src/cairo-path-fixed.c                   |    5 +
 src/cairo-quartz-surface.c               |    9 ++
 test/Makefile.am                         |    6 +
 test/Makefile.sources                    |    2 
 test/show-glyphs-advance.c               |  107 +++++++++++++++++++++++++++++++
 test/show-glyphs-advance.image16.ref.png |binary
 test/show-glyphs-advance.ps.ref.png      |binary
 test/show-glyphs-advance.quartz.ref.png  |binary
 test/show-glyphs-advance.ref.png         |binary
 test/show-glyphs-advance.svg.ref.png     |binary
 test/stroke-open-box.c                   |   51 ++++++++++++++
 test/stroke-open-box.ref.png             |binary
 12 files changed, 178 insertions(+), 2 deletions(-)

New commits:
commit b4466bc9140bdacbd93eb6ed76f9e4e749a2bae2
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Mar 16 17:12:59 2011 +0100

    quartz: Fix y glyph advance
    
    The advances must be transformed by the "quartz inverse scale",
    i.e. (scale_inverse * scale(1,-1)).
    
    Fixes show-glyph-advance.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 113674f..6dd5aca 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -2579,12 +2579,19 @@ _cairo_quartz_surface_show_glyphs_cg (void *abstract_surface,
 	}
     }
 
+    /* scale(1,-1) * scaled_font->scale */
     textTransform = CGAffineTransformMake (scaled_font->scale.xx,
 					   scaled_font->scale.yx,
 					   -scaled_font->scale.xy,
 					   -scaled_font->scale.yy,
 					   0, 0);
-    _cairo_quartz_cairo_matrix_to_quartz (&scaled_font->scale_inverse, &invTextTransform);
+
+    /* scaled_font->scale_inverse * scale(1,-1) */
+    invTextTransform = CGAffineTransformMake (scaled_font->scale_inverse.xx,
+					      -scaled_font->scale_inverse.yx,
+					      scaled_font->scale_inverse.xy,
+					      -scaled_font->scale_inverse.yy,
+					      0.0, 0.0);
 
     CGContextSetTextMatrix (surface->cgContext, CGAffineTransformIdentity);
 
commit aaf87a65a897bddc398c88db884c585267805c94
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Mar 16 16:24:51 2011 +0100

    test: Add show-glyphs-advance
    
    This new test (based on show-glyphs-many) checks that the glyphs
    advances are respected along both axes.
    
    9c0d761bfcdd28d52c83d74f46dd3c709ae0fa69 introduced a bug which
    regresses this test in quartz.
    
    Thanks to Jeff Muizelaar for the report!

diff --git a/test/Makefile.am b/test/Makefile.am
index ec3e613..adce425 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1150,6 +1150,11 @@ REFERENCE_IMAGES = \
 	self-intersecting.xlib.ref.png \
 	set-source.ref.png \
 	set-source.rgb24.ref.png \
+	show-glyphs-advance.image16.ref.png \
+	show-glyphs-advance.ps.ref.png \
+	show-glyphs-advance.quartz.ref.png \
+	show-glyphs-advance.ref.png \
+	show-glyphs-advance.svg.ref.png \
 	show-glyphs-many.ref.png \
 	show-text-current-point.image16.ref.png \
 	show-text-current-point.ps2.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 8b1b14f..01bd091 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -233,6 +233,7 @@ test_sources = \
 	self-copy-overlap.c				\
 	self-intersecting.c				\
 	set-source.c					\
+	show-glyphs-advance.c				\
 	show-glyphs-many.c				\
 	show-text-current-point.c			\
 	skew-extreme.c					\
diff --git a/test/show-glyphs-advance.c b/test/show-glyphs-advance.c
new file mode 100644
index 0000000..f0ea57e
--- /dev/null
+++ b/test/show-glyphs-advance.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ * Copyright © 2011 Andrea Canciani
+ *
+ * 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>
+ *         Andrea Canciani <ranma42 at gmail.com>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+get_glyph (const cairo_test_context_t *ctx,
+	   cairo_scaled_font_t *scaled_font,
+	   const char *utf8,
+	   cairo_glyph_t *glyph)
+{
+    cairo_glyph_t *text_to_glyphs;
+    cairo_status_t status;
+    int i;
+
+    text_to_glyphs = glyph;
+    i = 1;
+    status = cairo_scaled_font_text_to_glyphs (scaled_font,
+					       0, 0,
+					       utf8, -1,
+					       &text_to_glyphs, &i,
+					       NULL, NULL,
+					       0);
+    if (status != CAIRO_STATUS_SUCCESS)
+	return cairo_test_status_from_status (ctx, status);
+
+    if (text_to_glyphs != glyph) {
+	*glyph = text_to_glyphs[0];
+	cairo_glyph_free (text_to_glyphs);
+    }
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+static const char *characters[] = { "A", "B", "C", "D" };
+
+#define NUM_CHARS 4
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
+    cairo_scaled_font_t *scaled_font;
+    cairo_glyph_t *glyphs = xmalloc (NUM_CHARS  * sizeof (cairo_glyph_t));
+    int i;
+    cairo_status_t status;
+
+    /* Paint white background. */
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    scaled_font = cairo_get_scaled_font (cr);
+
+    for (i = 0; i < NUM_CHARS; i++) {
+	status = get_glyph (ctx, scaled_font, characters[i], &glyphs[i]);
+	if (status)
+	    goto BAIL;
+
+	glyphs[i].x = 10.0 + 10.0 * (i % 2);
+	glyphs[i].y = 20.0 + 10.0 * (i / 2);
+    }
+
+    cairo_set_source_rgb (cr, 0, 0, 0);
+    cairo_show_glyphs (cr, glyphs, 4);
+
+    cairo_translate (cr, 40., 20.);
+    cairo_rotate (cr, M_PI / 4.);
+
+    cairo_show_glyphs (cr, glyphs, NUM_CHARS);
+
+  BAIL:
+    free(glyphs);
+
+    return status;
+}
+
+CAIRO_TEST (show_glyphs_advance,
+	    "Test that glyph advances work as expected along both axes",
+	    "text, matrix", /* keywords */
+	    NULL, /* requirements */
+	    64, 64,
+	    NULL, draw)
diff --git a/test/show-glyphs-advance.image16.ref.png b/test/show-glyphs-advance.image16.ref.png
new file mode 100644
index 0000000..dd2f18d
Binary files /dev/null and b/test/show-glyphs-advance.image16.ref.png differ
diff --git a/test/show-glyphs-advance.ps.ref.png b/test/show-glyphs-advance.ps.ref.png
new file mode 100644
index 0000000..96a80f9
Binary files /dev/null and b/test/show-glyphs-advance.ps.ref.png differ
diff --git a/test/show-glyphs-advance.quartz.ref.png b/test/show-glyphs-advance.quartz.ref.png
new file mode 100644
index 0000000..4750308
Binary files /dev/null and b/test/show-glyphs-advance.quartz.ref.png differ
diff --git a/test/show-glyphs-advance.ref.png b/test/show-glyphs-advance.ref.png
new file mode 100644
index 0000000..bf44a8f
Binary files /dev/null and b/test/show-glyphs-advance.ref.png differ
diff --git a/test/show-glyphs-advance.svg.ref.png b/test/show-glyphs-advance.svg.ref.png
new file mode 100644
index 0000000..914d4d6
Binary files /dev/null and b/test/show-glyphs-advance.svg.ref.png differ
commit 36e0cad71aa7b9a84fb31fba333175cbf445ab4e
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Tue Mar 8 10:26:06 2011 +0100

    path: Fix _cairo_path_fixed_is_rectangle()
    
    __cairo_path_fixed_is_rectangle() is used by the PS and PDF backends
    to check if a path is equivalent to a rectangle when stroking. This is
    different from being a rectangle when filling, because of the implicit
    close_path appended to every subpath when filling.
    
    Fixes stroke-open-box.
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=34560

diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index eea8630..72af7bb 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -1286,8 +1286,11 @@ _cairo_path_fixed_is_rectangle (const cairo_path_fixed_t *path,
     if (! _cairo_path_fixed_is_box (path, box))
 	return FALSE;
 
+    /* This check is valid because the current implementation of
+     * _cairo_path_fixed_is_box () only accepts rectangles like:
+     * move,line,line,line[,line|close[,close|move]]. */
     buf = cairo_path_head (path);
-    if (buf->points[0].y == buf->points[1].y)
+    if (buf->num_ops > 4)
 	return TRUE;
 
     return FALSE;
commit 145e8ab03db77a13b49bfb0fb9ca6355ad48c2bc
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Tue Mar 8 10:13:24 2011 +0100

    test: Add stroke-open-box
    
    Add a new test to check that the stroking of a 3-sided box is not
    "optimized" to a 4-sided box.
    
    Test case based on the code by Simon Kellner in
    https://bugs.freedesktop.org/show_bug.cgi?id=34560

diff --git a/test/Makefile.am b/test/Makefile.am
index 9b673d2..ec3e613 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1230,6 +1230,7 @@ REFERENCE_IMAGES = \
 	stroke-image.quartz.ref.png \
 	stroke-image.ref.png \
 	stroke-image.xlib.ref.png \
+	stroke-open-box.ref.png \
 	subsurface.ref.png \
 	subsurface.image16.ref.png \
 	subsurface.ps.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 487fedd..8b1b14f 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -226,6 +226,7 @@ test_sources = \
 	scaled-font-zero-matrix.c			\
 	stroke-ctm-caps.c				\
 	stroke-image.c				        \
+	stroke-open-box.c				\
 	select-font-face.c				\
 	select-font-no-show-text.c			\
 	self-copy.c					\
diff --git a/test/stroke-open-box.c b/test/stroke-open-box.c
new file mode 100644
index 0000000..b1dae50
--- /dev/null
+++ b/test/stroke-open-box.c
@@ -0,0 +1,51 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright 2011 Simon Kellner
+ *
+ * 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: Simon Kellner <kellner at kit.edu>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    cairo_set_source_rgb (cr, 0, 0, 0);
+    cairo_move_to (cr, 5, 7);
+    cairo_rel_line_to (cr, 20, 0);
+    cairo_rel_line_to (cr, 0, 15);
+    cairo_rel_line_to (cr, -20, 0);
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (stroke_open_box,
+	    "Tests stroking of a 3-sided box",
+	    "stroke,box", /* keywords */
+	    NULL, /* requirements */
+	    30, 32,
+	    NULL, draw)
diff --git a/test/stroke-open-box.ref.png b/test/stroke-open-box.ref.png
new file mode 100644
index 0000000..b5f5bd5
Binary files /dev/null and b/test/stroke-open-box.ref.png differ


More information about the cairo-commit mailing list