|
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 SIZE 10
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
static cairo_surface_t *
|
|
Packit |
324a5c |
create_source (cairo_surface_t *target)
|
|
Packit |
324a5c |
{
|
|
Packit |
324a5c |
cairo_surface_t *similar;
|
|
Packit |
324a5c |
cairo_t *cr;
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
similar = cairo_surface_create_similar (target,
|
|
Packit |
324a5c |
CAIRO_CONTENT_COLOR, SIZE/2, SIZE);
|
|
Packit |
324a5c |
cr = cairo_create (similar);
|
|
Packit |
324a5c |
cairo_surface_destroy (similar);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
cairo_set_source_rgb (cr, 1, 0, 0);
|
|
Packit |
324a5c |
cairo_paint (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
similar = cairo_surface_reference (cairo_get_target (cr));
|
|
Packit |
324a5c |
cairo_destroy (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
return similar;
|
|
Packit |
324a5c |
}
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
static cairo_test_status_t
|
|
Packit |
324a5c |
draw (cairo_t *cr, int width, int height)
|
|
Packit |
324a5c |
{
|
|
Packit |
324a5c |
cairo_surface_t *source;
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
cairo_set_source_rgb (cr, 0, 0, 1);
|
|
Packit |
324a5c |
cairo_paint (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
cairo_rectangle (cr, 0, 0, SIZE/2, SIZE);
|
|
Packit |
324a5c |
cairo_clip (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/* Draw a source rectangle outside the image, the effect should be to
|
|
Packit |
324a5c |
* clear only within the clip region.
|
|
Packit |
324a5c |
*/
|
|
Packit |
324a5c |
source = create_source (cairo_get_target (cr));
|
|
Packit |
324a5c |
cairo_set_source_surface (cr, source, SIZE/2, 0);
|
|
Packit |
324a5c |
cairo_surface_destroy (source);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
Packit |
324a5c |
cairo_paint (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
return CAIRO_TEST_SUCCESS;
|
|
Packit |
324a5c |
}
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
CAIRO_TEST (clip_unbounded,
|
|
Packit |
324a5c |
"Test handling of an unbounded fill outside the clip region",
|
|
Packit |
324a5c |
"clip", /* keywords */
|
|
Packit |
324a5c |
NULL, /* requirements */
|
|
Packit |
324a5c |
SIZE, SIZE,
|
|
Packit |
324a5c |
NULL, draw)
|
|
Packit |
324a5c |
|