[cairo-commit] test/.gitignore test/long-lines.c test/long-lines-ref.png test/Makefile.am

Emmanuel Pacaud emmanuel at kemper.freedesktop.org
Mon Aug 14 11:19:30 PDT 2006


 test/.gitignore         |    1 
 test/Makefile.am        |    2 +
 test/long-lines-ref.png |binary
 test/long-lines.c       |   92 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 95 insertions(+)

New commits:
diff-tree 17ec33aa4f33919377d241bce01e2c395b2aa1b8 (from 09e1eb04ca06aa5c188dc3bdad0dadadaa9fe31f)
Author: Emmanuel Pacaud <emmanuel.pacaud at free.fr>
Date:   Mon Aug 14 20:19:15 2006 +0200

    New test for long line bug.
    
    This shows at least an issue in cairo_fixed_from_double where values
    > 32767 are converted to -32768, instead of being clamped to 32767.

diff --git a/test/.gitignore b/test/.gitignore
index 2927f3a..8206bbb 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -58,6 +58,7 @@ leaky-polygon
 line-width
 line-width-scale
 linear-gradient
+long-lines
 mask
 mask-ctm
 mask-surface-ctm
diff --git a/test/Makefile.am b/test/Makefile.am
index cbe1a73..e2e5f4f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -41,6 +41,7 @@ leaky-polygon			\
 line-width			\
 line-width-scale		\
 linear-gradient			\
+long-lines			\
 mask				\
 mask-ctm			\
 mask-surface-ctm		\
@@ -229,6 +230,7 @@ line-width-ref.png					\
 line-width-ps-argb32-ref.png				\
 line-width-scale-ref.png				\
 line-width-scale-ps-argb32-ref.png			\
+long-lines-ref.png					\
 mask-ref.png						\
 mask-rgb24-ref.png					\
 mask-beos-bitmap-argb32-ref.png				\
diff --git a/test/long-lines-ref.png b/test/long-lines-ref.png
new file mode 100644
index 0000000..6119204
Binary files /dev/null and b/test/long-lines-ref.png differ
diff --git a/test/long-lines.c b/test/long-lines.c
new file mode 100644
index 0000000..445ac66
--- /dev/null
+++ b/test/long-lines.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Authors: Carl D. Worth <cworth at cworth.org>
+ * 	    Emmanuel Pacaud <emmanuel.pacaud at lapp.in2p3.fr>
+ */
+
+#include "cairo-test.h"
+
+#define LINE_WIDTH 	1.
+#define SIZE 		10
+#define LINE_NBR	6
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+    "long-lines",
+    "Test long lines",
+    SIZE * (LINE_NBR + 1),
+    SIZE * (LINE_NBR + 1),
+    draw
+};
+
+struct {
+    double length;
+    double red, green, blue;
+} lines[LINE_NBR] = {
+    {      100.0, 1.0, 0.0, 0.0 },
+    {    10000.0, 0.0, 1.0, 0.0 },
+    {   100000.0, 0.0, 0.0, 1.0 },
+    {  1000000.0, 1.0, 1.0, 0.0 },
+    { 10000000.0, 0.0, 1.0, 1.0 },
+    {100000000.0, 1.0, 0.0, 1.0 }
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    double pos;
+    int i;
+
+    /* We draw in the default black, so paint white first. */
+    cairo_save (cr);
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
+    cairo_paint (cr);
+    cairo_restore (cr);
+
+
+    cairo_set_line_width (cr, LINE_WIDTH);
+
+    pos = SIZE + .5;
+    for (i = 0; i < LINE_NBR; i++) {
+	cairo_move_to (cr, pos, -lines[i].length);
+	cairo_line_to (cr, pos, +lines[i].length);
+	cairo_set_source_rgb (cr, lines[i].red, lines[i].green, lines[i].blue);
+	cairo_stroke (cr);
+	pos += SIZE;
+    }
+
+    /* This should display a perfect vertically centered black line */
+    cairo_move_to (cr, 0.5, -1e100);
+    cairo_line_to (cr, pos,  1e100);
+    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+    return cairo_test (&test);
+}


More information about the cairo-commit mailing list