From 851c8839622619779c9169299e3efccd108d0395 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 19 Jun 2009 19:00:39 +0100 Subject: [PATCH] [test] Add group-clip Larry Ewing found an ancient and nasty bug whereby a path was not corrected whilst pushing and popping groups. --- AUTHORS | 1 + test/Makefile.am | 1 + test/Makefile.sources | 1 + test/group-clip.c | 57 ++++++++++++++++++++++++++++++++++++++++ test/group-clip.ref.png | Bin 0 -> 191 bytes 5 files changed, 60 insertions(+) create mode 100644 test/group-clip.c create mode 100644 test/group-clip.ref.png diff --git a/AUTHORS b/AUTHORS index 7f7b0d188..39a31795c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,6 +23,7 @@ John Ellson First font/glyph extents functions Michael Emmel DirectFB backend Miklós Erdélyi Fix typo leading to a crash Behdad Esfahbod Huge piles of bug fixes, improvements, and general maintenance +Larry Ewing Test case for group-clip Brian Ewins ATSUI maintenance (first success at making it really work) Bertram Felgenhauer Fixes for subtle arithmetic errors Damian Frank Build system improvements for win32 diff --git a/test/Makefile.am b/test/Makefile.am index ff4d58888..a2275a4c7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -500,6 +500,7 @@ REFERENCE_IMAGES = \ gradient-constant-alpha.rgb24.ref.png \ gradient-zero-stops.ref.png \ gradient-zero-stops.rgb24.ref.png \ + group-clip.ref.png \ group-paint.ref.png \ huge-linear.ps3.ref.png \ huge-linear.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index 4604b1fff..64c6d043d 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -79,6 +79,7 @@ test_sources = \ gradient-alpha.c \ gradient-constant-alpha.c \ gradient-zero-stops.c \ + group-clip.c \ group-paint.c \ huge-linear.c \ huge-radial.c \ diff --git a/test/group-clip.c b/test/group-clip.c new file mode 100644 index 000000000..b99d8617e --- /dev/null +++ b/test/group-clip.c @@ -0,0 +1,57 @@ +/* + * Copyright © Chris Wilson, 2008 + * + * 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 + * Chris Wilson 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. + * + * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL CHRIS WILSON 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: Chris Wilson + * Larry Ewing + */ + +#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_rectangle (cr, 25, 25, width, height); + cairo_clip_preserve (cr); + cairo_push_group (cr); + cairo_set_source_rgb (cr, 0, 0, 1); + cairo_fill (cr); + cairo_rectangle (cr, 0, 0, width, height); + cairo_pop_group_to_source (cr); + cairo_paint (cr); + + cairo_reset_clip (cr); + cairo_clip_preserve (cr); + cairo_set_source_rgba (cr, 1, 0, 0, .5); + cairo_paint (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (group_clip, + "test preserving paths across groups", + "group", /* keywords */ + NULL, /* requirements */ + 40 + 25, 40 + 25, + NULL, draw) diff --git a/test/group-clip.ref.png b/test/group-clip.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..7b8a7532f710f8485029336d5df2691ba7810ad0 GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^jv&mz1SA=!#t8u_wj^(N7l!{JxM1({$v}}3PZ!6K zjK;SY8#x;c1XvtJfAg)3$rfN*XB2$kHayUHx3vIVCg!0I|hC761SM literal 0 HcmV?d00001