/* * 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: Kristian Høgsberg */ #include #include "cairo-test.h" #include #define WIDTH 256 #define HEIGHT 256 #define PAD 0 const char png_filename[] = "alpha-green.png"; #define N_OPERATORS (1 + CAIRO_OPERATOR_SATURATE - CAIRO_OPERATOR_CLEAR) #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) #define IMAGE_WIDTH (N_OPERATORS * (WIDTH + PAD) + PAD) #define IMAGE_HEIGHT ((HEIGHT + PAD) + PAD) static cairo_test_t test = { "precision-check", "Compositing with different operators", IMAGE_WIDTH, IMAGE_HEIGHT }; static cairo_test_status_t draw (cairo_t *cr, int width, int height) { int x, y; cairo_operator_t op; cairo_pattern_t *pattern; cairo_surface_t *image = cairo_image_surface_create_from_png (png_filename); for (op = CAIRO_OPERATOR_CLEAR; op <= CAIRO_OPERATOR_SATURATE; op++) { cairo_t *cr2; x = op * (WIDTH + PAD) + PAD; y = PAD; cairo_save (cr); cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_rectangle (cr, x, y, WIDTH, HEIGHT); cairo_fill (cr); pattern = cairo_pattern_create_for_surface (image); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_set_source (cr, pattern); cairo_set_operator (cr, op); cairo_rectangle (cr, x, y, WIDTH, HEIGHT); cairo_fill (cr); cairo_pattern_destroy (pattern); if (cairo_status (cr)) cairo_test_log ("%d HERE!\n", op); cairo_restore (cr); } if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) cairo_test_log ("%d .HERE!\n", op); return CAIRO_TEST_SUCCESS; } int main (void) { return cairo_test (&test, draw); }