diff options
author | Krzysztof Kosiński <tweenk.pl@gmail.com> | 2010-08-10 17:55:03 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-08-10 18:38:59 +0200 |
commit | a7762e3d6570a6981d8fb74ecc6ae30391c39b89 (patch) | |
tree | 233e20a8eaedf38ff10660bac406c79a0b05e4f6 | |
parent | 56ea51fdcc273531b5e86b921aad19237a1c9415 (diff) |
tests: Add linear-gradient-large test
Shows large rounding errors in Pixman when computing gradients. Added as
a test to Cairo to catch similar issues in other backends.
https://bugs.freedesktop.org/show_bug.cgi?id=29470
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.sources | 1 | ||||
-rw-r--r-- | test/linear-gradient-large.c | 67 | ||||
-rw-r--r-- | test/linear-gradient-large.ref.png | bin | 0 -> 3753 bytes |
4 files changed, 71 insertions, 2 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index df504baf..e1b07681 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -779,13 +779,14 @@ REFERENCE_IMAGES = \ linear-gradient.quartz.ref.png \ linear-gradient.ref.png \ linear-gradient.xlib.ref.png \ + linear-gradient-large.ref.png \ + linear-gradient-one-stop.argb32.ref.png \ + linear-gradient-one-stop.rgb24.ref.png \ linear-gradient-subset.image16.ref.png \ linear-gradient-subset.quartz.ref.png \ linear-gradient-subset.ref.png \ linear-gradient-subset.xlib.ref.png \ linear-gradient-subset.ps3.ref.png \ - linear-gradient-one-stop.argb32.ref.png \ - linear-gradient-one-stop.rgb24.ref.png \ linear-step-function.xfail.png \ linear-uniform.image16.ref.png \ linear-uniform.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index 7881cf03..bf8979d7 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -147,6 +147,7 @@ test_sources = \ line-width-zero.c \ linear-gradient.c \ linear-gradient-extend.c \ + linear-gradient-large.c \ linear-gradient-one-stop.c \ linear-gradient-reflect.c \ linear-gradient-subset.c \ diff --git a/test/linear-gradient-large.c b/test/linear-gradient-large.c new file mode 100644 index 00000000..f5e6a66a --- /dev/null +++ b/test/linear-gradient-large.c @@ -0,0 +1,67 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright 2010 Krzysztof Kosiński + * + * 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: Krzysztof Kosiński <tweenk.pl@gmail.com> + */ + +#include "cairo-test.h" + +/* originally reported in https://bugs.freedesktop.org/show_bug.cgi?id=29470 */ + +#define OFFSET 50 +#define SIZE 1000 + +static void mark_point(cairo_t *ct, double x, double y) +{ + cairo_rectangle(ct, x-2, y-2, 4, 4); + cairo_set_source_rgb(ct, 1,0,0); + cairo_fill(ct); +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_pattern_t *gr = cairo_pattern_create_linear (SIZE - OFFSET, OFFSET, + OFFSET, SIZE - OFFSET); + + cairo_pattern_add_color_stop_rgb (gr, 0.0, 1, 1, 1); + cairo_pattern_add_color_stop_rgb (gr, 0.0, 0, 0, 0); + cairo_pattern_add_color_stop_rgb (gr, 1.0, 0, 0, 0); + cairo_pattern_add_color_stop_rgb (gr, 1.0, 1, 1, 1); + + cairo_set_source (cr, gr); + cairo_paint (cr); + + mark_point(cr, SIZE - OFFSET, OFFSET); + mark_point(cr, OFFSET, SIZE - OFFSET); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (linear_gradient_large, + "Tests that large linear gradients get rendered at the correct place", + "linear, pattern", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw) diff --git a/test/linear-gradient-large.ref.png b/test/linear-gradient-large.ref.png Binary files differnew file mode 100644 index 00000000..cd5a07ae --- /dev/null +++ b/test/linear-gradient-large.ref.png |