summaryrefslogtreecommitdiff
path: root/test/filter-bilinear-extents.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-09-28 22:42:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-09-29 09:46:09 +0100
commit117f643e49615295eb37af24efffd8327429cbf9 (patch)
treee28c075233c501883894c4833859cc117757279e /test/filter-bilinear-extents.c
parent3ff86a4510b718a3154b56b052be786f9495a3b0 (diff)
downloadcairo-117f643e49615295eb37af24efffd8327429cbf9.tar.gz
[test/filter-bilinear-extents] Extend testing.
First, explicitly set the filter mode to BILINEAR in case the default should ever change. And then draw a second pattern with extents that in theory are larger than the source surface in order to test handling of acquiring out-of-bounds extents.
Diffstat (limited to 'test/filter-bilinear-extents.c')
-rw-r--r--test/filter-bilinear-extents.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/test/filter-bilinear-extents.c b/test/filter-bilinear-extents.c
index 666b7b33a..53789abba 100644
--- a/test/filter-bilinear-extents.c
+++ b/test/filter-bilinear-extents.c
@@ -54,34 +54,51 @@ static const cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- cairo_surface_t *checker;
+ cairo_surface_t *image;
cairo_t *cr2;
- /* Create a 2x2 blue+red checker */
- checker = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 2);
- cr2 = cairo_create (checker);
+ image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 2, 2);
- cairo_set_source_rgb (cr2, 1, 0 ,0); /* red */
+ /* Fill with an opaque background to avoid a separate rgb24 ref image */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+
+ /* First check handling of pattern extents > surface extents */
+ cairo_save (cr);
+ cairo_scale (cr, width/2., height/2.);
+
+ /* Create a solid black source to merge with the background */
+ cr2 = cairo_create (image);
+ cairo_set_source_rgb (cr2, 0, 0 ,0);
cairo_paint (cr2);
- cairo_set_source_rgb (cr2, 0, 0, 1); /* blue */
- cairo_rectangle (cr2, 0, 1, 1, 1);
- cairo_rectangle (cr2, 1, 0, 1, 1);
- cairo_fill (cr2);
+ cairo_set_source_surface (cr, cairo_get_target (cr2), 0, 0);
cairo_destroy (cr2);
-
- /* Draw our surface scaled with EXTEND_NONE */
- cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BILINEAR);
cairo_paint (cr);
+ cairo_restore (cr);
+ /* Then scale to smaller so we can see the full bilinear extents */
cairo_save (cr);
cairo_translate (cr, PAD, PAD);
cairo_scale (cr, SCALE, SCALE);
cairo_translate (cr, 0.5, 0.5);
- cairo_set_source_surface (cr, checker, 0, 0);
+
+ /* Create a 2x2 blue+red checkerboard source */
+ cr2 = cairo_create (image);
+ cairo_set_source_rgb (cr2, 1, 0 ,0); /* red */
+ cairo_paint (cr2);
+ cairo_set_source_rgb (cr2, 0, 0, 1); /* blue */
+ cairo_rectangle (cr2, 0, 1, 1, 1);
+ cairo_rectangle (cr2, 1, 0, 1, 1);
+ cairo_fill (cr2);
+ cairo_set_source_surface (cr, cairo_get_target (cr2), 0, 0);
+ cairo_destroy (cr2);
+
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BILINEAR);
cairo_paint (cr);
cairo_restore (cr);
- cairo_surface_destroy (checker);
+ cairo_surface_destroy (image);
return CAIRO_TEST_SUCCESS;
}