diff --git a/ChangeLog b/ChangeLog index 0c5026e87..b842c16e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,146 @@ +2006-01-17 Carl Worth + + Big change to the test infrastructure and supporting + internals. The goal now is to test both a COLOR_ALPHA and a COLOR + content for each surface backend, (since the semantics are + different and we probably need to support both in each backend. + + The PS/PDF backends don't allow a content to be passed in right + now, so they fail against the rgb24 tests, but the trivial + addition to the constructors will allow them to pass all tests + with both content values. + + * src/cairoint.h: + * src/cairo-image-surface.c: + (_cairo_image_surface_create_with_content), + (_cairo_image_surface_create_for_data_with_content), + (_cairo_image_surface_create_similar): And new constructors + (currently internal only) to create an image surface with a + cairo_content_t rather than a cairo_format_t. + + * src/cairo-meta-surface-private.h: + * src/cairo-meta-surface.c: (_cairo_meta_surface_create), + (_cairo_meta_surface_create_similar): Add a cairo_content_t + argument to the constructor. + + * src/cairo-paginated-surface-private.h: + * src/cairo-paginated-surface.c: (_cairo_paginated_surface_create), + (_cairo_paginated_surface_acquire_source_image), (_paint_page), + (_cairo_paginated_surface_show_page), + (_cairo_paginated_surface_snapshot): Add a cairo_content_t to the + constructor and use this content value when constructing + intermediate image surfaces in acquire_source, show_page, + copy_page, and snapshot. + + * src/cairo-pdf-surface.c: (emit_image_rgb_data), + (_cairo_pdf_surface_composite_image), (emit_surface_pattern): Add + image flattening by compositing over white, as is done in + cairo-ps-surface.c. + + * src/cairo-ps-surface.c: + (_cairo_ps_surface_create_for_stream_internal), + (cairo_ps_surface_create), (cairo_ps_surface_create_for_stream): + * src/cairo-pdf-surface.c: + (_cairo_pdf_surface_create_for_stream_internal), + (cairo_pdf_surface_create_for_stream), (cairo_pdf_surface_create), + Track changes to cairo-paginates-surface which now requires a + cairo_content_t value (no change to public PS/PDF constructors + yet). + + * src/test-fallback-surface.h: + * src/test-fallback-surface.c: (_test_fallback_surface_create), + (_test_fallback_surface_create_similar): + * src/test-meta-surface.h: + * src/test-meta-surface.c: (_test_meta_surface_create): + * src/test-paginated-surface.h: + * src/test-paginated-surface.c: + (_test_paginated_surface_create_for_data): Track change in + meta-surface and paginated-surface interfaces by now accepting a + cairo_content_t rather than a cairo_format_t. + + * test/.cvsignore: Ignore new output files (argb32 from pdf and ps + as well as rgb24 from test-fallback, test-meta, and + test-paginated). + + * test/Makefile.am: + * test/png-flatten.c: (main): Add new utility for flattening PNG + images in order to generate the -argbf-ref.png images. + + * test/buffer-diff.c: (image_diff_flattened): + * test/buffer-diff.h: Add image_diff_flattened for comparing + flattened output from PS and PDF backend with ARGB reference + images by first blending the reference images over white. + + * test/cairo-test.c: (_cairo_test_content_name), + (create_image_surface), (create_test_fallback_surface), + (create_test_meta_surface), (create_test_paginated_surface), + (test_paginated_write_to_png), (create_cairo_glitz_glx_surface), + (create_cairo_glitz_agl_surface), (create_cairo_glitz_wgl_surface), + (create_win32_surface), (create_xcb_surface), + (create_xlib_surface), (create_ps_surface), (create_pdf_surface), + (create_svg_surface), (cairo_test_for_target), + (cairo_test_expecting): Get rid of conditional, format-specific + background-color initialization before running tests. Now uses + ARGB(0,0,0,0) in all cases. Switch from specifying tests with a + format value to specifying tests with a content value. Add support + for a 'fake' COLOR_ALPHA_FLATTENED content for testing the PS and + PDF output against a flattened version of the argb32 reference + images (first blended over white). + + * test/multi-page.c: (main): Track change in + cairo_ps_surface_create (now requires cairo_content_t value). + + * test/caps-joins.c: (draw): + * test/caps-sub-paths.c: (draw): + * test/dash-caps-joins.c: (draw): + * test/dash-offset-negative.c: (draw): + * test/leaky-polygon.c: (draw): + * test/line-width.c: (draw): + * test/path-data.c: (draw): + * test/show-text-current-point.c: (draw): + * test/text-antialias-gray.c: (draw): + * test/text-antialias-none.c: (draw): + * test/transforms.c: (draw): Adjust tests that draw in default + (black) to first paint white so that the results are visible. + + * test/caps-joins-ref.png: + * test/caps-sub-paths-ref.png: + * test/dash-caps-joins-ref.png: + * test/dash-offset-negative-ref.png: + * test/leaky-polygon-ref.png: + * test/line-width-ref.png: + * test/path-data-ref.png: + * test/show-text-current-point-ref.png: + * test/text-antialias-gray-ref.png: + * test/text-antialias-none-ref.png: + * test/transforms-ref.png: Adjust ARGB32 reference images for new + white background for changed tests. + + * test/clip-fill-rule-pixel-aligned-rgb24-ref.png: + * test/clip-fill-rule-rgb24-ref.png: + * test/clip-nesting-rgb24-ref.png: + * test/clip-operator-rgb24-ref.png: + * test/clip-twice-rgb24-ref.png: + * test/fill-and-stroke-rgb24-ref.png: + * test/fill-rule-rgb24-ref.png: + * test/gradient-alpha-rgb24-ref.png: + * test/mask-ctm-rgb24-ref.png: + * test/mask-rgb24-ref.png: + * test/mask-surface-ctm-rgb24-ref.png: + * test/nil-surface-rgb24-ref.png: + * test/operator-clear-rgb24-ref.png: + * test/operator-source-rgb24-ref.png: + * test/paint-with-alpha-rgb24-ref.png: + * test/rel-path-rgb24-ref.png: + * test/scale-source-surface-paint-rgb24-ref.png: + * test/set-source-rgb24-ref.png: + * test/source-surface-scale-paint-rgb24-ref.png: + * test/text-pattern-rgb24-ref.png: + * test/trap-clip-rgb24-ref.png: + * test/unbounded-operator-rgb24-ref.png: Adjust RGB24 reference + images for new black background due to changed initialization (and + the tests themselves being unchanged). + 2006-01-14 Christian Biesinger * test/mask-beos-rgb24-ref.png: diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 329590d16..88c0b5e61 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -232,6 +232,18 @@ cairo_image_surface_create (cairo_format_t format, return surface; } +cairo_surface_t * +_cairo_image_surface_create_with_content (cairo_content_t content, + int width, + int height) +{ + if (! CAIRO_CONTENT_VALID (content)) + return (cairo_surface_t*) &_cairo_surface_nil; + + return cairo_image_surface_create (_cairo_format_from_content (content), + width, height); +} + /** * cairo_image_surface_create_for_data: * @data: a pointer to a buffer supplied by the application @@ -296,6 +308,21 @@ cairo_image_surface_create_for_data (unsigned char *data, return surface; } +cairo_surface_t * +_cairo_image_surface_create_for_data_with_content (unsigned char *data, + cairo_content_t content, + int width, + int height, + int stride) +{ + if (! CAIRO_CONTENT_VALID (content)) + return (cairo_surface_t*) &_cairo_surface_nil; + + return cairo_image_surface_create_for_data (data, + _cairo_format_from_content (content), + width, height, stride); +} + /** * cairo_image_surface_get_width: * @surface: a #cairo_image_surface_t @@ -379,8 +406,8 @@ _cairo_image_surface_create_similar (void *abstract_src, { assert (CAIRO_CONTENT_VALID (content)); - return cairo_image_surface_create (_cairo_format_from_content (content), - width, height); + return _cairo_image_surface_create_with_content (content, + width, height); } static cairo_status_t diff --git a/src/cairo-meta-surface-private.h b/src/cairo-meta-surface-private.h index cedf7a3eb..e57150904 100644 --- a/src/cairo-meta-surface-private.h +++ b/src/cairo-meta-surface-private.h @@ -127,6 +127,8 @@ typedef union _cairo_command { typedef struct _cairo_meta_surface { cairo_surface_t base; + cairo_content_t content; + /* A meta-surface is logically unbounded, but when used as a * source we need to render it to an image, so we need a size at * which to create that image. */ @@ -138,7 +140,9 @@ typedef struct _cairo_meta_surface { } cairo_meta_surface_t; cairo_private cairo_surface_t * -_cairo_meta_surface_create (int width_pixels, int height_pixels); +_cairo_meta_surface_create (cairo_content_t content, + int width_pixels, + int height_pixels); cairo_private cairo_status_t _cairo_meta_surface_replay (cairo_surface_t *surface, diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index 408e3b000..a314150bc 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -60,7 +60,9 @@ static const cairo_surface_backend_t cairo_meta_surface_backend; cairo_surface_t * -_cairo_meta_surface_create (int width_pixels, int height_pixels) +_cairo_meta_surface_create (cairo_content_t content, + int width_pixels, + int height_pixels) { cairo_meta_surface_t *meta; @@ -72,6 +74,7 @@ _cairo_meta_surface_create (int width_pixels, int height_pixels) _cairo_surface_init (&meta->base, &cairo_meta_surface_backend); + meta->content = content; meta->width_pixels = width_pixels; meta->height_pixels = height_pixels; @@ -87,7 +90,7 @@ _cairo_meta_surface_create_similar (void *abstract_surface, int width, int height) { - return _cairo_meta_surface_create (width, height); + return _cairo_meta_surface_create (content, width, height); } static cairo_status_t diff --git a/src/cairo-paginated-surface-private.h b/src/cairo-paginated-surface-private.h index eef07178f..2f918293b 100644 --- a/src/cairo-paginated-surface-private.h +++ b/src/cairo-paginated-surface-private.h @@ -40,6 +40,7 @@ cairo_private cairo_surface_t * _cairo_paginated_surface_create (cairo_surface_t *target, + cairo_content_t content, int width, int height); diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 6e9720538..99d7fa934 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -72,6 +72,8 @@ typedef struct _cairo_paginated_surface { cairo_surface_t base; + cairo_content_t content; + /* XXX: These shouldn't actually exist. We inherit this ugliness * from _cairo_meta_surface_create. The width/height parameters * from that function also should not exist. The fix that will @@ -97,6 +99,7 @@ _cairo_paginated_surface_show_page (void *abstract_surface); cairo_surface_t * _cairo_paginated_surface_create (cairo_surface_t *target, + cairo_content_t content, int width, int height) { @@ -108,12 +111,13 @@ _cairo_paginated_surface_create (cairo_surface_t *target, _cairo_surface_init (&surface->base, &cairo_paginated_surface_backend); + surface->content = content; surface->width = width; surface->height = height; surface->target = target; - surface->meta = _cairo_meta_surface_create (width, height); + surface->meta = _cairo_meta_surface_create (content, width, height); if (cairo_surface_status (surface->meta)) goto FAIL_CLEANUP_SURFACE; @@ -166,8 +170,9 @@ _cairo_paginated_surface_acquire_source_image (void *abstract_surface, _cairo_surface_get_extents (surface->target, &extents); - image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - extents.width, extents.height); + image = _cairo_image_surface_create_with_content (surface->content, + extents.width, + extents.height); _cairo_meta_surface_replay (surface->meta, image); @@ -191,8 +196,9 @@ _paint_page (cairo_paginated_surface_t *surface) cairo_surface_t *image; cairo_pattern_t *pattern; - image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - surface->width, surface->height); + image = _cairo_image_surface_create_with_content (surface->content, + surface->width, + surface->height); _cairo_meta_surface_replay (surface->meta, image); @@ -236,7 +242,8 @@ _cairo_paginated_surface_show_page (void *abstract_surface) cairo_surface_destroy (surface->meta); - surface->meta = _cairo_meta_surface_create (surface->width, surface->height); + surface->meta = _cairo_meta_surface_create (surface->content, + surface->width, surface->height); if (cairo_surface_status (surface->meta)) return cairo_surface_status (surface->meta); @@ -362,9 +369,9 @@ _cairo_paginated_surface_snapshot (void *abstract_other) _cairo_surface_get_extents (other->target, &extents); - surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - extents.width, - extents.height); + surface = _cairo_image_surface_create_with_content (other->content, + extents.width, + extents.height); _cairo_meta_surface_replay (other->meta, surface); diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index a562f7e9a..cf0087c0a 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -287,8 +287,9 @@ _cairo_pdf_surface_add_font (cairo_pdf_surface_t *surface, unsigned int id) static cairo_surface_t * _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *stream, - double width, - double height) + cairo_content_t content, + double width, + double height) { cairo_pdf_document_t *document; cairo_surface_t *target; @@ -304,14 +305,14 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *stream, document->owner = target; _cairo_pdf_document_destroy (document); - return _cairo_paginated_surface_create (target, width, height); + return _cairo_paginated_surface_create (target, content, width, height); } cairo_surface_t * -cairo_pdf_surface_create_for_stream (cairo_write_func_t write, +cairo_pdf_surface_create_for_stream (cairo_write_func_t write, void *closure, - double width, - double height) + double width, + double height) { cairo_output_stream_t *stream; @@ -321,13 +322,17 @@ cairo_pdf_surface_create_for_stream (cairo_write_func_t write, return (cairo_surface_t*) &_cairo_surface_nil; } - return _cairo_pdf_surface_create_for_stream_internal (stream, width, height); + /* XXX: content here is hard-coded but should be passed in (API + * change that needs to be discussed on the list). */ + return _cairo_pdf_surface_create_for_stream_internal (stream, + CAIRO_CONTENT_COLOR_ALPHA, + width, height); } cairo_surface_t * -cairo_pdf_surface_create (const char *filename, - double width, - double height) +cairo_pdf_surface_create (const char *filename, + double width, + double height) { cairo_output_stream_t *stream; @@ -337,7 +342,11 @@ cairo_pdf_surface_create (const char *filename, return (cairo_surface_t*) &_cairo_surface_nil; } - return _cairo_pdf_surface_create_for_stream_internal (stream, width, height); + /* XXX: content here is hard-coded but should be passed in (API + * change that needs to be discussed on the list). */ + return _cairo_pdf_surface_create_for_stream_internal (stream, + CAIRO_CONTENT_COLOR_ALPHA, + width, height); } static cairo_bool_t @@ -581,9 +590,12 @@ compress_dup (const void *data, unsigned long data_size, return compressed; } +/* XXX: This should be rewritten to use the standard cairo_status_t + * return and the error paths here need to be checked for memory + * leaks. */ static unsigned int -emit_image_data (cairo_pdf_document_t *document, - cairo_image_surface_t *image) +emit_image_rgb_data (cairo_pdf_document_t *document, + cairo_image_surface_t *image) { cairo_output_stream_t *output = document->output_stream; cairo_pdf_stream_t *stream; @@ -591,17 +603,55 @@ emit_image_data (cairo_pdf_document_t *document, int i, x, y; unsigned long rgb_size, compressed_size; pixman_bits_t *pixel; + cairo_surface_t *opaque; + cairo_image_surface_t *opaque_image; + cairo_pattern_union_t pattern; rgb_size = image->height * image->width * 3; rgb = malloc (rgb_size); if (rgb == NULL) return 0; + /* XXX: We could actually output the alpha channels through PDF + * 1.4's SMask. But for now, all we support is opaque image data, + * so we must flatten any ARGB image by blending over white + * first. */ + if (image->format != CAIRO_FORMAT_RGB24) { + opaque = cairo_image_surface_create (CAIRO_FORMAT_RGB24, + image->width, + image->height); + if (opaque->status) + return 0; + + _cairo_pattern_init_for_surface (&pattern.surface, &image->base); + + _cairo_surface_fill_rectangle (opaque, + CAIRO_OPERATOR_SOURCE, + CAIRO_COLOR_WHITE, + 0, 0, image->width, image->height); + + _cairo_surface_composite (CAIRO_OPERATOR_OVER, + &pattern.base, + NULL, + opaque, + 0, 0, + 0, 0, + 0, 0, + image->width, + image->height); + + _cairo_pattern_fini (&pattern.base); + opaque_image = (cairo_image_surface_t *) opaque; + } else { + opaque = &image->base; + opaque_image = image; + } + i = 0; for (y = 0; y < image->height; y++) { - pixel = (pixman_bits_t *) (image->data + y * image->stride); + pixel = (pixman_bits_t *) (opaque_image->data + y * opaque_image->stride); - for (x = 0; x < image->width; x++, pixel++) { + for (x = 0; x < opaque_image->width; x++, pixel++) { rgb[i++] = (*pixel & 0x00ff0000) >> 16; rgb[i++] = (*pixel & 0x0000ff00) >> 8; rgb[i++] = (*pixel & 0x000000ff) >> 0; @@ -634,6 +684,9 @@ emit_image_data (cairo_pdf_document_t *document, free (rgb); free (compressed); + if (opaque_image != image) + cairo_surface_destroy (opaque); + return stream->id; } @@ -655,7 +708,7 @@ _cairo_pdf_surface_composite_image (cairo_pdf_surface_t *dst, if (status) return status; - id = emit_image_data (dst->document, image); + id = emit_image_rgb_data (dst->document, image); if (id == 0) { status = CAIRO_STATUS_NO_MEMORY; goto bail; @@ -835,7 +888,7 @@ emit_surface_pattern (cairo_pdf_surface_t *dst, _cairo_pdf_document_close_stream (document); - id = emit_image_data (dst->document, image); + id = emit_image_rgb_data (dst->document, image); /* BBox must be smaller than XStep by YStep or acroread wont * display the pattern. */ diff --git a/src/cairo-pdf.h b/src/cairo-pdf.h index d611fb2ca..abcab0f3f 100644 --- a/src/cairo-pdf.h +++ b/src/cairo-pdf.h @@ -44,9 +44,9 @@ CAIRO_BEGIN_DECLS cairo_public cairo_surface_t * -cairo_pdf_surface_create (const char *filename, - double width_in_points, - double height_in_points); +cairo_pdf_surface_create (const char *filename, + double width_in_points, + double height_in_points); cairo_public cairo_surface_t * cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func, diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index bf0039883..ce8fa0da1 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -122,6 +122,7 @@ _cairo_ps_surface_emit_footer (cairo_ps_surface_t *surface) static cairo_surface_t * _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream, + cairo_content_t content, double width, double height) { @@ -155,13 +156,14 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream, _cairo_ps_surface_emit_header (surface); - return _cairo_paginated_surface_create (&surface->base, width, height); + return _cairo_paginated_surface_create (&surface->base, + content, width, height); } cairo_surface_t * -cairo_ps_surface_create (const char *filename, - double width_in_points, - double height_in_points) +cairo_ps_surface_create (const char *filename, + double width_in_points, + double height_in_points) { cairo_output_stream_t *stream; @@ -171,7 +173,10 @@ cairo_ps_surface_create (const char *filename, return (cairo_surface_t*) &_cairo_surface_nil; } + /* XXX: content here is hard-coded but should be passed in (API + * change that needs to be discussed on the list). */ return _cairo_ps_surface_create_for_stream_internal (stream, + CAIRO_CONTENT_COLOR_ALPHA, width_in_points, height_in_points); } @@ -190,7 +195,10 @@ cairo_ps_surface_create_for_stream (cairo_write_func_t write_func, return (cairo_surface_t*) &_cairo_surface_nil; } + /* XXX: content here is hard-coded but should be passed in (API + * change that needs to be discussed on the list). */ return _cairo_ps_surface_create_for_stream_internal (stream, + CAIRO_CONTENT_COLOR_ALPHA, width_in_points, height_in_points); } diff --git a/src/cairo-ps.h b/src/cairo-ps.h index 036c4b2c2..0db0c0220 100644 --- a/src/cairo-ps.h +++ b/src/cairo-ps.h @@ -48,9 +48,9 @@ CAIRO_BEGIN_DECLS /* PS-surface functions */ cairo_public cairo_surface_t * -cairo_ps_surface_create (const char *filename, - double width_in_points, - double height_in_points); +cairo_ps_surface_create (const char *filename, + double width_in_points, + double height_in_points); cairo_public cairo_surface_t * cairo_ps_surface_create_for_stream (cairo_write_func_t write_func, diff --git a/src/cairoint.h b/src/cairoint.h index 2bfcd97be..352df1f4f 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1829,6 +1829,18 @@ _cairo_image_surface_create_with_masks (unsigned char *data, int height, int stride); +cairo_private cairo_surface_t * +_cairo_image_surface_create_with_content (cairo_content_t content, + int width, + int height); + +cairo_private cairo_surface_t * +_cairo_image_surface_create_for_data_with_content (unsigned char *data, + cairo_content_t content, + int width, + int height, + int stride); + cairo_private void _cairo_image_surface_assume_ownership_of_data (cairo_image_surface_t *surface); diff --git a/src/test-fallback-surface.c b/src/test-fallback-surface.c index 1f9db6734..fe0cc6fb5 100644 --- a/src/test-fallback-surface.c +++ b/src/test-fallback-surface.c @@ -65,14 +65,14 @@ typedef struct _test_fallback_surface { const cairo_private cairo_surface_backend_t test_fallback_surface_backend; cairo_surface_t * -_test_fallback_surface_create (cairo_format_t format, +_test_fallback_surface_create (cairo_content_t content, int width, int height) { test_fallback_surface_t *surface; cairo_surface_t *backing; - backing = cairo_image_surface_create (format, width, height); + backing = _cairo_image_surface_create_with_content (content, width, height); if (cairo_surface_status (backing)) return (cairo_surface_t*) &_cairo_surface_nil; @@ -97,7 +97,7 @@ _test_fallback_surface_create_similar (void *abstract_surface, { assert (CAIRO_CONTENT_VALID (content)); - return _test_fallback_surface_create (_cairo_format_from_content (content), + return _test_fallback_surface_create (content, width, height); } diff --git a/src/test-fallback-surface.h b/src/test-fallback-surface.h index f8e5a90f0..25603072e 100644 --- a/src/test-fallback-surface.h +++ b/src/test-fallback-surface.h @@ -41,7 +41,7 @@ CAIRO_BEGIN_DECLS cairo_surface_t * -_test_fallback_surface_create (cairo_format_t format, +_test_fallback_surface_create (cairo_content_t content, int width, int height); diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c index 026861929..bdabf31d3 100644 --- a/src/test-meta-surface.c +++ b/src/test-meta-surface.c @@ -68,9 +68,9 @@ static cairo_int_status_t _test_meta_surface_show_page (void *abstract_surface); cairo_surface_t * -_test_meta_surface_create (cairo_format_t format, - int width, - int height) +_test_meta_surface_create (cairo_content_t content, + int width, + int height) { test_meta_surface_t *surface; @@ -80,11 +80,12 @@ _test_meta_surface_create (cairo_format_t format, _cairo_surface_init (&surface->base, &test_meta_surface_backend); - surface->meta = _cairo_meta_surface_create (width, height); + surface->meta = _cairo_meta_surface_create (content, width, height); if (cairo_surface_status (surface->meta)) goto FAIL_CLEANUP_SURFACE; - surface->image = cairo_image_surface_create (format, width, height); + surface->image = _cairo_image_surface_create_with_content (content, + width, height); if (cairo_surface_status (surface->image)) goto FAIL_CLEANUP_META; diff --git a/src/test-meta-surface.h b/src/test-meta-surface.h index d9f5590a1..4022ab7ff 100644 --- a/src/test-meta-surface.h +++ b/src/test-meta-surface.h @@ -41,7 +41,7 @@ CAIRO_BEGIN_DECLS cairo_surface_t * -_test_meta_surface_create (cairo_format_t format, +_test_meta_surface_create (cairo_content_t content, int width, int height); diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c index 2a1510915..155f2773f 100644 --- a/src/test-paginated-surface.c +++ b/src/test-paginated-surface.c @@ -52,16 +52,17 @@ #include "cairo-paginated-surface-private.h" cairo_surface_t * -_test_paginated_surface_create_for_data (unsigned char *data, - cairo_format_t format, - int width, - int height, - int stride) +_test_paginated_surface_create_for_data (unsigned char *data, + cairo_content_t content, + int width, + int height, + int stride) { cairo_surface_t *target; - target = cairo_image_surface_create_for_data (data, format, - width, height, stride); + target = _cairo_image_surface_create_for_data_with_content (data, content, + width, height, + stride); - return _cairo_paginated_surface_create (target, width, height); + return _cairo_paginated_surface_create (target, content, width, height); } diff --git a/src/test-paginated-surface.h b/src/test-paginated-surface.h index f00a33631..df5500290 100644 --- a/src/test-paginated-surface.h +++ b/src/test-paginated-surface.h @@ -41,11 +41,11 @@ CAIRO_BEGIN_DECLS cairo_surface_t * -_test_paginated_surface_create_for_data (unsigned char *data, - cairo_format_t format, - int width, - int height, - int stride); +_test_paginated_surface_create_for_data (unsigned char *data, + cairo_content_t content, + int width, + int height, + int stride); CAIRO_END_DECLS diff --git a/test/.cvsignore b/test/.cvsignore index 625ea31da..82a713fac 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -44,6 +44,7 @@ paint paint-with-alpha path-data pdf2png +png-flatten svg2png svg-clip svg-clip.svg @@ -79,15 +80,22 @@ xlib-surface *-image-out.png *-image-argb32-out.png *-image-rgb24-out.png +*-pdf-argb32-out.png +*-pdf-argb32-out.pdf *-pdf-rgb24-out.png *-pdf-rgb24-out.pdf +*-ps-argb32-out.png +*-ps-argb32-out.ps *-ps-rgb24-out.png *-ps-rgb24-out.ps *-svg-rgb24-out.png *-svg-rgb24-out.svg *-test-fallback-argb32-out.png +*-test-fallback-rgb24-out.png *-test-meta-argb32-out.png +*-test-meta-rgb24-out.png *-test-paginated-argb32-out.png +*-test-paginated-rgb24-out.png *-xcb-out.png *-xcb-argb32-out.png *-xcb-rgb24-out.png diff --git a/test/Makefile.am b/test/Makefile.am index ec0e3aab2..0da8b5a74 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -347,8 +347,9 @@ user_data_LDADD = $(LDADDS) rel_path_LDADD = $(LDADDS) xlib_surface_LDADD = $(LDADDS) -noinst_PROGRAMS = imagediff +noinst_PROGRAMS = imagediff png-flatten imagediff_LDADD = $(LDADDS) +png_flatten_LDADD = $(LDADDS) if CAIRO_CAN_TEST_PDF_SURFACE noinst_PROGRAMS += pdf2png diff --git a/test/buffer-diff.c b/test/buffer-diff.c index 78284efcd..dd1b7c664 100644 --- a/test/buffer-diff.c +++ b/test/buffer-diff.c @@ -187,3 +187,97 @@ image_diff (const char *filename_a, return pixels_changed; } + +/* Like image_diff, but first "flatten" the contents of filename_b by + * blending over white. + * + * Yes, this is an ugly copy-and-paste of another function. I'm doing + * this for two reasons: + * + * 1) I want to rewrite all of the image_diff interfaces anyway + * (should use cairo_image_surface_create_from_png, should save + * loaded buffers for re-use). + * + * 2) Vlad has an outstanding patch against buffer-diff.c and I think + * this will be kinder to his merge pain. + */ +int +image_diff_flattened (const char *filename_a, + const char *filename_b, + const char *filename_diff) +{ + int pixels_changed; + unsigned int width_a, height_a, stride_a; + unsigned int width_b, height_b, stride_b; + unsigned char *buf_a, *buf_b, *buf_diff; + unsigned char *b_flat; + cairo_surface_t *buf_b_surface, *b_flat_surface; + cairo_t *cr; + read_png_status_t status; + + status = read_png_argb32 (filename_a, &buf_a, &width_a, &height_a, &stride_a); + if (status) + return -1; + + status = read_png_argb32 (filename_b, &buf_b, &width_b, &height_b, &stride_b); + if (status) { + free (buf_a); + return -1; + } + + if (width_a != width_b || + height_a != height_b || + stride_a != stride_b) + { + cairo_test_log ("Error: Image size mismatch: (%dx%d@%d) vs. (%dx%d@%d)\n" + " for %s vs. %s\n", + width_a, height_a, stride_a, + width_b, height_b, stride_b, + filename_a, filename_b); + free (buf_a); + free (buf_b); + return -1; + } + + buf_b_surface = cairo_image_surface_create_for_data (buf_b, + CAIRO_FORMAT_ARGB32, + width_b, height_b, + stride_b); + + buf_diff = xcalloc (stride_a * height_a, 1); + + b_flat = xcalloc (stride_b * height_b, 1); + + b_flat_surface = cairo_image_surface_create_for_data (b_flat, + CAIRO_FORMAT_ARGB32, + width_b, height_b, + stride_b); + cr = cairo_create (b_flat_surface); + + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + cairo_set_source_surface (cr, buf_b_surface, 0, 0); + cairo_paint (cr); + + cairo_destroy (cr); + cairo_surface_destroy (b_flat_surface); + cairo_surface_destroy (buf_b_surface); + + pixels_changed = buffer_diff (buf_a, b_flat, buf_diff, + width_a, height_a, stride_a); + + if (pixels_changed) { + FILE *png_file = fopen (filename_diff, "wb"); + write_png_argb32 (buf_diff, png_file, width_a, height_a, stride_a); + fclose (png_file); + } else { + xunlink (filename_diff); + } + + free (buf_a); + free (buf_b); + free (b_flat); + free (buf_diff); + + return pixels_changed; +} diff --git a/test/buffer-diff.h b/test/buffer-diff.h index 2734713a3..b9c48ed3b 100644 --- a/test/buffer-diff.h +++ b/test/buffer-diff.h @@ -59,4 +59,11 @@ image_diff (const char *filename_a, const char *filename_b, const char *filename_diff); +/* Like image_diff, but blending the contents of b over white first. */ +int +image_diff_flattened (const char *filename_a, + const char *filename_b, + const char *filename_diff); + + #endif diff --git a/test/cairo-test.c b/test/cairo-test.c index 79af9db0d..ae7375ed3 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -59,9 +59,12 @@ xunlink (const char *pathname); #define CAIRO_TEST_LOG_SUFFIX ".log" #define CAIRO_TEST_PNG_SUFFIX "-out.png" #define CAIRO_TEST_REF_SUFFIX "-ref.png" -#define CAIRO_TEST_RGB24_REF_SUFFIX "-rgb24-ref.png" #define CAIRO_TEST_DIFF_SUFFIX "-diff.png" +/* A fake format we use for the flattened ARGB output of the PS and + * PDF surfaces. */ +#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED -1 + /* Static data is messy, but we're coding for tests here, not a * general-purpose library, and it keeps the tests cleaner to avoid a * context object there, (though not a whole lot). */ @@ -147,8 +150,9 @@ xunlink (const char *pathname) } typedef cairo_surface_t * -(*cairo_test_create_target_surface_t) (cairo_test_t *test, cairo_format_t format, - void **closure); +(*cairo_test_create_target_surface_t) (cairo_test_t *test, + cairo_content_t content, + void **closure); typedef cairo_status_t (*cairo_test_write_to_png_t) (cairo_surface_t *surface, const char *filename); @@ -159,7 +163,7 @@ typedef void typedef struct _cairo_test_target { const char *name; - cairo_format_t reference_format; + cairo_content_t content; cairo_test_create_target_surface_t create_target_surface; cairo_test_write_to_png_t write_to_png; cairo_test_cleanup_target_t cleanup_target; @@ -167,22 +171,37 @@ typedef struct _cairo_test_target } cairo_test_target_t; static char * -cairo_target_format_name (const cairo_test_target_t *target) +_cairo_test_content_name (cairo_content_t content) { - char *format; - - if (target->reference_format == CAIRO_FORMAT_RGB24) - format = "rgb24"; - else - format = "argb32"; - return format; + switch (content) { + case CAIRO_CONTENT_COLOR: + return "rgb24"; + case CAIRO_CONTENT_COLOR_ALPHA: + case CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED: + return "argb32"; + default: + assert (0); /* not reached */ + return "---"; + } } static cairo_surface_t * -create_image_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_image_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { *closure = NULL; + cairo_format_t format; + + if (content == CAIRO_CONTENT_COLOR_ALPHA) { + format = CAIRO_FORMAT_ARGB32; + } else if (content == CAIRO_CONTENT_COLOR) { + format = CAIRO_FORMAT_RGB24; + } else { + assert (0); /* not reached */ + return NULL; + } + return cairo_image_surface_create (format, test->width, test->height); } @@ -193,41 +212,44 @@ create_image_surface (cairo_test_t *test, cairo_format_t format, #include "test-paginated-surface.h" static cairo_surface_t * -create_test_fallback_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_test_fallback_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { *closure = NULL; - return _test_fallback_surface_create (format, test->width, test->height); + return _test_fallback_surface_create (content, test->width, test->height); } static cairo_surface_t * -create_test_meta_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_test_meta_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { *closure = NULL; - return _test_meta_surface_create (format, test->width, test->height); + return _test_meta_surface_create (content, test->width, test->height); } static const cairo_user_data_key_t test_paginated_closure_key; typedef struct { unsigned char *data; - cairo_format_t format; + cairo_content_t content; int width; int height; int stride; } test_paginated_closure_t; static cairo_surface_t * -create_test_paginated_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_test_paginated_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { test_paginated_closure_t *tpc; cairo_surface_t *surface; *closure = tpc = xmalloc (sizeof (test_paginated_closure_t)); - tpc->format = format; + tpc->content = content; tpc->width = test->width; tpc->height = test->height; tpc->stride = test->width * 4; @@ -235,7 +257,7 @@ create_test_paginated_surface (cairo_test_t *test, cairo_format_t format, tpc->data = xcalloc (tpc->stride * test->height, 1); surface = _test_paginated_surface_create_for_data (tpc->data, - tpc->format, + tpc->content, tpc->width, tpc->height, tpc->stride); @@ -262,12 +284,25 @@ test_paginated_write_to_png (cairo_surface_t *surface, const char *filename) { cairo_surface_t *image; + cairo_format_t format; test_paginated_closure_t *tpc; tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key); + switch (tpc->content) { + case CAIRO_CONTENT_COLOR: + format = CAIRO_FORMAT_RGB24; + break; + case CAIRO_CONTENT_COLOR_ALPHA: + format = CAIRO_FORMAT_ARGB32; + break; + default: + assert (0); /* not reached */ + return CAIRO_STATUS_NO_MEMORY; + } + image = cairo_image_surface_create_for_data (tpc->data, - tpc->format, + format, tpc->width, tpc->height, tpc->stride); @@ -299,7 +334,7 @@ static const cairo_user_data_key_t glitz_closure_key; typedef struct _glitz_target_closure_base { int width; int height; - cairo_format_t format; + cairo_content_t content; } glitz_target_closure_base_t; #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE @@ -425,7 +460,7 @@ create_glitz_glx_surface (glitz_format_name_t formatname, static cairo_surface_t * create_cairo_glitz_glx_surface (cairo_test_t *test, - cairo_format_t format, + cairo_content_t content, void **closure) { int width = test->width; @@ -451,15 +486,15 @@ create_cairo_glitz_glx_surface (cairo_test_t *test, gxtc->scr = DefaultScreen(gxtc->dpy); - switch (format) { - case CAIRO_FORMAT_RGB24: + switch (content) { + case CAIRO_CONTENT_COLOR: glitz_surface = create_glitz_glx_surface (GLITZ_STANDARD_RGB24, width, height, gxtc); break; - case CAIRO_FORMAT_ARGB32: + case CAIRO_CONTENT_COLOR_ALPHA: glitz_surface = create_glitz_glx_surface (GLITZ_STANDARD_ARGB32, width, height, gxtc); break; default: - cairo_test_log ("Invalid format for glitz-glx test: %d\n", format); + cairo_test_log ("Invalid content for glitz-glx test: %d\n", content); goto FAIL_CLOSE_DISPLAY; } if (!glitz_surface) { @@ -471,7 +506,7 @@ create_cairo_glitz_glx_surface (cairo_test_t *test, gxtc->base.width = test->width; gxtc->base.height = test->height; - gxtc->base.format = format; + gxtc->base.content = content; cairo_surface_set_user_data (surface, &glitz_closure_key, gxtc, NULL); @@ -568,7 +603,7 @@ create_glitz_agl_surface (glitz_format_name_t formatname, static cairo_surface_t * create_cairo_glitz_agl_surface (cairo_test_t *test, - cairo_format_t format, + cairo_content_t content, void **closure) { glitz_surface_t *glitz_surface; @@ -579,15 +614,15 @@ create_cairo_glitz_agl_surface (cairo_test_t *test, *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t)); - switch (format) { - case CAIRO_FORMAT_RGB24: + switch (content) { + case CAIRO_CONTENT_COLOR: glitz_surface = create_glitz_agl_surface (GLITZ_STANDARD_RGB24, test->width, test->height, NULL); break; - case CAIRO_FORMAT_ARGB32: + case CAIRO_CONTENT_COLOR_ALPHA: glitz_surface = create_glitz_agl_surface (GLITZ_STANDARD_ARGB32, test->width, test->height, NULL); break; default: - cairo_test_log ("Invalid format for glitz-agl test: %d\n", format); + cairo_test_log ("Invalid content for glitz-agl test: %d\n", content); goto FAIL; } @@ -598,7 +633,7 @@ create_cairo_glitz_agl_surface (cairo_test_t *test, aglc->base.width = test->width; aglc->base.height = test->height; - aglc->base.format = format; + aglc->base.content = content; cairo_surface_set_user_data (surface, &glitz_closure_key, aglc, NULL); return surface; @@ -684,7 +719,7 @@ create_glitz_wgl_surface (glitz_format_name_t formatname, static cairo_surface_t * create_cairo_glitz_wgl_surface (cairo_test_t *test, - cairo_format_t format, + cairo_content_t content, void **closure) { glitz_surface_t *glitz_surface; @@ -695,15 +730,15 @@ create_cairo_glitz_wgl_surface (cairo_test_t *test, *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t)); - switch (format) { - case CAIRO_FORMAT_RGB24: + switch (content) { + case CAIRO_CONTENT_COLOR: glitz_surface = create_glitz_wgl_surface (GLITZ_STANDARD_RGB24, test->width, test->height, NULL); break; - case CAIRO_FORMAT_ARGB32: + case CAIRO_CONTENT_COLOR_ALPHA: glitz_surface = create_glitz_wgl_surface (GLITZ_STANDARD_ARGB32, test->width, test->height, NULL); break; default: - cairo_test_log ("Invalid format for glitz-wgl test: %d\n", format); + cairo_test_log ("Invalid content for glitz-wgl test: %d\n", content); goto FAIL; } @@ -714,7 +749,7 @@ create_cairo_glitz_wgl_surface (cairo_test_t *test, wglc->base.width = test->width; wglc->base.height = test->height; - wglc->base.format = format; + wglc->base.content = content; cairo_surface_set_user_data (surface, &glitz_closure_key, wglc, NULL); return surface; @@ -760,8 +795,9 @@ typedef struct _win32_target_closure } win32_target_closure_t; static cairo_surface_t * -create_win32_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_win32_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { int width = test->width; int height = test->height; @@ -910,6 +946,7 @@ create_xcb_surface (int width, int height, void **closure) cairo_surface_t *surface; XCBConnection *c; XCBRenderPICTFORMINFO render_format; + cairo_format_t format; *closure = xtc = xmalloc (sizeof (xcb_target_closure_t)); @@ -934,7 +971,19 @@ create_xcb_surface (int width, int height, void **closure) width, height); } - render_format = _format_from_cairo (c, CAIRO_FORMAT_ARGB32); + switch (content) { + case CAIRO_CONTENT_COLOR: + format = CAIRO_FORMAT_RGB24; + break; + case CAIRO_CONTENT_COLOR_ALPHA: + format = CAIRO_FORMAT_ARGB32; + break; + default: + cairo_test_log ("Invalid content for XCB test: %d\n", content); + return NULL; + } + + render_format = _format_from_cairo (c, format); if (render_format.id.xid == 0) return NULL; surface = cairo_xcb_surface_create_with_xrender_format (c, xtc->drawable, @@ -964,8 +1013,9 @@ typedef struct _xlib_target_closure } xlib_target_closure_t; static cairo_surface_t * -create_xlib_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_xlib_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { int width = test->width; int height = test->height; @@ -997,15 +1047,15 @@ create_xlib_surface (cairo_test_t *test, cairo_format_t format, * extension. That would probably be through another * cairo_test_target which would use an extended version of * cairo_test_xlib_disable_render. */ - switch (format) { - case CAIRO_FORMAT_ARGB32: + switch (content) { + case CAIRO_CONTENT_COLOR_ALPHA: xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); break; - case CAIRO_FORMAT_RGB24: + case CAIRO_CONTENT_COLOR: xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24); break; default: - cairo_test_log ("Invalid format for xlib test: %d\n", format); + cairo_test_log ("Invalid content for xlib test: %d\n", content); return NULL; } if (xrender_format == NULL) { @@ -1055,23 +1105,27 @@ typedef struct _ps_target_closure } ps_target_closure_t; static cairo_surface_t * -create_ps_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_ps_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { int width = test->width; int height = test->height; ps_target_closure_t *ptc; cairo_surface_t *surface; - /* This is the only format supported by the PS surface backend. */ - assert (format == CAIRO_FORMAT_RGB24); + /* Sanitize back to a real cairo_content_t value. */ + if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) + content = CAIRO_CONTENT_COLOR_ALPHA; *closure = ptc = xmalloc (sizeof (ps_target_closure_t)); ptc->width = width; ptc->height = height; - xasprintf (&ptc->filename, "%s-%s%s", test->name, "ps-rgb24-out", ".ps"); + xasprintf (&ptc->filename, "%s-ps-%s-out.ps", + test->name, _cairo_test_content_name (content)); + surface = cairo_ps_surface_create (ptc->filename, width, height); if (cairo_surface_status (surface)) { free (ptc->filename); @@ -1120,7 +1174,7 @@ typedef struct _pdf_target_closure static cairo_surface_t * create_pdf_surface (cairo_test_t *test, - cairo_format_t format, + cairo_content_t content, void **closure) { int width = test->width; @@ -1128,15 +1182,18 @@ create_pdf_surface (cairo_test_t *test, pdf_target_closure_t *ptc; cairo_surface_t *surface; - /* XXX: Is this the only format supported by the PDF surface backend? */ - assert (format == CAIRO_FORMAT_RGB24); + /* Sanitizie back to a real cairo_content_t value. */ + if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) + content = CAIRO_CONTENT_COLOR_ALPHA; *closure = ptc = xmalloc (sizeof (pdf_target_closure_t)); ptc->width = width; ptc->height = height; - xasprintf (&ptc->filename, "%s-%s%s", test->name, "pdf-rgb24-out", ".pdf"); + xasprintf (&ptc->filename, "%s-pdf-%s-out.pdf", + test->name, _cairo_test_content_name (content)); + surface = cairo_pdf_surface_create (ptc->filename, width, height); if (cairo_surface_status (surface)) { free (ptc->filename); @@ -1185,17 +1242,15 @@ typedef struct _svg_target_closure } svg_target_closure_t; static cairo_surface_t * -create_svg_surface (cairo_test_t *test, cairo_format_t format, - void **closure) +create_svg_surface (cairo_test_t *test, + cairo_content_t content, + void **closure) { int width = test->width; int height = test->height; svg_target_closure_t *ptc; cairo_surface_t *surface; - /* This is the only format supported by the PS surface backend. */ - assert (format == CAIRO_FORMAT_RGB24); - *closure = ptc = xmalloc (sizeof (svg_target_closure_t)); ptc->width = width; @@ -1255,28 +1310,28 @@ cairo_test_for_target (cairo_test_t *test, srcdir = getenv ("srcdir"); if (!srcdir) srcdir = "."; - format = cairo_target_format_name (target); + format = _cairo_test_content_name (target->content); xasprintf (&png_name, "%s-%s-%s%s", test->name, target->name, format, CAIRO_TEST_PNG_SUFFIX); xasprintf (&ref_name, "%s/%s-%s-%s%s", srcdir, test->name, target->name, format, CAIRO_TEST_REF_SUFFIX); if (access (ref_name, F_OK) != 0) { - char *ref_suffix; free (ref_name); - if (target->reference_format == CAIRO_FORMAT_RGB24) - ref_suffix = CAIRO_TEST_RGB24_REF_SUFFIX; + if (target->content == CAIRO_CONTENT_COLOR_ALPHA || + target->content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) + xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, + CAIRO_TEST_REF_SUFFIX); else - ref_suffix = CAIRO_TEST_REF_SUFFIX; - xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, - ref_suffix); + xasprintf (&ref_name, "%s/%s-%s%s", srcdir, test->name, + format,CAIRO_TEST_REF_SUFFIX); } xasprintf (&diff_name, "%s-%s-%s%s", test->name, target->name, format, CAIRO_TEST_DIFF_SUFFIX); /* Run the actual drawing code. */ - surface = (target->create_target_surface) (test, target->reference_format, &target->closure); + surface = (target->create_target_surface) (test, target->content, &target->closure); if (surface == NULL) { cairo_test_log ("Error: Failed to set %s target\n", target->name); ret = CAIRO_TEST_UNTESTED; @@ -1285,11 +1340,10 @@ cairo_test_for_target (cairo_test_t *test, cr = cairo_create (surface); + /* Clear to transparent (or black) depending on whether the target + * surface supports alpha. */ cairo_save (cr); - if (target->reference_format == CAIRO_FORMAT_RGB24) - cairo_set_source_rgba (cr, 1, 1, 1, 1); - else - cairo_set_source_rgba (cr, 0, 0, 0, 0); + cairo_set_source_rgba (cr, 0, 0, 0, 0); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_paint (cr); cairo_restore (cr); @@ -1316,7 +1370,10 @@ cairo_test_for_target (cairo_test_t *test, if (test->width != 0 && test->height != 0) { int pixels_changed; (target->write_to_png) (surface, png_name); - pixels_changed = image_diff (png_name, ref_name, diff_name); + if (target->content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) + pixels_changed = image_diff_flattened (png_name, ref_name, diff_name); + else + pixels_changed = image_diff (png_name, ref_name, diff_name); if (pixels_changed) { if (pixels_changed > 0) cairo_test_log ("Error: %d pixels differ from reference image %s\n", @@ -1355,90 +1412,102 @@ cairo_test_expecting (cairo_test_t *test, cairo_test_draw_function_t draw, cairo_test_target_t **targets_to_test; cairo_test_target_t targets[] = { - { "image", CAIRO_FORMAT_ARGB32, + { "image", CAIRO_CONTENT_COLOR_ALPHA, create_image_surface, cairo_surface_write_to_png, NULL}, - { "image", CAIRO_FORMAT_RGB24, + { "image", CAIRO_CONTENT_COLOR, create_image_surface, cairo_surface_write_to_png, NULL}, #ifdef CAIRO_HAS_TEST_SURFACES - { "test-fallback", CAIRO_FORMAT_ARGB32, + { "test-fallback", CAIRO_CONTENT_COLOR_ALPHA, create_test_fallback_surface, cairo_surface_write_to_png, NULL }, - { "test-meta", CAIRO_FORMAT_ARGB32, + { "test-fallback", CAIRO_CONTENT_COLOR, + create_test_fallback_surface, cairo_surface_write_to_png, NULL }, + { "test-meta", CAIRO_CONTENT_COLOR_ALPHA, create_test_meta_surface, cairo_surface_write_to_png, NULL }, - { "test-paginated", CAIRO_FORMAT_ARGB32, + { "test-meta", CAIRO_CONTENT_COLOR, + create_test_meta_surface, cairo_surface_write_to_png, NULL }, + { "test-paginated", CAIRO_CONTENT_COLOR_ALPHA, + create_test_paginated_surface, + test_paginated_write_to_png, + cleanup_test_paginated }, + { "test-paginated", CAIRO_CONTENT_COLOR, create_test_paginated_surface, test_paginated_write_to_png, cleanup_test_paginated }, #endif #ifdef CAIRO_HAS_GLITZ_SURFACE #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE - { "glitz-glx", CAIRO_FORMAT_ARGB32, + { "glitz-glx", CAIRO_CONTENT_COLOR_ALPHA, create_cairo_glitz_glx_surface, cairo_surface_write_to_png, cleanup_cairo_glitz_glx }, - { "glitz-glx", CAIRO_FORMAT_RGB24, + { "glitz-glx", CAIRO_CONTENT_COLOR, create_cairo_glitz_glx_surface, cairo_surface_write_to_png, cleanup_cairo_glitz_glx }, #endif #if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE - { "glitz-agl", CAIRO_FORMAT_ARGB32, + { "glitz-agl", CAIRO_CONTENT_COLOR_ALPHA, create_cairo_glitz_agl_surface, cairo_surface_write_to_png, cleanup_cairo_glitz_agl }, - { "glitz-agl", CAIRO_FORMAT_RGB24, + { "glitz-agl", CAIRO_CONTENT_COLOR, create_cairo_glitz_agl_surface, cairo_surface_write_to_png, cleanup_cairo_glitz_agl }, #endif #if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE - { "glitz-wgl", CAIRO_FORMAT_ARGB32, + { "glitz-wgl", CAIRO_CONTENT_COLOR_ALPHA, create_cairo_glitz_wgl_surface, cairo_surface_write_to_png, cleanup_cairo_glitz_wgl }, - { "glitz-wgl", CAIRO_FORMAT_RGB24, + { "glitz-wgl", CAIRO_CONTENT_COLOR, create_cairo_glitz_wgl_surface, cairo_surface_write_to_png, cleanup_cairo_glitz_wgl }, #endif #endif /* CAIRO_HAS_GLITZ_SURFACE */ #if 0 && CAIRO_HAS_QUARTZ_SURFACE - { "quartz", CAIRO_FORMAT_RGB24, + { "quartz", CAIRO_CONTENT_COLOR, create_quartz_surface, cairo_surface_write_to_png, cleanup_quartz }, #endif #if CAIRO_HAS_WIN32_SURFACE - { "win32", CAIRO_FORMAT_RGB24, + { "win32", CAIRO_CONTENT_COLOR, create_win32_surface, cairo_surface_write_to_png, cleanup_win32 }, #endif #if CAIRO_HAS_XCB_SURFACE - { "xcb", CAIRO_FORMAT_ARGB32, + { "xcb", CAIRO_CONTENT_COLOR_ALPHA, create_xcb_surface, cairo_surface_write_to_png, cleanup_xcb}, #endif #if CAIRO_HAS_XLIB_SURFACE - { "xlib", CAIRO_FORMAT_ARGB32, + { "xlib", CAIRO_CONTENT_COLOR_ALPHA, create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib}, - { "xlib", CAIRO_FORMAT_RGB24, + { "xlib", CAIRO_CONTENT_COLOR, create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib}, #endif #if CAIRO_HAS_PS_SURFACE - { "ps", CAIRO_FORMAT_RGB24, + { "ps", CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, + create_ps_surface, ps_surface_write_to_png, cleanup_ps }, + { "ps", CAIRO_CONTENT_COLOR, create_ps_surface, ps_surface_write_to_png, cleanup_ps }, #endif #if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE - { "pdf", CAIRO_FORMAT_RGB24, + { "pdf", CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, + create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf }, + { "pdf", CAIRO_CONTENT_COLOR, create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf }, #endif #if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE - { "svg", CAIRO_FORMAT_RGB24, + { "svg", CAIRO_CONTENT_COLOR_ALPHA, create_svg_surface, svg_surface_write_to_png, cleanup_svg }, #endif #if CAIRO_HAS_BEOS_SURFACE - { "beos", CAIRO_FORMAT_RGB24, + { "beos", CAIRO_CONTENT_COLOR, create_beos_surface, cairo_surface_write_to_png, cleanup_beos}, - { "beos_bitmap", CAIRO_FORMAT_RGB24, + { "beos_bitmap", CAIRO_CONTENT_COLOR, create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap}, - { "beos_bitmap", CAIRO_FORMAT_ARGB32, + { "beos_bitmap", CAIRO_CONTENT_COLOR_ALPHA, create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap}, #endif #if CAIRO_HAS_DIRECTFB_SURFACE - { "directfb", CAIRO_FORMAT_RGB24, + { "directfb", CAIRO_CONTENT_COLOR, create_directfb_surface, cairo_surface_write_to_png, cleanup_directfb}, - { "directfb_bitmap", CAIRO_FORMAT_ARGB32, + { "directfb_bitmap", CAIRO_CONTENT_COLOR_ALPHA, create_directfb_bitmap_surface, cairo_surface_write_to_png,cleanup_directfb}, #endif }; @@ -1483,13 +1552,15 @@ cairo_test_expecting (cairo_test_t *test, cairo_test_draw_function_t draw, for (i = 0; i < num_targets; i++) { cairo_test_target_t *target = targets_to_test[i]; cairo_test_log ("Testing %s with %s target\n", test->name, target->name); - printf ("%s-%s-%s:\t", test->name, target->name, cairo_target_format_name(target)); + printf ("%s-%s-%s:\t", test->name, target->name, + _cairo_test_content_name (target->content)); status = cairo_test_for_target (test, draw, target); - cairo_test_log ("TEST: %s TARGET: %s FORMAT: %s RESULT: ", - test->name, target->name, cairo_target_format_name(target)); + test->name, target->name, + _cairo_test_content_name (target->content)); + switch (status) { case CAIRO_TEST_SUCCESS: printf ("PASS\n"); diff --git a/test/caps-joins-ref.png b/test/caps-joins-ref.png index e7547cae4..9297ac4d5 100644 Binary files a/test/caps-joins-ref.png and b/test/caps-joins-ref.png differ diff --git a/test/caps-joins.c b/test/caps-joins.c index 7c5b1f0e2..abc6568b0 100644 --- a/test/caps-joins.c +++ b/test/caps-joins.c @@ -52,6 +52,12 @@ make_path (cairo_t *cr) static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_set_line_width (cr, LINE_WIDTH); cairo_translate (cr, PAD, PAD); diff --git a/test/caps-sub-paths-ref.png b/test/caps-sub-paths-ref.png index ced313603..1da16e8b0 100644 Binary files a/test/caps-sub-paths-ref.png and b/test/caps-sub-paths-ref.png differ diff --git a/test/caps-sub-paths.c b/test/caps-sub-paths.c index 70195bb85..edb499b8a 100644 --- a/test/caps-sub-paths.c +++ b/test/caps-sub-paths.c @@ -39,6 +39,12 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_set_line_width (cr, 4); cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); diff --git a/test/clip-fill-rule-pixel-aligned-rgb24-ref.png b/test/clip-fill-rule-pixel-aligned-rgb24-ref.png index 87e4498d2..1970c4768 100644 Binary files a/test/clip-fill-rule-pixel-aligned-rgb24-ref.png and b/test/clip-fill-rule-pixel-aligned-rgb24-ref.png differ diff --git a/test/clip-fill-rule-rgb24-ref.png b/test/clip-fill-rule-rgb24-ref.png index 293aff7ca..a969e367d 100644 Binary files a/test/clip-fill-rule-rgb24-ref.png and b/test/clip-fill-rule-rgb24-ref.png differ diff --git a/test/clip-nesting-rgb24-ref.png b/test/clip-nesting-rgb24-ref.png index 808d1da33..e2488f34e 100644 Binary files a/test/clip-nesting-rgb24-ref.png and b/test/clip-nesting-rgb24-ref.png differ diff --git a/test/clip-operator-rgb24-ref.png b/test/clip-operator-rgb24-ref.png index 9d6d686a9..7be49f0cb 100644 Binary files a/test/clip-operator-rgb24-ref.png and b/test/clip-operator-rgb24-ref.png differ diff --git a/test/clip-twice-rgb24-ref.png b/test/clip-twice-rgb24-ref.png index 1e97392c9..7485594ce 100644 Binary files a/test/clip-twice-rgb24-ref.png and b/test/clip-twice-rgb24-ref.png differ diff --git a/test/dash-caps-joins-ref.png b/test/dash-caps-joins-ref.png index c44352bcd..5c887c5c9 100644 Binary files a/test/dash-caps-joins-ref.png and b/test/dash-caps-joins-ref.png differ diff --git a/test/dash-caps-joins.c b/test/dash-caps-joins.c index d0e68ecfc..68023806d 100644 --- a/test/dash-caps-joins.c +++ b/test/dash-caps-joins.c @@ -60,6 +60,12 @@ draw (cairo_t *cr, int width, int height) { double dash[] = {LINE_WIDTH, 1.5 * LINE_WIDTH}; + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_set_line_width (cr, LINE_WIDTH); cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), - 2 * LINE_WIDTH); diff --git a/test/dash-offset-negative-ref.png b/test/dash-offset-negative-ref.png index 93dce321f..f2b8007af 100644 Binary files a/test/dash-offset-negative-ref.png and b/test/dash-offset-negative-ref.png differ diff --git a/test/dash-offset-negative.c b/test/dash-offset-negative.c index 52992e0f6..82f55ca91 100644 --- a/test/dash-offset-negative.c +++ b/test/dash-offset-negative.c @@ -45,6 +45,12 @@ draw (cairo_t *cr, int width, int height) { double dashes[] = { 1 }; + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_set_line_width (cr, 2); /* Basic 1-1 dash pattern */ diff --git a/test/fill-and-stroke-rgb24-ref.png b/test/fill-and-stroke-rgb24-ref.png index 8b08c0f91..ff886eb25 100644 Binary files a/test/fill-and-stroke-rgb24-ref.png and b/test/fill-and-stroke-rgb24-ref.png differ diff --git a/test/fill-rule-rgb24-ref.png b/test/fill-rule-rgb24-ref.png index 31a84d1b1..68d2b9b8b 100644 Binary files a/test/fill-rule-rgb24-ref.png and b/test/fill-rule-rgb24-ref.png differ diff --git a/test/gradient-alpha-rgb24-ref.png b/test/gradient-alpha-rgb24-ref.png index 383bfb05c..6703e4c4a 100644 Binary files a/test/gradient-alpha-rgb24-ref.png and b/test/gradient-alpha-rgb24-ref.png differ diff --git a/test/leaky-polygon-ref.png b/test/leaky-polygon-ref.png index 0daabe15a..15afc5dba 100644 Binary files a/test/leaky-polygon-ref.png and b/test/leaky-polygon-ref.png differ diff --git a/test/leaky-polygon.c b/test/leaky-polygon.c index 575311ee9..f34904446 100644 --- a/test/leaky-polygon.c +++ b/test/leaky-polygon.c @@ -65,6 +65,12 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_scale (cr, 1.0/(1<<16), 1.0/(1<<16)); cairo_move_to (cr, 131072,39321); diff --git a/test/line-width-ref.png b/test/line-width-ref.png index ddcd929d8..81ac2f593 100644 Binary files a/test/line-width-ref.png and b/test/line-width-ref.png differ diff --git a/test/line-width.c b/test/line-width.c index ca2d2760b..67f92bc22 100644 --- a/test/line-width.c +++ b/test/line-width.c @@ -41,6 +41,10 @@ draw (cairo_t *cr, int width, int height) { int i; + /* We draw in black, so paint white first. */ + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_set_source_rgb (cr, 0, 0, 0); cairo_translate (cr, 2, 2); diff --git a/test/mask-ctm-rgb24-ref.png b/test/mask-ctm-rgb24-ref.png index 3331d5bec..266cb0d12 100644 Binary files a/test/mask-ctm-rgb24-ref.png and b/test/mask-ctm-rgb24-ref.png differ diff --git a/test/mask-rgb24-ref.png b/test/mask-rgb24-ref.png index e3b7724c4..a9c6a5b79 100644 Binary files a/test/mask-rgb24-ref.png and b/test/mask-rgb24-ref.png differ diff --git a/test/mask-surface-ctm-rgb24-ref.png b/test/mask-surface-ctm-rgb24-ref.png index 3331d5bec..a2bdc6111 100644 Binary files a/test/mask-surface-ctm-rgb24-ref.png and b/test/mask-surface-ctm-rgb24-ref.png differ diff --git a/test/multi-page.c b/test/multi-page.c index 91360843e..f6780b493 100644 --- a/test/multi-page.c +++ b/test/multi-page.c @@ -159,7 +159,7 @@ main (void) filename = "multi-page.pdf"; surface = cairo_pdf_surface_create (filename, - WIDTH_IN_POINTS, HEIGHT_IN_POINTS); + WIDTH_IN_POINTS, HEIGHT_IN_POINTS); status = cairo_surface_status (surface); if (status) { cairo_test_log ("Failed to create pdf surface for file %s: %s\n", diff --git a/test/nil-surface-rgb24-ref.png b/test/nil-surface-rgb24-ref.png index 44b099823..97b2cfaa5 100644 Binary files a/test/nil-surface-rgb24-ref.png and b/test/nil-surface-rgb24-ref.png differ diff --git a/test/operator-clear-rgb24-ref.png b/test/operator-clear-rgb24-ref.png index a125abe69..ebb02b3a8 100644 Binary files a/test/operator-clear-rgb24-ref.png and b/test/operator-clear-rgb24-ref.png differ diff --git a/test/operator-source-rgb24-ref.png b/test/operator-source-rgb24-ref.png index 18f1bae55..7f49db078 100644 Binary files a/test/operator-source-rgb24-ref.png and b/test/operator-source-rgb24-ref.png differ diff --git a/test/paint-with-alpha-rgb24-ref.png b/test/paint-with-alpha-rgb24-ref.png index f8d75bcf1..b5cf0a703 100644 Binary files a/test/paint-with-alpha-rgb24-ref.png and b/test/paint-with-alpha-rgb24-ref.png differ diff --git a/test/path-data-ref.png b/test/path-data-ref.png index f8bc64758..3e9c30487 100644 Binary files a/test/path-data-ref.png and b/test/path-data-ref.png differ diff --git a/test/path-data.c b/test/path-data.c index b02ce4333..13b5fcc51 100644 --- a/test/path-data.c +++ b/test/path-data.c @@ -95,6 +95,12 @@ draw (cairo_t *cr, int width, int height) { cairo_path_t *path; + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + /* copy path, munge, and fill */ cairo_translate (cr, 5, 5); make_path (cr); diff --git a/test/png-flatten.c b/test/png-flatten.c new file mode 100644 index 000000000..2ce804ea6 --- /dev/null +++ b/test/png-flatten.c @@ -0,0 +1,77 @@ +/* + * Copyright © 2005 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Carl Worth + */ + +#include + +#include + +int +main (int argc, char *argv[]) +{ + cairo_t *cr; + cairo_surface_t *argb, *rgb24; + cairo_status_t status; + const char *input, *output; + + if (argc != 3) { + fprintf (stderr, "usage: %s input.png output.png", argv[0]); + fprintf (stderr, "Loads a PNG image (potentially with alpha) and writes out a flattened (no alpha)\nPNG image by first blending over white.\n"); + return 1; + } + + input = argv[1]; + output = argv[2]; + + argb = cairo_image_surface_create_from_png (input); + status = cairo_surface_status (argb); + if (status) { + fprintf (stderr, "%s: Error: Failed to load %s: %s\n", + argv[0], input, cairo_status_to_string (status)); + return 1; + } + + rgb24 = cairo_image_surface_create (CAIRO_FORMAT_RGB24, + cairo_image_surface_get_width (argb), + cairo_image_surface_get_height (argb)); + + cr = cairo_create (rgb24); + + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + + cairo_set_source_surface (cr, argb, 0, 0); + cairo_paint (cr); + + cairo_destroy (cr); + + status = cairo_surface_write_to_png (rgb24, output); + if (status) { + fprintf (stderr, "%s: Error: Failed to write %s: %s\n", + argv[0], output, cairo_status_to_string (status)); + return 1; + } + + return 0; +} diff --git a/test/rel-path-rgb24-ref.png b/test/rel-path-rgb24-ref.png index 65567398a..0a8a8732d 100644 Binary files a/test/rel-path-rgb24-ref.png and b/test/rel-path-rgb24-ref.png differ diff --git a/test/scale-source-surface-paint-rgb24-ref.png b/test/scale-source-surface-paint-rgb24-ref.png index 07aad3b6a..b9e2f435e 100644 Binary files a/test/scale-source-surface-paint-rgb24-ref.png and b/test/scale-source-surface-paint-rgb24-ref.png differ diff --git a/test/set-source-rgb24-ref.png b/test/set-source-rgb24-ref.png index 617c9f75a..b158c7465 100644 Binary files a/test/set-source-rgb24-ref.png and b/test/set-source-rgb24-ref.png differ diff --git a/test/show-text-current-point-ref.png b/test/show-text-current-point-ref.png index de2a13866..2fc5bd83f 100644 Binary files a/test/show-text-current-point-ref.png and b/test/show-text-current-point-ref.png differ diff --git a/test/show-text-current-point.c b/test/show-text-current-point.c index 84fe597ee..4595a8e91 100644 --- a/test/show-text-current-point.c +++ b/test/show-text-current-point.c @@ -38,6 +38,12 @@ draw (cairo_t *cr, int width, int height) { cairo_font_options_t *font_options; + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_select_font_face (cr, "Bitstream Vera Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); diff --git a/test/source-surface-scale-paint-rgb24-ref.png b/test/source-surface-scale-paint-rgb24-ref.png index 341269768..7ca745937 100644 Binary files a/test/source-surface-scale-paint-rgb24-ref.png and b/test/source-surface-scale-paint-rgb24-ref.png differ diff --git a/test/text-antialias-gray-ref.png b/test/text-antialias-gray-ref.png index dd2c77511..63b2e52ac 100644 Binary files a/test/text-antialias-gray-ref.png and b/test/text-antialias-gray-ref.png differ diff --git a/test/text-antialias-gray.c b/test/text-antialias-gray.c index a8e4a34d8..2b6f80ca7 100644 --- a/test/text-antialias-gray.c +++ b/test/text-antialias-gray.c @@ -42,6 +42,12 @@ draw (cairo_t *cr, int width, int height) cairo_font_options_t *font_options; static char black[] = "black", blue[] = "blue"; + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_select_font_face (cr, "Bitstream Vera Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); diff --git a/test/text-antialias-none-ref.png b/test/text-antialias-none-ref.png index 79d90fc83..bdd77bd56 100644 Binary files a/test/text-antialias-none-ref.png and b/test/text-antialias-none-ref.png differ diff --git a/test/text-antialias-none.c b/test/text-antialias-none.c index fb1c97a92..32a93f4ea 100644 --- a/test/text-antialias-none.c +++ b/test/text-antialias-none.c @@ -42,6 +42,12 @@ draw (cairo_t *cr, int width, int height) cairo_font_options_t *font_options; static char black[] = "black", blue[] = "blue"; + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_select_font_face (cr, "Bitstream Vera Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); diff --git a/test/text-pattern-rgb24-ref.png b/test/text-pattern-rgb24-ref.png index d73048570..e5a7f7077 100644 Binary files a/test/text-pattern-rgb24-ref.png and b/test/text-pattern-rgb24-ref.png differ diff --git a/test/transforms-ref.png b/test/transforms-ref.png index ee5bc7c7b..a60e51915 100644 Binary files a/test/transforms-ref.png and b/test/transforms-ref.png differ diff --git a/test/transforms.c b/test/transforms.c index 2c7556a9d..7e0e025aa 100644 --- a/test/transforms.c +++ b/test/transforms.c @@ -51,6 +51,12 @@ draw_L_shape (cairo_t *cr) static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + cairo_translate (cr, 5, 5); draw_L_shape (cr); diff --git a/test/trap-clip-rgb24-ref.png b/test/trap-clip-rgb24-ref.png index 0fea43b01..7506b82e4 100644 Binary files a/test/trap-clip-rgb24-ref.png and b/test/trap-clip-rgb24-ref.png differ diff --git a/test/unbounded-operator-rgb24-ref.png b/test/unbounded-operator-rgb24-ref.png index 1321dd00a..c12d9bbaa 100644 Binary files a/test/unbounded-operator-rgb24-ref.png and b/test/unbounded-operator-rgb24-ref.png differ