Tizen 2.0 Release
[framework/graphics/cairo.git] / test / buffer-diff.h
1 /* imagediff - Compare two images
2  *
3  * Copyright © 2004 Richard D. Worth
4  * Copyright © 2006 Red Hat, Inc.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software
7  * and its documentation for any purpose is hereby granted without
8  * fee, provided that the above copyright notice appear in all copies
9  * and that both that copyright notice and this permission notice
10  * appear in supporting documentation, and that the name of the authors
11  * not be used in advertising or publicity pertaining to distribution
12  * of the software without specific, written prior permission.
13  * The authors make no representations about the suitability of this
14  * software for any purpose.  It is provided "as is" without express
15  * or implied warranty.
16  *
17  * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
19  * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24  *
25  * Authors: Richard D. Worth <richard@theworths.org>
26  *          Carl Worth <cworth@cworth.org>
27  */
28
29 #ifndef BUFFER_DIFF_H
30 #define BUFFER_DIFF_H
31
32 #include "cairo-test.h"
33
34 typedef struct _buffer_diff_result {
35     unsigned int pixels_changed;
36     unsigned int max_diff;
37 } buffer_diff_result_t;
38
39 /* Compares two image buffers ignoring the alpha channel.
40  *
41  * Provides number of pixels changed and maximum single-channel
42  * difference in result.
43  *
44  * Also fills in a "diff" buffer intended to visually show where the
45  * images differ.
46  */
47 void
48 buffer_diff_noalpha (const unsigned char *buf_a,
49                      const unsigned char *buf_b,
50                      unsigned char *buf_diff,
51                      int            width,
52                      int            height,
53                      int            stride,
54                      buffer_diff_result_t *result);
55
56 /* The central algorithm to compare two images, and return the differences
57  * in the surface_diff.
58  *
59  * Provides number of pixels changed and maximum single-channel
60  * difference in result.
61  */
62 cairo_status_t
63 image_diff (const cairo_test_context_t *ctx,
64             cairo_surface_t *surface_a,
65             cairo_surface_t *surface_b,
66             cairo_surface_t *surface_diff,
67             buffer_diff_result_t *result);
68
69 cairo_bool_t
70 image_diff_is_failure (const buffer_diff_result_t *result,
71                        unsigned int                tolerance);
72
73 #endif