test: improve clip-*-unbounded tests
Merge clip-*-unbounded tests and add self-intersections to the paths that are drawn. This exposes a bug in the unbounded fixup code in quartz. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
@ -215,8 +215,26 @@ REFERENCE_IMAGES = \
|
|||
clip-fill.quartz.ref.png \
|
||||
clip-fill.xlib.ref.png \
|
||||
clip-fill.xlib-fallback.ref.png \
|
||||
clip-fill-eo-unbounded.image16.ref.png \
|
||||
clip-fill-eo-unbounded.argb32.ref.png \
|
||||
clip-fill-eo-unbounded.rgb24.ref.png \
|
||||
clip-fill-eo-unbounded.quartz.argb32.ref.png \
|
||||
clip-fill-eo-unbounded.quartz.rgb24.ref.png \
|
||||
clip-fill-eo-unbounded.svg12.rgb24.xfail.png \
|
||||
clip-fill-eo-unbounded.xlib.argb32.ref.png \
|
||||
clip-fill-eo-unbounded.xlib.rgb24.ref.png \
|
||||
clip-fill-eo-unbounded.xlib-fallback.rgb24.ref.png \
|
||||
clip-fill-no-op.image16.ref.png \
|
||||
clip-fill-no-op.ref.png \
|
||||
clip-fill-nz-unbounded.image16.ref.png \
|
||||
clip-fill-nz-unbounded.argb32.ref.png \
|
||||
clip-fill-nz-unbounded.rgb24.ref.png \
|
||||
clip-fill-nz-unbounded.quartz.argb32.ref.png \
|
||||
clip-fill-nz-unbounded.quartz.rgb24.ref.png \
|
||||
clip-fill-nz-unbounded.svg12.rgb24.xfail.png \
|
||||
clip-fill-nz-unbounded.xlib.argb32.ref.png \
|
||||
clip-fill-nz-unbounded.xlib.rgb24.ref.png \
|
||||
clip-fill-nz-unbounded.xlib-fallback.rgb24.ref.png \
|
||||
clip-fill-rule-pixel-aligned.ref.png \
|
||||
clip-fill-rule-pixel-aligned.rgb24.ref.png \
|
||||
clip-fill-rule.image16.ref.png \
|
||||
|
|
@ -228,18 +246,6 @@ REFERENCE_IMAGES = \
|
|||
clip-fill-rule.rgb24.ref.png \
|
||||
clip-fill-rule.test-paginated.rgb24.ref.png \
|
||||
clip-fill-rule.xlib.rgb24.ref.png \
|
||||
clip-fill-unbounded.image16.ref.png \
|
||||
clip-fill-unbounded.argb32.ref.png \
|
||||
clip-fill-unbounded.rgb24.ref.png \
|
||||
clip-fill-unbounded.pdf.argb32.ref.png \
|
||||
clip-fill-unbounded.ps.argb32.xfail.png \
|
||||
clip-fill-unbounded.quartz.argb32.ref.png \
|
||||
clip-fill-unbounded.quartz.rgb24.ref.png \
|
||||
clip-fill-unbounded.svg12.argb32.xfail.png \
|
||||
clip-fill-unbounded.svg12.rgb24.xfail.png \
|
||||
clip-fill-unbounded.xlib.argb32.ref.png \
|
||||
clip-fill-unbounded.xlib.rgb24.ref.png \
|
||||
clip-fill-unbounded.xlib-fallback.rgb24.ref.png \
|
||||
clip-group-shapes-aligned-rectangles.ref.png \
|
||||
clip-group-shapes-unaligned-rectangles.ref.png \
|
||||
clip-group-shapes-unaligned-rectangles.xlib.ref.png \
|
||||
|
|
@ -304,14 +310,11 @@ REFERENCE_IMAGES = \
|
|||
clip-stroke.xlib-fallback.ref.png \
|
||||
clip-stroke-no-op.image16.ref.png \
|
||||
clip-stroke-no-op.ref.png \
|
||||
clip-stroke-unbounded.image16.ref.png \
|
||||
clip-stroke-unbounded.image16.rgb24.ref.png \
|
||||
clip-stroke-unbounded.argb32.ref.png \
|
||||
clip-stroke-unbounded.rgb24.ref.png \
|
||||
clip-stroke-unbounded.ps.argb32.ref.png \
|
||||
clip-stroke-unbounded.pdf.argb32.xfail.png \
|
||||
clip-stroke-unbounded.quartz.argb32.ref.png \
|
||||
clip-stroke-unbounded.quartz.rgb24.ref.png \
|
||||
clip-stroke-unbounded.svg12.argb32.xfail.png \
|
||||
clip-stroke-unbounded.svg12.rgb24.xfail.png \
|
||||
clip-stroke-unbounded.xlib.argb32.ref.png \
|
||||
clip-stroke-unbounded.xlib.rgb24.ref.png \
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ test_sources = \
|
|||
clip-contexts.c \
|
||||
clip-disjoint.c \
|
||||
clip-device-offset.c \
|
||||
clip-draw-unbounded.c \
|
||||
clip-empty.c \
|
||||
clip-empty-group.c \
|
||||
clip-empty-save.c \
|
||||
|
|
@ -32,7 +33,6 @@ test_sources = \
|
|||
clip-fill-no-op.c \
|
||||
clip-fill-rule.c \
|
||||
clip-fill-rule-pixel-aligned.c \
|
||||
clip-fill-unbounded.c \
|
||||
clip-group-shapes.c \
|
||||
clip-image.c \
|
||||
clip-nesting.c \
|
||||
|
|
@ -41,7 +41,6 @@ test_sources = \
|
|||
clip-shape.c \
|
||||
clip-stroke.c \
|
||||
clip-stroke-no-op.c \
|
||||
clip-stroke-unbounded.c \
|
||||
clip-text.c \
|
||||
clip-twice.c \
|
||||
clip-twice-rectangle.c \
|
||||
|
|
|
|||
184
test/clip-draw-unbounded.c
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
|
||||
/*
|
||||
* Copyright 2009 Chris Wilson
|
||||
* Copyright 2010 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: Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 60
|
||||
#define HEIGHT 60
|
||||
|
||||
static void
|
||||
stroke (cairo_t *cr)
|
||||
{
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_IN);
|
||||
cairo_set_source_rgb (cr, 0, 0.7, 0);
|
||||
cairo_arc (cr, 10, 10, 7.5, 0, 2 * M_PI);
|
||||
cairo_move_to (cr, 0, 20);
|
||||
cairo_line_to (cr, 20, 0);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
fill (cairo_t *cr)
|
||||
{
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_IN);
|
||||
cairo_set_source_rgb (cr, 0, 0.7, 0);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 10, 10, 8.5, 0, 2 * M_PI);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc_negative (cr, 10, 10, 6.5, 2 * M_PI, 0);
|
||||
|
||||
cairo_move_to (cr, -1, 19);
|
||||
cairo_line_to (cr, 1, 21);
|
||||
cairo_line_to (cr, 21, 1);
|
||||
cairo_line_to (cr, 19, -1);
|
||||
cairo_line_to (cr, -1, 19);
|
||||
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
clip_simple (cairo_t *cr)
|
||||
{
|
||||
cairo_rectangle (cr, 0, 0, 20, 20);
|
||||
cairo_clip (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
clip_unaligned (cairo_t *cr)
|
||||
{
|
||||
cairo_rectangle (cr, 0.5, 0.5, 20, 20);
|
||||
cairo_clip (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
clip_aligned (cairo_t *cr)
|
||||
{
|
||||
cairo_fill_rule_t orig_rule;
|
||||
|
||||
orig_rule = cairo_get_fill_rule (cr);
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
cairo_rectangle (cr, 0, 0, 20, 20);
|
||||
cairo_rectangle (cr, 3, 3, 10, 10);
|
||||
cairo_rectangle (cr, 7, 7, 10, 10);
|
||||
cairo_clip (cr);
|
||||
cairo_set_fill_rule (cr, orig_rule);
|
||||
}
|
||||
|
||||
static void
|
||||
clip_mask (cairo_t *cr)
|
||||
{
|
||||
cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
|
||||
cairo_clip (cr);
|
||||
}
|
||||
|
||||
static void (* const clip_funcs[])(cairo_t *cr) = {
|
||||
clip_simple,
|
||||
clip_unaligned,
|
||||
clip_aligned,
|
||||
clip_mask
|
||||
};
|
||||
|
||||
static double translations[][2] = {
|
||||
{ 10, 10 },
|
||||
{ WIDTH, 0 },
|
||||
{ -WIDTH, HEIGHT },
|
||||
{ WIDTH, 0 }
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, void (*shapes)(cairo_t *))
|
||||
{
|
||||
int i;
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
|
||||
for (i = 0; i < sizeof (clip_funcs) / sizeof (clip_funcs[0]); i++) {
|
||||
cairo_translate (cr, translations[i][0], translations[i][1]);
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_scale (cr, 2, 2);
|
||||
clip_funcs[i] (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_test_status_t
|
||||
draw_stroke (cairo_t *cr, int width, int height)
|
||||
{
|
||||
return draw (cr, stroke);
|
||||
}
|
||||
|
||||
static cairo_test_status_t
|
||||
draw_fill_nz (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
|
||||
return draw (cr, fill);
|
||||
}
|
||||
|
||||
static cairo_test_status_t
|
||||
draw_fill_eo (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
return draw (cr, fill);
|
||||
}
|
||||
|
||||
CAIRO_TEST (clip_stroke_unbounded,
|
||||
"Tests unbounded stroke through complex clips.",
|
||||
"clip, stroke, unbounded", /* keywords */
|
||||
NULL, /* requirements */
|
||||
2 * WIDTH, 2 * HEIGHT,
|
||||
NULL, draw_stroke)
|
||||
|
||||
CAIRO_TEST (clip_fill_nz_unbounded,
|
||||
"Tests unbounded fill through complex clips (with winding fill rule).",
|
||||
"clip, fill, unbounded", /* keywords */
|
||||
NULL, /* requirements */
|
||||
2 * WIDTH, 2 * HEIGHT,
|
||||
NULL, draw_fill_nz)
|
||||
|
||||
CAIRO_TEST (clip_fill_eo_unbounded,
|
||||
"Tests unbounded fill through complex clips (with even-odd fill rule).",
|
||||
"clip, fill, unbounded", /* keywords */
|
||||
NULL, /* requirements */
|
||||
2 * WIDTH, 2 * HEIGHT,
|
||||
NULL, draw_fill_eo)
|
||||
BIN
test/clip-fill-eo-unbounded.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-fill-eo-unbounded.image16.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
test/clip-fill-eo-unbounded.quartz.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
test/clip-fill-eo-unbounded.quartz.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
test/clip-fill-eo-unbounded.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
test/clip-fill-eo-unbounded.svg12.rgb24.xfail.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-fill-eo-unbounded.xlib-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
test/clip-fill-eo-unbounded.xlib.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-fill-eo-unbounded.xlib.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
test/clip-fill-nz-unbounded.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-fill-nz-unbounded.image16.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
test/clip-fill-nz-unbounded.quartz.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
test/clip-fill-nz-unbounded.quartz.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
test/clip-fill-nz-unbounded.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
test/clip-fill-nz-unbounded.svg12.rgb24.xfail.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-fill-nz-unbounded.xlib-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
test/clip-fill-nz-unbounded.xlib.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-fill-nz-unbounded.xlib.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009 Chris Wilson
|
||||
*
|
||||
* 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. Chris Wilson 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.
|
||||
*
|
||||
* Author: Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 40
|
||||
#define HEIGHT 40
|
||||
|
||||
static void
|
||||
shapes (cairo_t *cr)
|
||||
{
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_IN);
|
||||
cairo_set_source_rgb (cr, 0, 0.7, 0);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 10, 10, 8.5, 0, 2 * M_PI);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc_negative (cr, 10, 10, 6.5, 2 * M_PI, 0);
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
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_translate (cr, 10, 10);
|
||||
|
||||
/* simple clip */
|
||||
cairo_save (cr);
|
||||
cairo_rectangle (cr, 0, 0, 20, 20);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, WIDTH, 0);
|
||||
|
||||
/* unaligned clip */
|
||||
cairo_save (cr);
|
||||
cairo_rectangle (cr, 0.5, 0.5, 20, 20);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, -WIDTH, HEIGHT);
|
||||
|
||||
/* aligned-clip */
|
||||
cairo_save (cr);
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
cairo_rectangle (cr, 0, 0, 20, 20);
|
||||
cairo_rectangle (cr, 3, 3, 10, 10);
|
||||
cairo_rectangle (cr, 7, 7, 10, 10);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, WIDTH, 0);
|
||||
|
||||
/* force a clip-mask */
|
||||
cairo_save (cr);
|
||||
cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
CAIRO_TEST (clip_fill_unbounded,
|
||||
"Tests unbounded fill through complex clips.",
|
||||
"clip, fill, unbounded", /* keywords */
|
||||
NULL, /* requirements */
|
||||
2 * WIDTH, 2* HEIGHT,
|
||||
NULL, draw)
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.5 KiB |
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009 Chris Wilson
|
||||
*
|
||||
* 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. Chris Wilson 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.
|
||||
*
|
||||
* Author: Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 40
|
||||
#define HEIGHT 40
|
||||
|
||||
static void
|
||||
shapes (cairo_t *cr)
|
||||
{
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_IN);
|
||||
cairo_set_source_rgb (cr, 0, 0.7, 0);
|
||||
cairo_arc (cr, 10, 10, 7.5, 0, 2 * M_PI);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
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_translate (cr, 10, 10);
|
||||
|
||||
/* simple clip */
|
||||
cairo_save (cr);
|
||||
cairo_rectangle (cr, 0, 0, 20, 20);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, WIDTH, 0);
|
||||
|
||||
/* unaligned clip */
|
||||
cairo_save (cr);
|
||||
cairo_rectangle (cr, 0.5, 0.5, 20, 20);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, -WIDTH, HEIGHT);
|
||||
|
||||
/* aligned-clip */
|
||||
cairo_save (cr);
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
cairo_rectangle (cr, 0, 0, 20, 20);
|
||||
cairo_rectangle (cr, 3, 3, 10, 10);
|
||||
cairo_rectangle (cr, 7, 7, 10, 10);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_translate (cr, WIDTH, 0);
|
||||
|
||||
/* force a clip-mask */
|
||||
cairo_save (cr);
|
||||
cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
|
||||
cairo_clip (cr);
|
||||
shapes (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
CAIRO_TEST (clip_stroke_unbounded,
|
||||
"Tests unbounded stroke through complex clips.",
|
||||
"clip, stroke, unbounded", /* keywords */
|
||||
NULL, /* requirements */
|
||||
2 * WIDTH, 2* HEIGHT,
|
||||
NULL, draw)
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
BIN
test/clip-stroke-unbounded.image16.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3 KiB |