diff options
author | Carl Worth <cworth@cworth.org> | 2006-08-17 10:37:46 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-08-17 13:35:15 -0700 |
commit | 64d2feb9f62d32f8189ea6a43420782e0c4a9373 (patch) | |
tree | 6c40ab15f6ce7ce8d8cd915c4d1b984db1b894a4 | |
parent | 524507c39f2f495af426a8c41c6311efe3eb633f (diff) |
Harmonize implementations of source-clip and source-clip-scale to make similarities more evident.
-rw-r--r-- | test/.gitignore | 1 | ||||
-rw-r--r-- | test/source-clip-ref.png | bin | 180 -> 133 bytes | |||
-rw-r--r-- | test/source-clip-scale-ref.png | bin | 243 -> 161 bytes | |||
-rw-r--r-- | test/source-clip-scale.c | 56 | ||||
-rw-r--r-- | test/source-clip.c | 38 |
5 files changed, 42 insertions, 53 deletions
diff --git a/test/.gitignore b/test/.gitignore index 51ed65cce..40332f92a 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -102,6 +102,7 @@ set-source show-glyphs-many show-text-current-point source-clip +source-clip-scale source-surface-scale-paint surface-finish-twice surface-pattern diff --git a/test/source-clip-ref.png b/test/source-clip-ref.png Binary files differindex 8df2bff97..22454bed9 100644 --- a/test/source-clip-ref.png +++ b/test/source-clip-ref.png diff --git a/test/source-clip-scale-ref.png b/test/source-clip-scale-ref.png Binary files differindex 972f41d67..1519ff895 100644 --- a/test/source-clip-scale-ref.png +++ b/test/source-clip-scale-ref.png diff --git a/test/source-clip-scale.c b/test/source-clip-scale.c index a7857101b..cc2496911 100644 --- a/test/source-clip-scale.c +++ b/test/source-clip-scale.c @@ -27,13 +27,13 @@ #include "cairo-test.h" #include <stdio.h> -#define SIZE 40 +#define SIZE 12 static cairo_test_draw_function_t draw; cairo_test_t test = { "source-clip-scale", - "Test a leftover clip on a source surface not affecting compositing", + "Test that a source surface is not affected by a clip when scaling", SIZE * 2, SIZE, draw }; @@ -41,54 +41,44 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - cairo_surface_t *surf2; + cairo_surface_t *source; cairo_t *cr2; - /* cr: Fill the destination with our red background that should - * get covered - */ - cairo_set_source_rgb (cr, 1, 0, 0); - cairo_paint (cr); - - surf2 = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, SIZE, SIZE); - cr2 = cairo_create (surf2); + source = cairo_surface_create_similar (cairo_get_target (cr), + CAIRO_CONTENT_COLOR_ALPHA, + SIZE, SIZE); + cr2 = cairo_create (source); - /* cr2: Fill temp surface with green */ + /* Fill the source surface with green */ cairo_set_source_rgb (cr2, 0, 1, 0); cairo_paint (cr2); - /* cr2: Make a blue square in the middle */ - cairo_set_source_rgb (cr2, 0, 0, 2); + /* Draw a blue square in the middle of the source with clipping. + * Note that we are only clipping within a save/restore block but + * the buggy behavior demonstrates that the clip remains present + * on the surface. */ cairo_save (cr2); - cairo_new_path (cr2); - cairo_rectangle (cr2, 10, 10, SIZE-20, SIZE-20); + cairo_rectangle (cr2, + SIZE / 4, SIZE / 4, + SIZE / 2, SIZE / 2); cairo_clip (cr2); + cairo_set_source_rgb (cr2, 0, 0, 1); cairo_paint (cr2); cairo_restore (cr2); - /* If this is uncommented, the test works as expected, because this - * forces the clip to be reset on surf2. - */ - /* - cairo_new_path (cr2); - cairo_rectangle (cr2, 0, 0, 0, 0); - cairo_fill (cr2); - */ + /* Fill the destination surface with solid red (should not appear + * in final result) */ + cairo_set_source_rgb (cr, 1, 0, 0); + cairo_paint (cr); - /* If this scale is commented out, the test displays - * the green-and-blue square on the left side of the result. - * - * The correct "pass" image is the green-and-blue square image stretched - * by 2x. With this scale, however, only the blue (clipped) portion - * of the src shows through. - */ + /* Now draw the source surface onto the destination with scaling. */ cairo_scale (cr, 2.0, 1.0); - cairo_set_source_surface (cr, surf2, 0, 0); + cairo_set_source_surface (cr, source, 0, 0); cairo_paint (cr); cairo_destroy (cr2); - cairo_surface_destroy (surf2); + cairo_surface_destroy (source); return CAIRO_TEST_SUCCESS; } diff --git a/test/source-clip.c b/test/source-clip.c index 4243bf0cd..cb9386a3c 100644 --- a/test/source-clip.c +++ b/test/source-clip.c @@ -27,13 +27,13 @@ #include "cairo-test.h" #include <stdio.h> -#define SIZE 50 +#define SIZE 12 static cairo_test_draw_function_t draw; cairo_test_t test = { "source-clip", - "Test using a surface with an active clip as a source", + "Test that a source surface is not affected by a clip", SIZE, SIZE, draw }; @@ -41,43 +41,41 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - cairo_pattern_t *pattern; - cairo_surface_t *source_surface; + cairo_surface_t *source; cairo_t *cr2; - source_surface = cairo_surface_create_similar (cairo_get_target (cr), - CAIRO_CONTENT_COLOR_ALPHA, - SIZE, SIZE); + source = cairo_surface_create_similar (cairo_get_target (cr), + CAIRO_CONTENT_COLOR_ALPHA, + SIZE, SIZE); - cr2 = cairo_create (source_surface); + cr2 = cairo_create (source); - /* Fill the source surface with solid black */ - cairo_set_source_rgb (cr2, 0, 0, 0); + /* Fill the source surface with green */ + cairo_set_source_rgb (cr2, 0, 1, 0); cairo_paint (cr2); - /* Now leave a clip in place */ + /* Draw a blue square in the middle of the source with clipping, + * and leave the clip there. */ cairo_rectangle (cr2, SIZE / 4, SIZE / 4, SIZE / 2, SIZE / 2); cairo_clip (cr2); + cairo_set_source_rgb (cr2, 0, 0, 1); + cairo_paint (cr2); - /* Fill the destination surface with solid white */ - cairo_set_source_rgb (cr, 1, 1, 1); + /* Fill the destination surface with solid red (should not appear + * in final result) */ + cairo_set_source_rgb (cr, 1, 0, 0); cairo_paint (cr); /* Now draw the source surface onto the destination surface */ - pattern = cairo_pattern_create_for_surface (source_surface); - cairo_set_source (cr, pattern); + cairo_set_source_surface (cr, source, 0, 0); cairo_paint (cr); - /* As the clip shouldn't matter, the result should be solid black */ - cairo_destroy (cr2); - cairo_pattern_destroy (pattern); - cairo_surface_destroy (source_surface); + cairo_surface_destroy (source); return CAIRO_TEST_SUCCESS; - } int |