diff options
author | Emmanuel Pacaud <emmanuel.pacaud@free.fr> | 2006-08-14 20:19:15 +0200 |
---|---|---|
committer | Emmanuel Pacaud <emmanuel.pacaud@free.fr> | 2006-08-14 20:19:15 +0200 |
commit | 17ec33aa4f33919377d241bce01e2c395b2aa1b8 (patch) | |
tree | 615bbb1904dcc538fd4ec846f739e4a02b9014b5 | |
parent | 09e1eb04ca06aa5c188dc3bdad0dadadaa9fe31f (diff) |
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.
-rw-r--r-- | test/.gitignore | 1 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/long-lines-ref.png | bin | 0 -> 247 bytes | |||
-rw-r--r-- | test/long-lines.c | 92 |
4 files changed, 95 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore index 2927f3ae..8206bbb4 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 cbe1a737..e2e5f4f8 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 Binary files differnew file mode 100644 index 00000000..6119204c --- /dev/null +++ b/test/long-lines-ref.png diff --git a/test/long-lines.c b/test/long-lines.c new file mode 100644 index 00000000..445ac66d --- /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@cworth.org> + * Emmanuel Pacaud <emmanuel.pacaud@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); +} |