Blame test/clip-fill.c

Packit 324a5c
/*
Packit 324a5c
 * Copyright 2009 Chris Wilson
Packit 324a5c
 *
Packit 324a5c
 * Permission to use, copy, modify, distribute, and sell this software
Packit 324a5c
 * and its documentation for any purpose is hereby granted without
Packit 324a5c
 * fee, provided that the above copyright notice appear in all copies
Packit 324a5c
 * and that both that copyright notice and this permission notice
Packit 324a5c
 * appear in supporting documentation, and that the name of
Packit 324a5c
 * Chris Wilson not be used in advertising or publicity pertaining to
Packit 324a5c
 * distribution of the software without specific, written prior
Packit 324a5c
 * permission. Chris Wilson makes no representations about the
Packit 324a5c
 * suitability of this software for any purpose.  It is provided "as
Packit 324a5c
 * is" without express or implied warranty.
Packit 324a5c
 *
Packit 324a5c
 * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
Packit 324a5c
 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
Packit 324a5c
 * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
Packit 324a5c
 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
Packit 324a5c
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
Packit 324a5c
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
Packit 324a5c
 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Packit 324a5c
 *
Packit 324a5c
 * Author: Chris Wilson <chris@chris-wilson.co.uk>
Packit 324a5c
 */
Packit 324a5c
Packit 324a5c
#include "cairo-test.h"
Packit 324a5c
Packit 324a5c
#define WIDTH 20
Packit 324a5c
#define HEIGHT 20
Packit 324a5c
Packit 324a5c
static cairo_test_status_t
Packit 324a5c
draw (cairo_t *cr, int width, int height)
Packit 324a5c
{
Packit 324a5c
    cairo_set_source_rgb (cr, 1, 1, 1);
Packit 324a5c
    cairo_paint (cr);
Packit 324a5c
Packit 324a5c
    /* aligned-clip */
Packit 324a5c
    cairo_save (cr);
Packit 324a5c
    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
Packit 324a5c
    cairo_rectangle (cr, 0, 0, 20, 20);
Packit 324a5c
    cairo_rectangle (cr, 3, 3, 10, 10);
Packit 324a5c
    cairo_rectangle (cr, 7, 7, 10, 10);
Packit 324a5c
    cairo_clip (cr);
Packit 324a5c
Packit 324a5c
    cairo_set_source_rgb (cr, 0.7, 0, 0);
Packit 324a5c
    cairo_paint (cr);
Packit 324a5c
    cairo_set_source_rgb (cr, 0, 0.7, 0);
Packit 324a5c
    cairo_arc (cr, 10, 10, 8, 0, 2 * M_PI);
Packit 324a5c
    cairo_fill (cr);
Packit 324a5c
    cairo_restore (cr);
Packit 324a5c
Packit 324a5c
    cairo_translate (cr, WIDTH, 0);
Packit 324a5c
Packit 324a5c
    /* force a clip-mask */
Packit 324a5c
    cairo_save (cr);
Packit 324a5c
    cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
Packit 324a5c
    cairo_new_sub_path (cr);
Packit 324a5c
    cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
Packit 324a5c
    cairo_new_sub_path (cr);
Packit 324a5c
    cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
Packit 324a5c
    cairo_clip (cr);
Packit 324a5c
Packit 324a5c
    cairo_set_source_rgb (cr, 0, 0, 0.7);
Packit 324a5c
    cairo_paint (cr);
Packit 324a5c
    cairo_set_source_rgb (cr, 0, 0.7, 0);
Packit 324a5c
    cairo_arc (cr, 10, 10, 7.5, 0, 2 * M_PI);
Packit 324a5c
    cairo_fill (cr);
Packit 324a5c
    cairo_restore (cr);
Packit 324a5c
Packit 324a5c
    return CAIRO_TEST_SUCCESS;
Packit 324a5c
}
Packit 324a5c
Packit 324a5c
CAIRO_TEST (clip_fill,
Packit 324a5c
	    "Tests filling through complex clips.",
Packit 324a5c
	    "clip, fill", /* keywords */
Packit 324a5c
	    NULL, /* requirements */
Packit 324a5c
	    2 * WIDTH, HEIGHT,
Packit 324a5c
	    NULL, draw)