|
Packit |
324a5c |
/*
|
|
Packit |
324a5c |
* Copyright © 2008 Mozilla Corporation
|
|
Packit |
324a5c |
*
|
|
Packit |
324a5c |
* Permission to use, copy, modify, distribute, and sell this software
|
|
Packit |
324a5c |
* and its documentation for any purpose is hereby granted without
|
|
Packit |
324a5c |
* fee, provided that the above copyright notice appear in all copies
|
|
Packit |
324a5c |
* and that both that copyright notice and this permission notice
|
|
Packit |
324a5c |
* appear in supporting documentation, and that the name of
|
|
Packit |
324a5c |
* Mozilla Corporation not be used in advertising or publicity pertaining to
|
|
Packit |
324a5c |
* distribution of the software without specific, written prior
|
|
Packit |
324a5c |
* permission. Mozilla Corporation makes no representations about the
|
|
Packit |
324a5c |
* suitability of this software for any purpose. It is provided "as
|
|
Packit |
324a5c |
* is" without express or implied warranty.
|
|
Packit |
324a5c |
*
|
|
Packit |
324a5c |
* MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
Packit |
324a5c |
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
Packit |
324a5c |
* FITNESS, IN NO EVENT SHALL MOZILLA CORPORATION BE LIABLE FOR ANY SPECIAL,
|
|
Packit |
324a5c |
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
Packit |
324a5c |
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
Packit |
324a5c |
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
Packit |
324a5c |
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
324a5c |
*
|
|
Packit |
324a5c |
* Authors: Michael Ventnor, Jeff Muizelaar
|
|
Packit |
324a5c |
*/
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
#include "cairo-test.h"
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
#define WIDTH 20
|
|
Packit |
324a5c |
#define HEIGHT 20
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
static cairo_test_status_t
|
|
Packit |
324a5c |
draw (cairo_t *cr, int width, int height)
|
|
Packit |
324a5c |
{
|
|
Packit |
324a5c |
cairo_surface_t *second;
|
|
Packit |
324a5c |
cairo_t *second_cr;
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/* fill with black so we don't need an rgb test case */
|
|
Packit |
324a5c |
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
Packit |
324a5c |
cairo_paint (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
cairo_scale (cr, 0.5, 0.5);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/* draw the first rectangle */
|
|
Packit |
324a5c |
cairo_set_source_rgb (cr, 0, 0, 0.4);
|
|
Packit |
324a5c |
cairo_rectangle (cr, 6, 6, 10, 10);
|
|
Packit |
324a5c |
cairo_fill (cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/* adjust the offset so that the second rectangle will fit on the surface */
|
|
Packit |
324a5c |
second = cairo_image_surface_create (CAIRO_FORMAT_A8, 10, 10);
|
|
Packit |
324a5c |
cairo_surface_set_device_offset (second, -6, -6);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/* draw the second rectangle:
|
|
Packit |
324a5c |
* this rectangle should end up in the same place as the rectangle above
|
|
Packit |
324a5c |
* independent of the device offset of the surface it is painted on*/
|
|
Packit |
324a5c |
second_cr = cairo_create (second);
|
|
Packit |
324a5c |
cairo_surface_destroy (second);
|
|
Packit |
324a5c |
cairo_rectangle (second_cr, 6, 6, 10, 10);
|
|
Packit |
324a5c |
cairo_fill (second_cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/* paint the second rectangle on top of the first rectangle */
|
|
Packit |
324a5c |
cairo_set_source_rgb (cr, 0.5, 0.5, 0);
|
|
Packit |
324a5c |
cairo_mask_surface (cr, cairo_get_target (second_cr), 0, 0);
|
|
Packit |
324a5c |
cairo_destroy (second_cr);
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
return CAIRO_TEST_SUCCESS;
|
|
Packit |
324a5c |
}
|
|
Packit |
324a5c |
|
|
Packit |
324a5c |
/*
|
|
Packit |
324a5c |
* XFAIL: complication of pre-multiplying device_offset into the pattern_matrix
|
|
Packit |
324a5c |
* and then requiring further manipulation for SVG
|
|
Packit |
324a5c |
*/
|
|
Packit |
324a5c |
CAIRO_TEST (device_offset_scale,
|
|
Packit |
324a5c |
"Test that the device-offset transform is transformed by the ctm.",
|
|
Packit |
324a5c |
"device-offset", /* keywords */
|
|
Packit |
324a5c |
NULL, /* requirements */
|
|
Packit |
324a5c |
WIDTH, HEIGHT,
|
|
Packit |
324a5c |
NULL, draw)
|