cairo/test/composite-integer-translate-over-repeat.c

64 lines
1.6 KiB
C
Raw Normal View History

#include <math.h>
#include "cairo-test.h"
#include <stdio.h>
#define SIZE 100
#define SIZE2 20
#define OFFSET 10
cairo_test_t test = {
"composite-integer-translate-over-repeat",
"Test simple compositing: integer-translation 32->32 OVER, with repeat",
SIZE, SIZE,
draw
};
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *image;
cairo_pattern_t *pat;
cairo_t *cr2;
image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, SIZE2, SIZE2);
cr2 = cairo_create (image);
cairo_set_source_rgba (cr2, 1, 0, 0, 1);
cairo_rectangle (cr2, 0, 0, SIZE2/2, SIZE2/2);
cairo_fill (cr2);
cairo_set_source_rgba (cr2, 0, 1, 0, 1);
cairo_rectangle (cr2, SIZE2/2, 0, SIZE2/2, SIZE2/2);
cairo_fill (cr2);
cairo_set_source_rgba (cr2, 0, 0, 1, 1);
cairo_rectangle (cr2, 0, SIZE2/2, SIZE2/2, SIZE2/2);
cairo_fill (cr2);
cairo_set_source_rgba (cr2, 1, 1, 0, 1);
cairo_rectangle (cr2, SIZE2/2, SIZE2/2, SIZE2/2, SIZE2/2);
cairo_fill (cr2);
cairo_destroy (cr2);
pat = cairo_pattern_create_for_surface (image);
cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_rectangle (cr, 0, 0, SIZE, SIZE);
cairo_fill (cr);
cairo_translate (cr, OFFSET, OFFSET);
Add a function to test whether a cairo_operator_t is bounded (does nothing for 0 src/mask) cairoint.h: Add a helper function to take clearing areas that are outside the source/mask but are cleared by unbounded operations. src/cairo-xlib-surface.c (_cairo_xlib_surface_composite): Use _cairo_surface_composite_fixup_unbounded() as needed. src/cairo-image-surface.c src/cairint.h: Keep track of whether the surface has a clip or not ... we need this for determining when we can bypass an intermediate mask for composite_trapezoids(). Create an intermediate mask of the right size with pixman_add_trapezoids() and composite that. When rendering with an unbounded operator, create the intermediate mask ourselves and render with ADD to that, then composite the result. Create an intermediate surface the size of the extents, render the glyphs to that then composite the results. Add the size of the glyph Compute the size of the glyph mask, then use _cairo_surface_composite_fixup_unbounded(). Use the right mask format. (Unrelated bugfix) New function taking a drawing function as a parameter to encapsulate shared logic between compositing trapezoid, glyphs, and masks. Use _cairo_gstate_clip_and_composite(). Also fix extents computations for unbounded operators. src/cairo-clip.c src/cairo-clip-private.h (_cairo_clip_combine_to_surface): Add the destination as an extra parameter to allow combining to an intermediate surface. tests/unbounded-operator.c tests/Makefile.am: Add a test for the operation of the 6 unbounded operators against different shapes. tests/clip-operator.c tests/Makefile.am: Add a test that tests surface clipping with different shapes against all the operators. Make use OVER like the name and description. With fixed semantics, SOURCE does something different.
2005-08-08 13:46:11 +00:00
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_set_source (cr, pat);
cairo_rectangle (cr, 0, 0, SIZE - OFFSET, SIZE - OFFSET);
cairo_fill (cr);
cairo_surface_destroy (image);
2005-07-18 08:23:21 +00:00
cairo_pattern_destroy (pat);
return CAIRO_TEST_SUCCESS;
}
int
main (void)
{
return cairo_test (&test);
}