summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.sources2
-rw-r--r--test/raster-source.c (renamed from test/mime-surface.c)90
-rw-r--r--test/reference/raster-source.base.argb32.ref.png (renamed from test/reference/mime-surface.base.argb32.ref.png)bin1209 -> 1209 bytes
-rw-r--r--test/reference/raster-source.base.rgb24.ref.png (renamed from test/reference/mime-surface.base.rgb24.ref.png)bin1209 -> 1209 bytes
-rw-r--r--test/reference/raster-source.ref.png (renamed from test/reference/mime-surface.ref.png)bin1209 -> 1209 bytes
-rw-r--r--test/reference/raster-source.traps.argb32.ref.png (renamed from test/reference/mime-surface.traps.argb32.ref.png)bin1209 -> 1209 bytes
-rw-r--r--test/reference/raster-source.traps.rgb24.ref.png (renamed from test/reference/mime-surface.traps.rgb24.ref.png)bin1209 -> 1209 bytes
7 files changed, 26 insertions, 66 deletions
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 8acc266e..2d356667 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -203,7 +203,6 @@ test_sources = \
mesh-pattern-overlap.c \
mesh-pattern-transformed.c \
mime-data.c \
- mime-surface.c \
mime-surface-api.c \
miter-precision.c \
move-to-show-surface.c \
@@ -247,6 +246,7 @@ test_sources = \
random-intersections-nonzero.c \
random-intersections-curves-eo.c \
random-intersections-curves-nz.c \
+ raster-source.c \
record.c \
record-extend.c \
record-mesh.c \
diff --git a/test/mime-surface.c b/test/raster-source.c
index d59112f2..5a7646e8 100644
--- a/test/mime-surface.c
+++ b/test/raster-source.c
@@ -49,41 +49,37 @@ png_dimensions (const char *filename,
}
static cairo_surface_t *
-png_acquire (cairo_surface_t *mime_surface, void *closure,
- cairo_surface_t *target, const cairo_rectangle_int_t *roi,
- cairo_rectangle_int_t *extents)
+png_acquire (cairo_pattern_t *pattern, void *closure,
+ cairo_surface_t *target,
+ const cairo_rectangle_int_t *extents)
{
- cairo_surface_t *image;
-
- image = cairo_image_surface_create_from_png (closure);
- extents->x = extents->y = 0;
- extents->width = cairo_image_surface_get_width (image);
- extents->height = cairo_image_surface_get_height (image);
- return image;
+ return cairo_image_surface_create_from_png (closure);
}
static cairo_surface_t *
-red_acquire (cairo_surface_t *mime_surface, void *closure,
- cairo_surface_t *target, const cairo_rectangle_int_t *roi,
- cairo_rectangle_int_t *extents)
+red_acquire (cairo_pattern_t *pattern, void *closure,
+ cairo_surface_t *target,
+ const cairo_rectangle_int_t *extents)
{
cairo_surface_t *image;
cairo_t *cr;
image = cairo_surface_create_similar_image (target,
CAIRO_FORMAT_RGB24,
- roi->width, roi->height);
+ extents->width,
+ extents->height);
+ cairo_surface_set_device_offset (image, extents->x, extents->y);
+
cr = cairo_create (image);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
- *extents = *roi;
return image;
}
static void
-release (cairo_surface_t *mime_surface, void *closure, cairo_surface_t *image)
+release (cairo_pattern_t *pattern, void *closure, cairo_surface_t *image)
{
cairo_surface_destroy (image);
}
@@ -92,18 +88,20 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const char *png_filename = "png.png";
- cairo_surface_t *png, *red;
+ cairo_pattern_t *png, *red;
cairo_content_t content;
int png_width, png_height;
int i, j;
png_dimensions (png_filename, &content, &png_width, &png_height);
- png = cairo_mime_surface_create ((void*)png_filename, content, png_width, png_height);
- cairo_mime_surface_set_acquire (png, png_acquire, release);
+ png = cairo_pattern_create_raster_source ((void*)png_filename,
+ content, png_width, png_height);
+ cairo_raster_source_pattern_set_acquire (png, png_acquire, release);
- red = cairo_mime_surface_create (NULL, CAIRO_CONTENT_COLOR, WIDTH, HEIGHT);
- cairo_mime_surface_set_acquire (red, red_acquire, release);
+ red = cairo_pattern_create_raster_source (NULL,
+ CAIRO_CONTENT_COLOR, WIDTH, HEIGHT);
+ cairo_raster_source_pattern_set_acquire (red, red_acquire, release);
cairo_set_source_rgb (cr, 0, 0, 1);
cairo_paint (cr);
@@ -111,64 +109,26 @@ draw (cairo_t *cr, int width, int height)
cairo_translate (cr, 0, (HEIGHT-png_height)/2);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
- cairo_surface_t *source;
+ cairo_pattern_t *source;
if ((i ^ j) & 1)
source = red;
else
source = png;
- cairo_set_source_surface (cr, source, 0, 0);
+ cairo_set_source (cr, source);
cairo_rectangle (cr, i * WIDTH/4, j * png_height/4, WIDTH/4, png_height/4);
cairo_fill (cr);
}
}
- cairo_surface_destroy (red);
- cairo_surface_destroy (png);
-
- return CAIRO_TEST_SUCCESS;
-}
-
-static cairo_test_status_t
-check_status (const cairo_test_context_t *ctx,
- cairo_status_t status,
- cairo_status_t expected)
-{
- if (status == expected)
- return CAIRO_TEST_SUCCESS;
-
- cairo_test_log (ctx,
- "Error: Expected status value %d (%s), received %d (%s)\n",
- expected,
- cairo_status_to_string (expected),
- status,
- cairo_status_to_string (status));
- return CAIRO_TEST_FAILURE;
-}
-
-static cairo_test_status_t
-preamble (cairo_test_context_t *ctx)
-{
- cairo_surface_t *mime;
- cairo_status_t status;
- cairo_t *cr;
-
- /* drawing to a mime-surface is verboten */
-
- mime = cairo_mime_surface_create (NULL, CAIRO_CONTENT_COLOR, 0, 0);
- cr = cairo_create (mime);
- cairo_surface_destroy (mime);
- status = cairo_status (cr);
- cairo_destroy (cr);
- status = check_status (ctx, status, CAIRO_STATUS_WRITE_ERROR);
- if (status)
- return status;
+ cairo_pattern_destroy (red);
+ cairo_pattern_destroy (png);
return CAIRO_TEST_SUCCESS;
}
-CAIRO_TEST (mime_surface,
+CAIRO_TEST (raster_source,
"Check that the mime-surface embedding works",
"api", /* keywords */
NULL, /* requirements */
WIDTH, HEIGHT,
- preamble, draw)
+ NULL, draw)
diff --git a/test/reference/mime-surface.base.argb32.ref.png b/test/reference/raster-source.base.argb32.ref.png
index ac5e5606..ac5e5606 100644
--- a/test/reference/mime-surface.base.argb32.ref.png
+++ b/test/reference/raster-source.base.argb32.ref.png
Binary files differ
diff --git a/test/reference/mime-surface.base.rgb24.ref.png b/test/reference/raster-source.base.rgb24.ref.png
index ac5e5606..ac5e5606 100644
--- a/test/reference/mime-surface.base.rgb24.ref.png
+++ b/test/reference/raster-source.base.rgb24.ref.png
Binary files differ
diff --git a/test/reference/mime-surface.ref.png b/test/reference/raster-source.ref.png
index ac5e5606..ac5e5606 100644
--- a/test/reference/mime-surface.ref.png
+++ b/test/reference/raster-source.ref.png
Binary files differ
diff --git a/test/reference/mime-surface.traps.argb32.ref.png b/test/reference/raster-source.traps.argb32.ref.png
index ac5e5606..ac5e5606 100644
--- a/test/reference/mime-surface.traps.argb32.ref.png
+++ b/test/reference/raster-source.traps.argb32.ref.png
Binary files differ
diff --git a/test/reference/mime-surface.traps.rgb24.ref.png b/test/reference/raster-source.traps.rgb24.ref.png
index ac5e5606..ac5e5606 100644
--- a/test/reference/mime-surface.traps.rgb24.ref.png
+++ b/test/reference/raster-source.traps.rgb24.ref.png
Binary files differ