mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 00:38:06 +02:00
Merge branch 'region32'
This commit is contained in:
commit
c57b1eca18
8 changed files with 108 additions and 25 deletions
|
|
@ -314,7 +314,7 @@ CAIRO_LIBS=$CAIRO_NONPKGCONFIG_LIBS
|
|||
|
||||
dnl ===========================================================================
|
||||
|
||||
PIXMAN_VERSION="0.10.0"
|
||||
PIXMAN_VERSION="0.11.2"
|
||||
PIXMAN_REQUIRES="pixman-1 >= $PIXMAN_VERSION"
|
||||
PKG_CHECK_MODULES(pixman, $PIXMAN_REQUIRES, ,
|
||||
[AC_MSG_ERROR([pixman >= $PIXMAN_VERSION is required
|
||||
|
|
|
|||
|
|
@ -1193,7 +1193,7 @@ _cairo_image_surface_set_clip_region (void *abstract_surface,
|
|||
{
|
||||
cairo_image_surface_t *surface = (cairo_image_surface_t *) abstract_surface;
|
||||
|
||||
if (! pixman_image_set_clip_region (surface->pixman_image, ®ion->rgn))
|
||||
if (! pixman_image_set_clip_region32 (surface->pixman_image, ®ion->rgn))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
surface->has_clip = region != NULL;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
/* #cairo_region_t is defined in cairoint.h */
|
||||
|
||||
struct _cairo_region {
|
||||
pixman_region16_t rgn;
|
||||
pixman_region32_t rgn;
|
||||
};
|
||||
|
||||
cairo_private void
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@
|
|||
void
|
||||
_cairo_region_init (cairo_region_t *region)
|
||||
{
|
||||
pixman_region_init (®ion->rgn);
|
||||
pixman_region32_init (®ion->rgn);
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_region_init_rect (cairo_region_t *region,
|
||||
cairo_rectangle_int_t *rect)
|
||||
{
|
||||
pixman_region_init_rect (®ion->rgn,
|
||||
pixman_region32_init_rect (®ion->rgn,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
|
|
@ -57,13 +57,13 @@ _cairo_region_init_boxes (cairo_region_t *region,
|
|||
cairo_box_int_t *boxes,
|
||||
int count)
|
||||
{
|
||||
pixman_box16_t stack_pboxes[CAIRO_STACK_ARRAY_LENGTH (pixman_box16_t)];
|
||||
pixman_box16_t *pboxes = stack_pboxes;
|
||||
pixman_box32_t stack_pboxes[CAIRO_STACK_ARRAY_LENGTH (pixman_box32_t)];
|
||||
pixman_box32_t *pboxes = stack_pboxes;
|
||||
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
int i;
|
||||
|
||||
if (count > ARRAY_LENGTH(stack_pboxes)) {
|
||||
pboxes = _cairo_malloc_ab (count, sizeof(pixman_box16_t));
|
||||
pboxes = _cairo_malloc_ab (count, sizeof(pixman_box32_t));
|
||||
if (pboxes == NULL)
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ _cairo_region_init_boxes (cairo_region_t *region,
|
|||
pboxes[i].y2 = boxes[i].p2.y;
|
||||
}
|
||||
|
||||
if (!pixman_region_init_rects (®ion->rgn, pboxes, count))
|
||||
if (!pixman_region32_init_rects (®ion->rgn, pboxes, count))
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
if (pboxes != stack_pboxes)
|
||||
|
|
@ -87,13 +87,13 @@ _cairo_region_init_boxes (cairo_region_t *region,
|
|||
void
|
||||
_cairo_region_fini (cairo_region_t *region)
|
||||
{
|
||||
pixman_region_fini (®ion->rgn);
|
||||
pixman_region32_fini (®ion->rgn);
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
_cairo_region_copy (cairo_region_t *dst, cairo_region_t *src)
|
||||
{
|
||||
if (!pixman_region_copy (&dst->rgn, &src->rgn))
|
||||
if (!pixman_region32_copy (&dst->rgn, &src->rgn))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -102,18 +102,18 @@ _cairo_region_copy (cairo_region_t *dst, cairo_region_t *src)
|
|||
int
|
||||
_cairo_region_num_boxes (cairo_region_t *region)
|
||||
{
|
||||
return pixman_region_n_rects (®ion->rgn);
|
||||
return pixman_region32_n_rects (®ion->rgn);
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
_cairo_region_get_boxes (cairo_region_t *region, int *num_boxes, cairo_box_int_t **boxes)
|
||||
{
|
||||
int nboxes;
|
||||
pixman_box16_t *pboxes;
|
||||
pixman_box32_t *pboxes;
|
||||
cairo_box_int_t *cboxes;
|
||||
int i;
|
||||
|
||||
pboxes = pixman_region_rectangles (®ion->rgn, &nboxes);
|
||||
pboxes = pixman_region32_rectangles (®ion->rgn, &nboxes);
|
||||
|
||||
if (nboxes == 0) {
|
||||
*num_boxes = 0;
|
||||
|
|
@ -154,7 +154,7 @@ _cairo_region_boxes_fini (cairo_region_t *region, cairo_box_int_t *boxes)
|
|||
void
|
||||
_cairo_region_get_extents (cairo_region_t *region, cairo_rectangle_int_t *extents)
|
||||
{
|
||||
pixman_box16_t *pextents = pixman_region_extents (®ion->rgn);
|
||||
pixman_box32_t *pextents = pixman_region32_extents (®ion->rgn);
|
||||
|
||||
extents->x = pextents->x1;
|
||||
extents->y = pextents->y1;
|
||||
|
|
@ -165,7 +165,7 @@ _cairo_region_get_extents (cairo_region_t *region, cairo_rectangle_int_t *extent
|
|||
cairo_int_status_t
|
||||
_cairo_region_subtract (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *b)
|
||||
{
|
||||
if (!pixman_region_subtract (&dst->rgn, &a->rgn, &b->rgn))
|
||||
if (!pixman_region32_subtract (&dst->rgn, &a->rgn, &b->rgn))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -174,7 +174,7 @@ _cairo_region_subtract (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *
|
|||
cairo_int_status_t
|
||||
_cairo_region_intersect (cairo_region_t *dst, cairo_region_t *a, cairo_region_t *b)
|
||||
{
|
||||
if (!pixman_region_intersect (&dst->rgn, &a->rgn, &b->rgn))
|
||||
if (!pixman_region32_intersect (&dst->rgn, &a->rgn, &b->rgn))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -185,7 +185,7 @@ _cairo_region_union_rect (cairo_region_t *dst,
|
|||
cairo_region_t *src,
|
||||
cairo_rectangle_int_t *rect)
|
||||
{
|
||||
if (!pixman_region_union_rect (&dst->rgn, &src->rgn,
|
||||
if (!pixman_region32_union_rect (&dst->rgn, &src->rgn,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
|
@ -196,25 +196,25 @@ _cairo_region_union_rect (cairo_region_t *dst,
|
|||
cairo_bool_t
|
||||
_cairo_region_not_empty (cairo_region_t *region)
|
||||
{
|
||||
return (cairo_bool_t) pixman_region_not_empty (®ion->rgn);
|
||||
return (cairo_bool_t) pixman_region32_not_empty (®ion->rgn);
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_region_translate (cairo_region_t *region,
|
||||
int x, int y)
|
||||
{
|
||||
pixman_region_translate (®ion->rgn, x, y);
|
||||
pixman_region32_translate (®ion->rgn, x, y);
|
||||
}
|
||||
|
||||
pixman_region_overlap_t
|
||||
_cairo_region_contains_rectangle (cairo_region_t *region, cairo_rectangle_int_t *rect)
|
||||
{
|
||||
pixman_box16_t pbox;
|
||||
pixman_box32_t pbox;
|
||||
|
||||
pbox.x1 = rect->x;
|
||||
pbox.y1 = rect->y;
|
||||
pbox.x2 = rect->x + rect->width;
|
||||
pbox.y2 = rect->y + rect->height;
|
||||
|
||||
return pixman_region_contains_rectangle (®ion->rgn, &pbox);
|
||||
return pixman_region32_contains_rectangle (®ion->rgn, &pbox);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1995,15 +1995,36 @@ _cairo_xlib_surface_set_clip_region (void *abstract_surface,
|
|||
cairo_status_t status;
|
||||
XRectangle *rects = NULL;
|
||||
int n_boxes, i;
|
||||
cairo_rectangle_int_t rect;
|
||||
cairo_region_t bound, bounded;
|
||||
|
||||
status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = surface->width;
|
||||
rect.height = surface->height;
|
||||
|
||||
/* Intersect the region with the bounds of the surface. This
|
||||
* is necessary so we don't wrap around when we convert cairo's
|
||||
* 32 bit region into 16 bit rectangles.
|
||||
*/
|
||||
_cairo_region_init_rect (&bound, &rect);
|
||||
_cairo_region_init (&bounded);
|
||||
status = _cairo_region_intersect (&bounded, &bound, region);
|
||||
if (status) {
|
||||
_cairo_region_fini (&bound);
|
||||
_cairo_region_fini (&bounded);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = _cairo_region_get_boxes (&bounded, &n_boxes, &boxes);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (n_boxes > ARRAY_LENGTH (surface->embedded_clip_rects)) {
|
||||
rects = _cairo_malloc_ab (n_boxes, sizeof (XRectangle));
|
||||
if (rects == NULL) {
|
||||
_cairo_region_boxes_fini (region, boxes);
|
||||
_cairo_region_boxes_fini (&bounded, boxes);
|
||||
_cairo_region_fini (&bound);
|
||||
_cairo_region_fini (&bounded);
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2017,7 +2038,9 @@ _cairo_xlib_surface_set_clip_region (void *abstract_surface,
|
|||
rects[i].height = boxes[i].p2.y - boxes[i].p1.y;
|
||||
}
|
||||
|
||||
_cairo_region_boxes_fini (region, boxes);
|
||||
_cairo_region_boxes_fini (&bounded, boxes);
|
||||
_cairo_region_fini (&bounded);
|
||||
_cairo_region_fini (&bound);
|
||||
|
||||
surface->have_clip_rects = TRUE;
|
||||
surface->clip_rects = rects;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ infinite-join$(EXEEXT) \
|
|||
in-fill-empty-trapezoid$(EXEEXT) \
|
||||
in-fill-trapezoid$(EXEEXT) \
|
||||
invalid-matrix$(EXEEXT) \
|
||||
large-clip$(EXEEXT) \
|
||||
large-font$(EXEEXT) \
|
||||
large-source$(EXEEXT) \
|
||||
leaky-dash$(EXEEXT) \
|
||||
|
|
@ -443,6 +444,7 @@ REFERENCE_IMAGES = \
|
|||
image-surface-source-ref.png \
|
||||
infinite-join-ref.png \
|
||||
infinite-join-ps-ref.png \
|
||||
large-clip-ref.png \
|
||||
large-font-ref.png \
|
||||
large-source-ref.png \
|
||||
leaky-dash-ps-argb32-ref.png \
|
||||
|
|
|
|||
BIN
test/large-clip-ref.png
Normal file
BIN
test/large-clip-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 350 B |
58
test/large-clip.c
Normal file
58
test/large-clip.c
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright © 2008 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: Soren Sandmann <sandmann@redhat.com>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define SIZE 100
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
cairo_test_t test = {
|
||||
"large-clip",
|
||||
"Incorrect clipping when the clip rectangle doesn't fit in 16 bits signed",
|
||||
SIZE, SIZE,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_set_source_rgb (cr, 0, 0, 1);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, 65536 + 25, 65536 + 25);
|
||||
cairo_clip (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue