surface-pattern-scale-down-extend.c [plain text]
#include "cairo-test.h"
static cairo_test_status_t
draw_with_extend (cairo_t *cr, int w, int h, cairo_extend_t extend)
{
cairo_pattern_t *pattern;
cairo_set_source_rgb (cr, 1,1,1);
cairo_paint (cr);
cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR); {
cairo_set_source_rgb (cr, 1,0,0);
cairo_rectangle (cr, w/2, 0, w-w/2, h/2);
cairo_fill (cr);
cairo_set_source_rgb (cr, 1,1,0);
cairo_rectangle (cr, 0, h/2, w/2, h-h/2);
cairo_fill (cr);
}
pattern = cairo_pop_group (cr);
cairo_pattern_set_extend(pattern, extend);
cairo_scale (cr, 0.5, 0.5);
cairo_set_source (cr, pattern);
cairo_paint (cr);
cairo_pattern_destroy (pattern);
return CAIRO_TEST_SUCCESS;
}
static cairo_test_status_t
draw_repeat (cairo_t *cr, int w, int h)
{
return draw_with_extend (cr, w, h, CAIRO_EXTEND_REPEAT);
}
static cairo_test_status_t
draw_none (cairo_t *cr, int w, int h)
{
return draw_with_extend (cr, w, h, CAIRO_EXTEND_NONE);
}
static cairo_test_status_t
draw_reflect (cairo_t *cr, int w, int h)
{
return draw_with_extend (cr, w, h, CAIRO_EXTEND_REFLECT);
}
static cairo_test_status_t
draw_pad (cairo_t *cr, int w, int h)
{
return draw_with_extend (cr, w, h, CAIRO_EXTEND_PAD);
}
CAIRO_TEST (surface_pattern_scale_down_extend_repeat,
"Test interaction of downscaling a surface pattern and extend-repeat",
"pattern, transform, extend",
NULL,
100, 100,
NULL, draw_repeat)
CAIRO_TEST (surface_pattern_scale_down_extend_none,
"Test interaction of downscaling a surface pattern and extend-none",
"pattern, transform, extend",
NULL,
100, 100,
NULL, draw_none)
CAIRO_TEST (surface_pattern_scale_down_extend_reflect,
"Test interaction of downscaling a surface pattern and extend-reflect",
"pattern, transform, extend",
NULL,
100, 100,
NULL, draw_reflect)
CAIRO_TEST (surface_pattern_scale_down_extend_pad,
"Test interaction of downscaling a surface pattern and extend-pad",
"pattern, transform, extend",
NULL,
100, 100,
NULL, draw_pad)