summaryrefslogtreecommitdiff
path: root/test/source-clip.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-08-17 10:37:46 -0700
committerCarl Worth <cworth@cworth.org>2006-08-17 13:35:15 -0700
commit64d2feb9f62d32f8189ea6a43420782e0c4a9373 (patch)
tree6c40ab15f6ce7ce8d8cd915c4d1b984db1b894a4 /test/source-clip.c
parent524507c39f2f495af426a8c41c6311efe3eb633f (diff)
downloadcairo-64d2feb9f62d32f8189ea6a43420782e0c4a9373.tar.gz
Harmonize implementations of source-clip and source-clip-scale to make similarities more evident.
Diffstat (limited to 'test/source-clip.c')
-rw-r--r--test/source-clip.c38
1 files changed, 18 insertions, 20 deletions
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