2005-01-25 14:45:31 +00:00
|
|
|
/* imagediff - Compare two images
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2004 Richard D. Worth
|
|
|
|
|
*
|
|
|
|
|
* 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 Richard Worth
|
|
|
|
|
* not be used in advertising or publicity pertaining to distribution
|
|
|
|
|
* of the software without specific, written prior permission.
|
|
|
|
|
* Richard Worth makes no representations about the suitability of this
|
|
|
|
|
* software for any purpose. It is provided "as is" without express
|
|
|
|
|
* or implied warranty.
|
2006-06-06 15:35:48 -07:00
|
|
|
*
|
2005-01-25 14:45:31 +00:00
|
|
|
* RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
|
|
|
|
* NO EVENT SHALL RICHARD WORTH 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: Richard D. Worth <richard@theworths.org> */
|
|
|
|
|
|
2005-08-05 10:05:29 +00:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-04-27 13:33:25 +00:00
|
|
|
#include <stdio.h>
|
2006-08-22 22:00:58 -04:00
|
|
|
#include <stdlib.h>
|
2005-08-05 07:48:18 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-04-27 13:33:25 +00:00
|
|
|
#include <unistd.h>
|
2005-08-05 07:48:18 +00:00
|
|
|
#endif
|
2005-04-27 13:33:25 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
#include <string.h>
|
2005-08-05 11:15:04 +00:00
|
|
|
#include <pixman.h>
|
2005-04-27 13:33:25 +00:00
|
|
|
|
2005-05-10 20:25:38 +00:00
|
|
|
#include "cairo-test.h"
|
|
|
|
|
|
2006-12-14 04:17:07 -08:00
|
|
|
#include "pdiff.h"
|
2005-03-29 00:02:19 +00:00
|
|
|
#include "buffer-diff.h"
|
2005-04-27 13:33:25 +00:00
|
|
|
#include "xmalloc.h"
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xunlink (const char *pathname)
|
|
|
|
|
{
|
|
|
|
|
if (unlink (pathname) < 0 && errno != ENOENT) {
|
2005-05-10 20:25:38 +00:00
|
|
|
cairo_test_log (" Error: Cannot remove %s: %s\n",
|
|
|
|
|
pathname, strerror (errno));
|
2005-04-27 13:33:25 +00:00
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-01-25 14:45:31 +00:00
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
/* Compare two buffers, returning the number of pixels that are
|
|
|
|
|
* different and the maximum difference of any single color channel in
|
|
|
|
|
* result_ret.
|
|
|
|
|
*
|
|
|
|
|
* This function should be rewritten to compare all formats supported by
|
2005-08-05 11:15:04 +00:00
|
|
|
* cairo_format_t instead of taking a mask as a parameter.
|
|
|
|
|
*/
|
2006-08-31 04:01:10 -07:00
|
|
|
static void
|
2005-08-05 11:15:04 +00:00
|
|
|
buffer_diff_core (unsigned char *_buf_a,
|
|
|
|
|
unsigned char *_buf_b,
|
|
|
|
|
unsigned char *_buf_diff,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
2006-12-12 02:17:19 -08:00
|
|
|
int stride,
|
2006-08-31 04:01:10 -07:00
|
|
|
pixman_bits_t mask,
|
|
|
|
|
buffer_diff_result_t *result_ret)
|
2005-01-25 14:45:31 +00:00
|
|
|
{
|
|
|
|
|
int x, y;
|
2005-08-05 11:15:04 +00:00
|
|
|
pixman_bits_t *row_a, *row_b, *row;
|
2006-08-31 04:01:10 -07:00
|
|
|
buffer_diff_result_t result = {0, 0};
|
2005-08-05 11:15:04 +00:00
|
|
|
pixman_bits_t *buf_a = (pixman_bits_t*)_buf_a;
|
|
|
|
|
pixman_bits_t *buf_b = (pixman_bits_t*)_buf_b;
|
|
|
|
|
pixman_bits_t *buf_diff = (pixman_bits_t*)_buf_diff;
|
2005-01-25 14:45:31 +00:00
|
|
|
|
2006-12-12 02:17:19 -08:00
|
|
|
stride /= sizeof(pixman_bits_t);
|
2005-01-25 14:45:31 +00:00
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
|
{
|
2006-12-12 02:17:19 -08:00
|
|
|
row_a = buf_a + y * stride;
|
|
|
|
|
row_b = buf_b + y * stride;
|
|
|
|
|
row = buf_diff + y * stride;
|
2005-01-25 14:45:31 +00:00
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
|
{
|
2005-08-05 11:15:04 +00:00
|
|
|
/* check if the pixels are the same */
|
|
|
|
|
if ((row_a[x] & mask) != (row_b[x] & mask)) {
|
|
|
|
|
int channel;
|
|
|
|
|
pixman_bits_t diff_pixel = 0;
|
|
|
|
|
|
|
|
|
|
/* calculate a difference value for all 4 channels */
|
|
|
|
|
for (channel = 0; channel < 4; channel++) {
|
2006-08-30 13:17:08 -04:00
|
|
|
int value_a = (row_a[x] >> (channel*8)) & 0xff;
|
|
|
|
|
int value_b = (row_b[x] >> (channel*8)) & 0xff;
|
2006-08-08 01:16:49 -07:00
|
|
|
unsigned int diff;
|
2006-08-22 22:00:58 -04:00
|
|
|
diff = abs (value_a - value_b);
|
2006-08-31 04:01:10 -07:00
|
|
|
if (diff > result.max_diff)
|
|
|
|
|
result.max_diff = diff;
|
2006-08-30 13:17:08 -04:00
|
|
|
diff *= 4; /* emphasize */
|
|
|
|
|
if (diff)
|
|
|
|
|
diff += 128; /* make sure it's visible */
|
2006-08-01 15:20:39 -04:00
|
|
|
if (diff > 255)
|
2006-08-30 13:17:08 -04:00
|
|
|
diff = 255;
|
2006-08-01 15:20:39 -04:00
|
|
|
diff_pixel |= diff << (channel*8);
|
2005-08-05 11:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
result.pixels_changed++;
|
2005-08-05 11:15:04 +00:00
|
|
|
row[x] = diff_pixel;
|
2005-01-25 14:45:31 +00:00
|
|
|
} else {
|
2005-08-05 11:15:04 +00:00
|
|
|
row[x] = 0;
|
2005-01-25 14:45:31 +00:00
|
|
|
}
|
2005-08-05 11:15:04 +00:00
|
|
|
row[x] |= 0xff000000; /* Set ALPHA to 100% (opaque) */
|
2005-01-25 14:45:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
*result_ret = result;
|
2005-04-27 13:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
void
|
2006-12-12 16:37:35 -08:00
|
|
|
compare_surfaces (cairo_surface_t *surface_a,
|
|
|
|
|
cairo_surface_t *surface_b,
|
|
|
|
|
cairo_surface_t *surface_diff,
|
|
|
|
|
buffer_diff_result_t *result)
|
2005-08-05 11:15:04 +00:00
|
|
|
{
|
2006-12-14 04:17:07 -08:00
|
|
|
/* These default values were taken straight from the
|
|
|
|
|
* perceptualdiff program. We'll probably want to tune these as
|
|
|
|
|
* necessary. */
|
|
|
|
|
double gamma = 2.2;
|
|
|
|
|
double luminance = 100.0;
|
|
|
|
|
double field_of_view = 45.0;
|
|
|
|
|
int discernible_pixels_changed;
|
|
|
|
|
|
|
|
|
|
/* First, we run cairo's old buffer_diff algorithm which looks for
|
|
|
|
|
* pixel-perfect images, (we do this first since the test suite
|
|
|
|
|
* runs about 3x slower if we run pdiff_compare first).
|
|
|
|
|
*/
|
2006-12-12 16:37:35 -08:00
|
|
|
buffer_diff_core (cairo_image_surface_get_data (surface_a),
|
|
|
|
|
cairo_image_surface_get_data (surface_b),
|
|
|
|
|
cairo_image_surface_get_data (surface_diff),
|
|
|
|
|
cairo_image_surface_get_width (surface_a),
|
|
|
|
|
cairo_image_surface_get_height (surface_a),
|
|
|
|
|
cairo_image_surface_get_stride (surface_a),
|
|
|
|
|
0xffffffff,
|
|
|
|
|
result);
|
2006-12-14 04:17:07 -08:00
|
|
|
if (result->pixels_changed == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
cairo_test_log ("%d pixels differ (with maximum difference of %d) from reference image\n",
|
|
|
|
|
result->pixels_changed, result->max_diff);
|
|
|
|
|
|
|
|
|
|
/* Then, if there are any different pixels, we give the pdiff code
|
|
|
|
|
* a crack at the images. If it decides that there are no visually
|
|
|
|
|
* discernible differences in any pixels, then we accept this
|
|
|
|
|
* result as good enough. */
|
|
|
|
|
discernible_pixels_changed = pdiff_compare (surface_a, surface_b,
|
|
|
|
|
gamma, luminance, field_of_view);
|
|
|
|
|
if (discernible_pixels_changed == 0) {
|
|
|
|
|
result->pixels_changed = 0;
|
|
|
|
|
cairo_test_log ("But perceptual diff finds no visually discernible difference.\n"
|
|
|
|
|
"Accepting result.\n");
|
|
|
|
|
}
|
2005-08-05 11:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
void
|
2005-08-05 11:15:04 +00:00
|
|
|
buffer_diff_noalpha (unsigned char *buf_a,
|
|
|
|
|
unsigned char *buf_b,
|
|
|
|
|
unsigned char *buf_diff,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
2006-12-12 02:17:19 -08:00
|
|
|
int stride,
|
2006-08-31 04:01:10 -07:00
|
|
|
buffer_diff_result_t *result)
|
2005-08-05 11:15:04 +00:00
|
|
|
{
|
2006-08-31 04:01:10 -07:00
|
|
|
buffer_diff_core(buf_a, buf_b, buf_diff,
|
2006-12-12 02:17:19 -08:00
|
|
|
width, height, stride, 0x00ffffff,
|
2006-08-31 04:01:10 -07:00
|
|
|
result);
|
2005-08-05 11:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-30 23:41:48 -07:00
|
|
|
static cairo_status_t
|
|
|
|
|
stdio_write_func (void *closure, const unsigned char *data, unsigned int length)
|
|
|
|
|
{
|
|
|
|
|
FILE *file = closure;
|
|
|
|
|
|
|
|
|
|
if (fwrite (data, 1, length, file) != length)
|
|
|
|
|
return CAIRO_STATUS_WRITE_ERROR;
|
|
|
|
|
|
|
|
|
|
return CAIRO_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flatten an ARGB surface by blending it over white. The resulting
|
|
|
|
|
* surface, (still in ARGB32 format, but with only alpha==1.0
|
|
|
|
|
* everywhere) is returned in the same surface pointer.
|
|
|
|
|
*
|
|
|
|
|
* The original surface will be destroyed.
|
|
|
|
|
*
|
|
|
|
|
* The (x,y) value specify an origin of interest for the original
|
|
|
|
|
* image. The flattened image will be generated only from the box
|
|
|
|
|
* extending from (x,y) to (width,height).
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
flatten_surface (cairo_surface_t **surface, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
cairo_surface_t *flat;
|
|
|
|
|
cairo_t *cr;
|
|
|
|
|
|
|
|
|
|
flat = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
|
cairo_image_surface_get_width (*surface) - x,
|
|
|
|
|
cairo_image_surface_get_height (*surface) - y);
|
|
|
|
|
cairo_surface_set_device_offset (flat, -x, -y);
|
|
|
|
|
|
|
|
|
|
cr = cairo_create (flat);
|
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
cairo_set_source_surface (cr, *surface, 0, 0);
|
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
|
|
cairo_surface_destroy (*surface);
|
|
|
|
|
*surface = flat;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-12 02:17:19 -08:00
|
|
|
/* Given an image surface, create a new surface that has the same
|
|
|
|
|
* contents as the sub-surface with its origin at x,y.
|
|
|
|
|
*
|
|
|
|
|
* The original surface will be destroyed.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
extract_sub_surface (cairo_surface_t **surface, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
cairo_surface_t *sub;
|
|
|
|
|
cairo_t *cr;
|
|
|
|
|
|
|
|
|
|
sub = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
|
cairo_image_surface_get_width (*surface) - x,
|
|
|
|
|
cairo_image_surface_get_height (*surface) - y);
|
|
|
|
|
|
|
|
|
|
/* We don't use a device offset like flatten_surface. That's not
|
|
|
|
|
* for any important reason, (the results should be
|
|
|
|
|
* identical). This style just seemed more natural to me this
|
|
|
|
|
* time, so I'm leaving both here so I can look at both to see
|
|
|
|
|
* which I like better. */
|
|
|
|
|
cr = cairo_create (sub);
|
|
|
|
|
cairo_set_source_surface (cr, *surface, -x, -y);
|
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
|
|
|
cairo_paint (cr);
|
2007-03-01 18:14:33 -05:00
|
|
|
cairo_destroy (cr);
|
2006-12-12 02:17:19 -08:00
|
|
|
|
|
|
|
|
cairo_surface_destroy (*surface);
|
|
|
|
|
*surface = sub;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-27 13:33:25 +00:00
|
|
|
/* Image comparison code courtesy of Richard Worth <richard@theworths.org>
|
|
|
|
|
* Returns number of pixels changed, (or -1 on error).
|
|
|
|
|
* Also saves a "diff" image intended to visually show where the
|
|
|
|
|
* images differ.
|
2006-08-31 04:01:10 -07:00
|
|
|
*
|
|
|
|
|
* The return value simply indicates whether a check was successfully
|
|
|
|
|
* made, (as opposed to a file-not-found condition or similar). It
|
|
|
|
|
* does not indicate anything about how much the images differ. For
|
|
|
|
|
* that, see result.
|
|
|
|
|
*
|
|
|
|
|
* One failure mode is if the two images provided do not have the same
|
|
|
|
|
* dimensions. In this case, this function will return
|
|
|
|
|
* CAIRO_STATUS_SURFACE_TYPE_MISMATCH (which is a bit of an abuse, but
|
|
|
|
|
* oh well).
|
2005-04-27 13:33:25 +00:00
|
|
|
*/
|
2006-08-31 04:01:10 -07:00
|
|
|
static cairo_status_t
|
2006-08-30 23:41:48 -07:00
|
|
|
image_diff_core (const char *filename_a,
|
|
|
|
|
const char *filename_b,
|
|
|
|
|
const char *filename_diff,
|
|
|
|
|
int ax,
|
|
|
|
|
int ay,
|
|
|
|
|
int bx,
|
|
|
|
|
int by,
|
2006-08-31 04:01:10 -07:00
|
|
|
buffer_diff_result_t *result,
|
2006-08-30 23:41:48 -07:00
|
|
|
cairo_bool_t flatten)
|
2005-04-27 13:33:25 +00:00
|
|
|
{
|
2006-09-07 13:09:25 -07:00
|
|
|
cairo_status_t status;
|
2005-04-27 13:33:25 +00:00
|
|
|
unsigned int width_a, height_a, stride_a;
|
|
|
|
|
unsigned int width_b, height_b, stride_b;
|
2006-08-30 23:41:48 -07:00
|
|
|
cairo_surface_t *surface_a, *surface_b, *surface_diff;
|
2005-04-27 13:33:25 +00:00
|
|
|
|
2006-08-30 23:41:48 -07:00
|
|
|
surface_a = cairo_image_surface_create_from_png (filename_a);
|
2006-09-07 13:09:25 -07:00
|
|
|
status = cairo_surface_status (surface_a);
|
|
|
|
|
if (status) {
|
|
|
|
|
cairo_test_log ("Error: Failed to create surface from %s: %s\n",
|
|
|
|
|
filename_a, cairo_status_to_string (status));
|
|
|
|
|
return status;
|
|
|
|
|
}
|
2005-04-27 13:33:25 +00:00
|
|
|
|
2006-08-30 23:41:48 -07:00
|
|
|
surface_b = cairo_image_surface_create_from_png (filename_b);
|
2006-09-07 13:09:25 -07:00
|
|
|
status = cairo_surface_status (surface_b);
|
|
|
|
|
if (status) {
|
|
|
|
|
cairo_test_log ("Error: Failed to create surface from %s: %s\n",
|
|
|
|
|
filename_b, cairo_status_to_string (status));
|
2006-08-30 23:41:48 -07:00
|
|
|
cairo_surface_destroy (surface_a);
|
2006-09-07 13:09:25 -07:00
|
|
|
return status;
|
2005-07-15 10:39:59 +00:00
|
|
|
}
|
2005-04-27 13:33:25 +00:00
|
|
|
|
2006-12-12 02:17:19 -08:00
|
|
|
if (flatten) {
|
|
|
|
|
flatten_surface (&surface_a, ax, ay);
|
|
|
|
|
flatten_surface (&surface_b, bx, by);
|
|
|
|
|
ax = ay = bx = by = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ax || ay) {
|
|
|
|
|
extract_sub_surface (&surface_a, ax, ay);
|
|
|
|
|
ax = ay = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bx || by) {
|
|
|
|
|
extract_sub_surface (&surface_b, bx, by);
|
|
|
|
|
bx = by = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
width_a = cairo_image_surface_get_width (surface_a);
|
|
|
|
|
height_a = cairo_image_surface_get_height (surface_a);
|
|
|
|
|
stride_a = cairo_image_surface_get_stride (surface_a);
|
|
|
|
|
width_b = cairo_image_surface_get_width (surface_b);
|
|
|
|
|
height_b = cairo_image_surface_get_height (surface_b);
|
|
|
|
|
stride_b = cairo_image_surface_get_stride (surface_b);
|
2006-02-15 13:46:52 -08:00
|
|
|
|
2005-04-27 13:33:25 +00:00
|
|
|
if (width_a != width_b ||
|
2006-12-12 02:17:19 -08:00
|
|
|
height_a != height_b ||
|
|
|
|
|
stride_a != stride_b)
|
2005-04-27 13:33:25 +00:00
|
|
|
{
|
2006-08-30 23:41:48 -07:00
|
|
|
cairo_test_log ("Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
|
2005-05-10 20:25:38 +00:00
|
|
|
" for %s vs. %s\n",
|
2006-08-30 23:41:48 -07:00
|
|
|
width_a, height_a,
|
|
|
|
|
width_b, height_b,
|
2005-05-10 20:25:38 +00:00
|
|
|
filename_a, filename_b);
|
2006-08-30 23:41:48 -07:00
|
|
|
cairo_surface_destroy (surface_a);
|
|
|
|
|
cairo_surface_destroy (surface_b);
|
2006-08-31 04:01:10 -07:00
|
|
|
return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
|
2005-04-27 13:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-30 23:41:48 -07:00
|
|
|
surface_diff = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
|
width_a, height_a);
|
2005-04-27 13:33:25 +00:00
|
|
|
|
2006-12-12 16:37:35 -08:00
|
|
|
compare_surfaces (surface_a, surface_b, surface_diff, result);
|
2006-08-31 04:01:10 -07:00
|
|
|
|
|
|
|
|
if (result->pixels_changed) {
|
2006-02-15 13:46:52 -08:00
|
|
|
FILE *png_file;
|
2006-08-30 23:41:48 -07:00
|
|
|
|
2006-02-15 13:46:52 -08:00
|
|
|
if (filename_diff)
|
|
|
|
|
png_file = fopen (filename_diff, "wb");
|
|
|
|
|
else
|
|
|
|
|
png_file = stdout;
|
2006-08-30 23:41:48 -07:00
|
|
|
|
|
|
|
|
cairo_surface_write_to_png_stream (surface_diff, stdio_write_func, png_file);
|
|
|
|
|
|
2006-02-15 13:46:52 -08:00
|
|
|
if (png_file != stdout)
|
|
|
|
|
fclose (png_file);
|
2005-04-27 13:33:25 +00:00
|
|
|
} else {
|
2006-02-15 13:46:52 -08:00
|
|
|
if (filename_diff)
|
|
|
|
|
xunlink (filename_diff);
|
2005-04-27 13:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-30 23:41:48 -07:00
|
|
|
cairo_surface_destroy (surface_a);
|
|
|
|
|
cairo_surface_destroy (surface_b);
|
|
|
|
|
cairo_surface_destroy (surface_diff);
|
2005-04-27 13:33:25 +00:00
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
return CAIRO_STATUS_SUCCESS;
|
2005-01-25 14:45:31 +00:00
|
|
|
}
|
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.
And new constructors (currently internal only) to create an image surface with a cairo_content_t rather than a cairo_format_t.
Add a cairo_content_t argument to the constructor.
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.
Add image flattening by compositing over white, as is done in cairo-ps-surface.c.
Track changes to cairo-paginates-surface which now requires a cairo_content_t value (no change to public PS/PDF constructors yet).
Track change in meta-surface and paginated-surface interfaces by now accepting a cairo_content_t rather than a cairo_format_t.
Ignore new output files (argb32 from pdf and ps as well as rgb24 from test-fallback, test-meta, and test-paginated).
Add new utility for flattening PNG images in order to generate the -argbf-ref.png images.
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.
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).
Track change in cairo_ps_surface_create (now requires cairo_content_t value).
Adjust tests that draw in default (black) to first paint white so that the results are visible.
Adjust ARGB32 reference images for new white background for changed tests.
Adjust RGB24 reference images for new black background due to changed initialization (and the tests themselves being unchanged).
2006-01-17 16:59:08 +00:00
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
cairo_status_t
|
2006-08-30 23:41:48 -07:00
|
|
|
image_diff (const char *filename_a,
|
|
|
|
|
const char *filename_b,
|
|
|
|
|
const char *filename_diff,
|
|
|
|
|
int ax,
|
|
|
|
|
int ay,
|
|
|
|
|
int bx,
|
2006-08-31 04:01:10 -07:00
|
|
|
int by,
|
|
|
|
|
buffer_diff_result_t *result)
|
2006-08-30 23:41:48 -07:00
|
|
|
{
|
|
|
|
|
return image_diff_core (filename_a, filename_b, filename_diff,
|
|
|
|
|
ax, ay, bx, by,
|
2006-08-31 04:01:10 -07:00
|
|
|
result, FALSE);
|
2006-08-30 23:41:48 -07:00
|
|
|
}
|
|
|
|
|
|
2006-08-31 04:01:10 -07:00
|
|
|
cairo_status_t
|
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.
And new constructors (currently internal only) to create an image surface with a cairo_content_t rather than a cairo_format_t.
Add a cairo_content_t argument to the constructor.
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.
Add image flattening by compositing over white, as is done in cairo-ps-surface.c.
Track changes to cairo-paginates-surface which now requires a cairo_content_t value (no change to public PS/PDF constructors yet).
Track change in meta-surface and paginated-surface interfaces by now accepting a cairo_content_t rather than a cairo_format_t.
Ignore new output files (argb32 from pdf and ps as well as rgb24 from test-fallback, test-meta, and test-paginated).
Add new utility for flattening PNG images in order to generate the -argbf-ref.png images.
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.
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).
Track change in cairo_ps_surface_create (now requires cairo_content_t value).
Adjust tests that draw in default (black) to first paint white so that the results are visible.
Adjust ARGB32 reference images for new white background for changed tests.
Adjust RGB24 reference images for new black background due to changed initialization (and the tests themselves being unchanged).
2006-01-17 16:59:08 +00:00
|
|
|
image_diff_flattened (const char *filename_a,
|
|
|
|
|
const char *filename_b,
|
2006-02-15 13:46:52 -08:00
|
|
|
const char *filename_diff,
|
|
|
|
|
int ax,
|
|
|
|
|
int ay,
|
|
|
|
|
int bx,
|
2006-08-31 04:01:10 -07:00
|
|
|
int by,
|
|
|
|
|
buffer_diff_result_t *result)
|
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.
And new constructors (currently internal only) to create an image surface with a cairo_content_t rather than a cairo_format_t.
Add a cairo_content_t argument to the constructor.
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.
Add image flattening by compositing over white, as is done in cairo-ps-surface.c.
Track changes to cairo-paginates-surface which now requires a cairo_content_t value (no change to public PS/PDF constructors yet).
Track change in meta-surface and paginated-surface interfaces by now accepting a cairo_content_t rather than a cairo_format_t.
Ignore new output files (argb32 from pdf and ps as well as rgb24 from test-fallback, test-meta, and test-paginated).
Add new utility for flattening PNG images in order to generate the -argbf-ref.png images.
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.
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).
Track change in cairo_ps_surface_create (now requires cairo_content_t value).
Adjust tests that draw in default (black) to first paint white so that the results are visible.
Adjust ARGB32 reference images for new white background for changed tests.
Adjust RGB24 reference images for new black background due to changed initialization (and the tests themselves being unchanged).
2006-01-17 16:59:08 +00:00
|
|
|
{
|
2006-08-30 23:41:48 -07:00
|
|
|
return image_diff_core (filename_a, filename_b, filename_diff,
|
|
|
|
|
ax, ay, bx, by,
|
2006-08-31 04:01:10 -07:00
|
|
|
result, TRUE);
|
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.
And new constructors (currently internal only) to create an image surface with a cairo_content_t rather than a cairo_format_t.
Add a cairo_content_t argument to the constructor.
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.
Add image flattening by compositing over white, as is done in cairo-ps-surface.c.
Track changes to cairo-paginates-surface which now requires a cairo_content_t value (no change to public PS/PDF constructors yet).
Track change in meta-surface and paginated-surface interfaces by now accepting a cairo_content_t rather than a cairo_format_t.
Ignore new output files (argb32 from pdf and ps as well as rgb24 from test-fallback, test-meta, and test-paginated).
Add new utility for flattening PNG images in order to generate the -argbf-ref.png images.
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.
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).
Track change in cairo_ps_surface_create (now requires cairo_content_t value).
Adjust tests that draw in default (black) to first paint white so that the results are visible.
Adjust ARGB32 reference images for new white background for changed tests.
Adjust RGB24 reference images for new black background due to changed initialization (and the tests themselves being unchanged).
2006-01-17 16:59:08 +00:00
|
|
|
}
|