[cairo-commit] 19 commits - perf/Makefile.am pixman/src
src/cairo-clip.c src/cairo-clip-private.h
src/cairo-glitz-surface.c src/cairo-gstate.c src/cairoint.h
src/cairo-meta-surface.c src/cairo-region.c
src/cairo-surface.c src/cairo-surface-fallback.c
src/cairo-traps.c test/Makefile.am
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Apr 8 19:30:43 PDT 2007
perf/Makefile.am | 2
pixman/src/fbcompose.c | 67 +++----
pixman/src/fbpict.c | 29 +--
pixman/src/icimage.c | 378 +++++++++----------------------------------
pixman/src/icimage.h | 10 -
pixman/src/icint.h | 2
pixman/src/icrect.c | 39 ++--
pixman/src/ictrap.c | 16 -
pixman/src/pixman-remap.h | 7
pixman/src/pixman.h | 22 +-
pixman/src/pixregion.c | 75 ++------
pixman/src/pixregionint.h | 7
src/cairo-clip-private.h | 6
src/cairo-clip.c | 152 ++++++++---------
src/cairo-glitz-surface.c | 49 ++---
src/cairo-gstate.c | 4
src/cairo-meta-surface.c | 2
src/cairo-region.c | 27 ---
src/cairo-surface-fallback.c | 239 ++++++++++++++-------------
src/cairo-surface.c | 54 +++---
src/cairo-traps.c | 18 +-
src/cairoint.h | 9 -
test/Makefile.am | 2
23 files changed, 461 insertions(+), 755 deletions(-)
New commits:
diff-tree e8072e6e0ac86b2b0baefb54dcc551ee548164af (from 6f9309221704a799ca36917c65abfc0941119b13)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Apr 8 22:03:46 2007 -0400
[test,perf] Make them rebuild boilerplate when src is changed
diff --git a/perf/Makefile.am b/perf/Makefile.am
index 8fd6e64..8007cab 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -51,7 +51,7 @@ cairo_perf_diff_files_SOURCES = \
LDADD = $(top_builddir)/boilerplate/libcairoboilerplate.la \
$(top_builddir)/src/libcairo.la
-$(top_builddir)/boilerplate/libcairoboilerplate.la:
+$(top_builddir)/boilerplate/libcairoboilerplate.la: $(top_builddir)/src/libcairo.la
cd $(top_builddir)/boilerplate && $(MAKE) $(AM_MAKEFLAGS) libcairoboilerplate.la
$(top_builddir)/src/libcairo.la:
diff --git a/test/Makefile.am b/test/Makefile.am
index e40aaf3..0461853 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -460,7 +460,7 @@ libcairotest_la_LIBADD =\
LDADD = $(CAIRO_LDADD) libcairotest.la
-$(top_builddir)/boilerplate/libcairoboilerplate.la:
+$(top_builddir)/boilerplate/libcairoboilerplate.la: $(top_builddir)/src/libcairo.la
cd $(top_builddir)/boilerplate && $(MAKE) $(AM_MAKEFLAGS) libcairoboilerplate.la
$(top_builddir)/src/libcairo.la:
diff-tree 6f9309221704a799ca36917c65abfc0941119b13 (from 4f8a04b1c93630c2556db5e3a0657076167e1ea3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Apr 8 21:58:54 2007 -0400
Rename pixman_region_uninit to pixman_region_fini
diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 43cfb98..d93df45 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -4292,7 +4292,7 @@ pixman_compositeGeneral (pixman_operator
free(scanline_buffer);
CLEANUP_REGION:
- pixman_region_uninit (®ion);
+ pixman_region_fini (®ion);
}
#endif
diff --git a/pixman/src/fbpict.c b/pixman/src/fbpict.c
index b416fe5..7cae833 100644
--- a/pixman/src/fbpict.c
+++ b/pixman/src/fbpict.c
@@ -1998,7 +1998,7 @@ pixman_composite (pixman_operator_t op,
}
CLEANUP_REGION:
- pixman_region_uninit (®ion);
+ pixman_region_fini (®ion);
}
/* The CPU detection code needs to be in a file not compiled with
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 0ef1eb3..e011461 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -465,12 +465,12 @@ pixman_image_destroy (pixman_image_t *im
pixman_image_destroyClip (image);
if (image->hasCompositeClip) {
- pixman_region_uninit (&image->compositeClip);
+ pixman_region_fini (&image->compositeClip);
image->hasCompositeClip = 0;
}
if (image->hasSourceClip) {
- pixman_region_uninit (&image->sourceClip);
+ pixman_region_fini (&image->sourceClip);
image->hasSourceClip = 0;
}
@@ -496,7 +496,7 @@ void
pixman_image_destroyClip (pixman_image_t *image)
{
if (CT_NONE != image->clientClipType)
- pixman_region_uninit (&image->clientClip);
+ pixman_region_fini (&image->clientClip);
image->clientClipType = CT_NONE;
}
@@ -518,7 +518,7 @@ pixman_image_set_clip_region (pixman_ima
return 0;
if (image->hasCompositeClip)
- pixman_region_uninit (&image->compositeClip);
+ pixman_region_fini (&image->compositeClip);
pixman_region_init_rect (&image->compositeClip, 0, 0,
image->pixels->width,
diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c
index 9636e5a..a6c080c 100644
--- a/pixman/src/icrect.c
+++ b/pixman/src/icrect.c
@@ -242,7 +242,7 @@ pixman_color_rects (pixman_image_t *dst
}
pixman_region_intersect (&rects_as_region, &rects_as_region, &clip);
- pixman_region_uninit (&clip);
+ pixman_region_fini (&clip);
n_clipped_rects = pixman_region_num_rects (&rects_as_region);
clipped_rects = pixman_region_rects (&rects_as_region);
@@ -265,7 +265,7 @@ pixman_color_rects (pixman_image_t *dst
&pixel);
}
- pixman_region_uninit (&rects_as_region);
+ pixman_region_fini (&rects_as_region);
if (xoff || yoff)
{
diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c
index d12bb4d..252fa69 100644
--- a/pixman/src/ictrap.c
+++ b/pixman/src/ictrap.c
@@ -153,8 +153,8 @@ pixman_composite_trapezoids (pixman_oper
bounds = *(pixman_region_extents (&traps_region));
- pixman_region_uninit (&traps_region);
- pixman_region_uninit (&dst_region);
+ pixman_region_fini (&traps_region);
+ pixman_region_fini (&dst_region);
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return;
diff --git a/pixman/src/pixman-remap.h b/pixman/src/pixman-remap.h
index b244f49..02ab3c4 100644
--- a/pixman/src/pixman-remap.h
+++ b/pixman/src/pixman-remap.h
@@ -59,7 +59,7 @@
#define pixman_region_init _cairo_pixman_region_init
#define pixman_region_init_rect _cairo_pixman_region_init_rect
#define pixman_region_init_with_extents _cairo_pixman_region_init_with_extents
-#define pixman_region_uninit _cairo_pixman_region_uninit
+#define pixman_region_fini _cairo_pixman_region_fini
#define pixman_region_empty _cairo_pixman_region_empty
#define pixman_region_extents _cairo_pixman_region_extents
#define pixman_region_intersect _cairo_pixman_region_intersect
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index c5f7ec0..5c12127 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -139,7 +139,7 @@ pixman_region_init_rect(pixman_region16_
pixman_private void
pixman_region_init_with_extents(pixman_region16_t *region, pixman_box16_t *extents);
pixman_private void
-pixman_region_uninit (pixman_region16_t *region);
+pixman_region_fini (pixman_region16_t *region);
/* manipulation */
diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index 1ab29fa..35982ae 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -314,7 +314,7 @@ pixman_region_init_with_extents(pixman_r
}
void
-pixman_region_uninit (pixman_region16_t *region)
+pixman_region_fini (pixman_region16_t *region)
{
good (region);
freeData (region);
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index b27088d..ea4ada3 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -99,10 +99,10 @@ _cairo_clip_reset (cairo_clip_t *clip)
clip->serial = 0;
if (clip->has_region) {
- /* pixman_region_uninit just releases the resources used but
+ /* pixman_region_fini just releases the resources used but
* doesn't bother with leaving the region in a valid state.
* So pixman_region_init has to be called afterwards. */
- pixman_region_uninit (&clip->region);
+ pixman_region_fini (&clip->region);
pixman_region_init (&clip->region);
clip->has_region = FALSE;
@@ -179,7 +179,7 @@ _cairo_clip_intersect_to_rectangle (cair
_cairo_region_extents_rectangle (&intersection, rectangle);
}
- pixman_region_uninit (&intersection);
+ pixman_region_fini (&intersection);
if (status)
return status;
@@ -217,7 +217,7 @@ _cairo_clip_intersect_to_region (cairo_c
pixman_region_intersect (region, &clip_rect, region))
status = CAIRO_STATUS_NO_MEMORY;
- pixman_region_uninit (&clip_rect);
+ pixman_region_fini (&clip_rect);
if (status)
return status;
@@ -350,11 +350,11 @@ _cairo_clip_intersect_region (cairo_clip
status = CAIRO_STATUS_NO_MEMORY;
}
- pixman_region_uninit (&intersection);
+ pixman_region_fini (&intersection);
}
clip->serial = _cairo_surface_allocate_clip_serial (target);
- pixman_region_uninit (®ion);
+ pixman_region_fini (®ion);
return status;
}
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index ceaa4b4..f8207e7 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -47,7 +47,7 @@ _cairo_glitz_surface_finish (void *abstr
if (surface->has_clip) {
glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0);
- pixman_region_uninit (&surface->clip);
+ pixman_region_fini (&surface->clip);
}
glitz_surface_destroy (surface->surface);
@@ -1299,7 +1299,7 @@ _cairo_glitz_surface_set_clip_region (vo
glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0);
if (surface->has_clip) {
- pixman_region_uninit (&surface->clip);
+ pixman_region_fini (&surface->clip);
surface->has_clip = FALSE;
}
}
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index a9b8e3b..581d312 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -586,7 +586,7 @@ _clip_and_composite_trapezoids (cairo_pa
}
if (!pixman_region_not_empty (&clear_region)) {
- pixman_region_uninit (&clear_region);
+ pixman_region_fini (&clear_region);
has_clear_region = FALSE;
}
} else {
@@ -660,9 +660,9 @@ _clip_and_composite_trapezoids (cairo_pa
out:
if (has_trap_region)
- pixman_region_uninit (&trap_region);
+ pixman_region_fini (&trap_region);
if (has_clear_region)
- pixman_region_uninit (&clear_region);
+ pixman_region_fini (&clear_region);
return status;
}
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 5630fed..93d4f46 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1915,9 +1915,9 @@ _cairo_surface_composite_fixup_unbounded
CLEANUP_REGIONS:
if (has_drawn_region)
- pixman_region_uninit (&drawn_region);
+ pixman_region_fini (&drawn_region);
if (has_clear_region)
- pixman_region_uninit (&clear_region);
+ pixman_region_fini (&clear_region);
return status;
}
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index c2707ef..2fa4f66 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -570,7 +570,7 @@ _cairo_traps_extract_region (cairo_traps
if (pixman_region_union_rect (region, region,
x, y, width, height) != PIXMAN_REGION_STATUS_SUCCESS) {
- pixman_region_uninit (region);
+ pixman_region_fini (region);
return CAIRO_STATUS_NO_MEMORY;
}
}
diff-tree 4f8a04b1c93630c2556db5e3a0657076167e1ea3 (from df9ea31df5857ee7aacd6ba002881233e9c4a9b4)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Apr 8 21:55:45 2007 -0400
[pixman-image] Simply initialization given that there is no clip
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index dc2ba3b..0ef1eb3 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -328,29 +328,15 @@ pixman_image_init (pixman_image_t *image
*/
if (image->pixels) {
- if (!image->hasCompositeClip) {
- pixman_region_init_rect (&image->compositeClip,
- 0, 0, image->pixels->width,
- image->pixels->height);
- image->hasCompositeClip = 1;
- }
-
- if (!image->hasSourceClip) {
- pixman_region_init_rect (&image->sourceClip,
- 0, 0, image->pixels->width,
- image->pixels->height);
- image->hasSourceClip = 1;
- }
- } else {
- if (image->hasCompositeClip) {
- pixman_region_uninit (&image->compositeClip);
- image->hasCompositeClip = FALSE;
- }
-
- if (image->hasSourceClip) {
- pixman_region_uninit (&image->sourceClip);
- image->hasSourceClip = FALSE;
- }
+ pixman_region_init_rect (&image->compositeClip,
+ 0, 0, image->pixels->width,
+ image->pixels->height);
+ image->hasCompositeClip = 1;
+
+ pixman_region_init_rect (&image->sourceClip,
+ 0, 0, image->pixels->width,
+ image->pixels->height);
+ image->hasSourceClip = 1;
}
image->transform = NULL;
diff-tree df9ea31df5857ee7aacd6ba002881233e9c4a9b4 (from 9436959a838412b5336279c7d5c35bf4e586f984)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Thu Mar 15 14:42:13 2007 +0100
[pixman-region] Separate pixman_region_init
Most of the time pixman_region_init is called without any extents, and
followed by a pixman_region_union_rect, used to used to initialize
rectangular regions. pixman_region_union_rect is not that cheap, but
the sequence is called quite often. So it should be worth introducing
a specialized and fast function for this sequence.
This introduces pixman_region_init_rect. This new function makes
_cairo_region_init_from_rectangle obsolete.
Also removes the extent argument from pixman_region_init as it was
called with NULL most of the time. A pixman_region_init_with_extents
is added for the general case.
diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 1bd7ab9..43cfb98 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -4219,8 +4219,7 @@ pixman_compositeGeneral (pixman_operator
if (op == PIXMAN_OPERATOR_OVER && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format_code) && !pSrc->alphaMap)
op = PIXMAN_OPERATOR_SRC;
- pixman_region_init (®ion, NULL);
- pixman_region_union_rect (®ion, ®ion, xDst, yDst, width, height);
+ pixman_region_init_rect (®ion, xDst, yDst, width, height);
if (!FbComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height))
diff --git a/pixman/src/fbpict.c b/pixman/src/fbpict.c
index 3fd4aa9..b416fe5 100644
--- a/pixman/src/fbpict.c
+++ b/pixman/src/fbpict.c
@@ -1933,8 +1933,7 @@ pixman_composite (pixman_operator_t op,
if (maskTransform)
maskRepeat = 0;
- pixman_region_init (®ion, NULL);
- pixman_region_union_rect (®ion, ®ion, xDst, yDst, width, height);
+ pixman_region_init_rect (®ion, xDst, yDst, width, height);
if (!FbComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height))
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 9d336eb..dc2ba3b 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -329,22 +329,18 @@ pixman_image_init (pixman_image_t *image
if (image->pixels) {
if (!image->hasCompositeClip) {
- pixman_region_init (&image->compositeClip, NULL);
+ pixman_region_init_rect (&image->compositeClip,
+ 0, 0, image->pixels->width,
+ image->pixels->height);
image->hasCompositeClip = 1;
}
- pixman_region_union_rect (&image->compositeClip, &image->compositeClip,
- 0, 0, image->pixels->width,
- image->pixels->height);
-
if (!image->hasSourceClip) {
- pixman_region_init (&image->sourceClip, NULL);
+ pixman_region_init_rect (&image->sourceClip,
+ 0, 0, image->pixels->width,
+ image->pixels->height);
image->hasSourceClip = 1;
}
-
- pixman_region_union_rect (&image->sourceClip, &image->sourceClip,
- 0, 0, image->pixels->width,
- image->pixels->height);
} else {
if (image->hasCompositeClip) {
pixman_region_uninit (&image->compositeClip);
@@ -526,7 +522,7 @@ pixman_image_set_clip_region (pixman_ima
pixman_image_destroyClip (image);
if (region) {
- pixman_region_init (&image->clientClip, NULL);
+ pixman_region_init (&image->clientClip);
pixman_region_copy (&image->clientClip, region);
image->clientClipType = CT_REGION;
}
@@ -538,9 +534,10 @@ pixman_image_set_clip_region (pixman_ima
if (image->hasCompositeClip)
pixman_region_uninit (&image->compositeClip);
- pixman_region_init (&image->compositeClip, NULL);
- pixman_region_union_rect (&image->compositeClip, &image->compositeClip,
- 0, 0, image->pixels->width, image->pixels->height);
+ pixman_region_init_rect (&image->compositeClip, 0, 0,
+ image->pixels->width,
+ image->pixels->height);
+
image->hasCompositeClip = 1;
if (region) {
diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c
index af4311a..9636e5a 100644
--- a/pixman/src/icrect.c
+++ b/pixman/src/icrect.c
@@ -204,10 +204,9 @@ pixman_color_rects (pixman_image_t *dst
xoff -= dst->pixels->x;
yoff -= dst->pixels->y;
- pixman_region_init (&clip, NULL);
- pixman_region_union_rect (&clip, &clip,
- dst->pixels->x, dst->pixels->y,
- dst->pixels->width, dst->pixels->height);
+ pixman_region_init_rect (&clip,
+ dst->pixels->x, dst->pixels->y,
+ dst->pixels->width, dst->pixels->height);
pixman_region_intersect (&clip, &clip, clipPict->hasCompositeClip ?
&clipPict->compositeClip : NULL);
@@ -233,7 +232,8 @@ pixman_color_rects (pixman_image_t *dst
}
}
- pixman_region_init (&rects_as_region, NULL);
+ pixman_region_init (&rects_as_region);
+
for (i = 0; i < nRect; i++)
{
pixman_region_union_rect (&rects_as_region, &rects_as_region,
diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c
index 7a90cf0..d12bb4d 100644
--- a/pixman/src/ictrap.c
+++ b/pixman/src/ictrap.c
@@ -138,8 +138,7 @@ pixman_composite_trapezoids (pixman_oper
yDst = traps[0].left.p1.y >> 16;
pixman_trapezoid_bounds (ntraps, traps, &traps_bounds);
-
- pixman_region_init (&traps_region, &traps_bounds);
+ pixman_region_init_with_extents (&traps_region, &traps_bounds);
/* XXX: If the image has a clip region set, we should really be
* fetching it here instead, but it looks like we don't yet expose
@@ -149,8 +148,7 @@ pixman_composite_trapezoids (pixman_oper
dst_bounds.x2 = pixman_image_get_width (dst);
dst_bounds.y2 = pixman_image_get_height (dst);
- pixman_region_init (&dst_region, &dst_bounds);
-
+ pixman_region_init_with_extents (&dst_region, &dst_bounds);
pixman_region_intersect (&traps_region, &traps_region, &dst_region);
bounds = *(pixman_region_extents (&traps_region));
diff --git a/pixman/src/pixman-remap.h b/pixman/src/pixman-remap.h
index d92cf5a..b244f49 100644
--- a/pixman/src/pixman-remap.h
+++ b/pixman/src/pixman-remap.h
@@ -57,6 +57,8 @@
#define pixman_region_contains_rectangle _cairo_pixman_region_contains_rectangle
#define pixman_region_copy _cairo_pixman_region_copy
#define pixman_region_init _cairo_pixman_region_init
+#define pixman_region_init_rect _cairo_pixman_region_init_rect
+#define pixman_region_init_with_extents _cairo_pixman_region_init_with_extents
#define pixman_region_uninit _cairo_pixman_region_uninit
#define pixman_region_empty _cairo_pixman_region_empty
#define pixman_region_extents _cairo_pixman_region_extents
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index 3f6830a..c5f7ec0 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -132,7 +132,12 @@ typedef enum {
/* creation/destruction */
pixman_private void
-pixman_region_init(pixman_region16_t *region, pixman_box16_t *extents);
+pixman_region_init(pixman_region16_t *region);
+pixman_private void
+pixman_region_init_rect(pixman_region16_t *region,
+ int x, int y, unsigned int width, unsigned int height);
+pixman_private void
+pixman_region_init_with_extents(pixman_region16_t *region, pixman_box16_t *extents);
pixman_private void
pixman_region_uninit (pixman_region16_t *region);
diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index a1bfd21..1ab29fa 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -288,24 +288,29 @@ pixman_region16_valid(reg)
#endif /* DEBUG_PIXREGION */
-/*****************************************************************
- * RegionInit(pReg, rect, size)
- * Outer region rect is statically allocated.
- *****************************************************************/
+void
+pixman_region_init(pixman_region16_t *region)
+{
+ region->extents = pixman_region_emptyBox;
+ region->data = &pixman_region_emptyData;
+}
void
-pixman_region_init(pixman_region16_t *region, pixman_box16_t *extents)
+pixman_region_init_rect(pixman_region16_t *region,
+ int x, int y, unsigned int width, unsigned int height)
{
- if (extents)
- {
- region->extents = *extents;
- region->data = NULL;
- }
- else
- {
- region->extents = pixman_region_emptyBox;
- region->data = &pixman_region_emptyData;
- }
+ region->extents.x1 = x;
+ region->extents.y1 = y;
+ region->extents.x2 = x + width;
+ region->extents.y2 = y + height;
+ region->data = NULL;
+}
+
+void
+pixman_region_init_with_extents(pixman_region16_t *region, pixman_box16_t *extents)
+{
+ region->extents = *extents;
+ region->data = NULL;
}
void
@@ -1093,7 +1098,7 @@ pixman_region_unionO (
/* Convenience function for performing union of region with a single rectangle */
pixman_region_status_t
pixman_region_union_rect(pixman_region16_t *dest, pixman_region16_t *source,
- int x, int y, unsigned int width, unsigned int height)
+ int x, int y, unsigned int width, unsigned int height)
{
pixman_region16_t region;
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 770be12..b27088d 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -61,7 +61,7 @@ _cairo_clip_init (cairo_clip_t *clip, ca
clip->serial = 0;
- pixman_region_init (&clip->region, NULL);
+ pixman_region_init (&clip->region);
clip->has_region = FALSE;
clip->path = NULL;
@@ -77,7 +77,7 @@ _cairo_clip_init_copy (cairo_clip_t *cli
clip->serial = other->serial;
- pixman_region_init (&clip->region, NULL);
+ pixman_region_init (&clip->region);
if (other->has_region) {
pixman_region_copy (&clip->region, &other->region);
@@ -103,7 +103,7 @@ _cairo_clip_reset (cairo_clip_t *clip)
* doesn't bother with leaving the region in a valid state.
* So pixman_region_init has to be called afterwards. */
pixman_region_uninit (&clip->region);
- pixman_region_init (&clip->region, NULL);
+ pixman_region_init (&clip->region);
clip->has_region = FALSE;
}
@@ -167,8 +167,9 @@ _cairo_clip_intersect_to_rectangle (cair
cairo_status_t status = CAIRO_STATUS_SUCCESS;
pixman_region16_t intersection;
- if (_cairo_region_init_from_rectangle (&intersection, rectangle))
- return CAIRO_STATUS_NO_MEMORY;
+ pixman_region_init_rect (&intersection,
+ rectangle->x, rectangle->y,
+ rectangle->width, rectangle->height);
if (PIXMAN_REGION_STATUS_SUCCESS !=
pixman_region_intersect (&intersection, &clip->region,
@@ -208,8 +209,9 @@ _cairo_clip_intersect_to_region (cairo_c
cairo_status_t status = CAIRO_STATUS_SUCCESS;
pixman_region16_t clip_rect;
- if (_cairo_region_init_from_rectangle (&clip_rect, &clip->surface_rect))
- return CAIRO_STATUS_NO_MEMORY;
+ pixman_region_init_rect (&clip_rect,
+ clip->surface_rect.x, clip->surface_rect.y,
+ clip->surface_rect.width, clip->surface_rect.height);
if (PIXMAN_REGION_STATUS_SUCCESS !=
pixman_region_intersect (region, &clip_rect, region))
@@ -339,7 +341,7 @@ _cairo_clip_intersect_region (cairo_clip
clip->has_region = TRUE;
} else {
pixman_region16_t intersection;
- pixman_region_init (&intersection, NULL);
+ pixman_region_init (&intersection);
if (PIXMAN_REGION_STATUS_SUCCESS ==
pixman_region_intersect (&intersection, &clip->region, ®ion)) {
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 7d7b2b4..ceaa4b4 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -1284,7 +1284,7 @@ _cairo_glitz_surface_set_clip_region (vo
int n;
if (!surface->has_clip) {
- pixman_region_init (&surface->clip, NULL);
+ pixman_region_init (&surface->clip);
surface->has_clip = TRUE;
}
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 1e1c86f..c675a18 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -36,31 +36,6 @@
#include "cairoint.h"
/**
- * _cairo_region_init_from_rectangle:
- * @region: a #pixman_region16_t
- * @rect: a #cairo_rectangle_int16_t
- *
- * Initializes a region with extents from the given rectangle.
- *
- * Return value: #CAIRO_STATUS_SUCCESS on success, or
- * #CAIRO_STATUS_NO_MEMORY when pixman fails to initialize
- * the region.
- **/
-cairo_status_t
-_cairo_region_init_from_rectangle (pixman_region16_t *region,
- cairo_rectangle_int16_t *rect)
-{
- pixman_region_init (region, NULL);
-
- if (PIXMAN_REGION_STATUS_SUCCESS == pixman_region_union_rect (
- region, region, rect->x, rect->y, rect->width, rect->height))
- return CAIRO_STATUS_SUCCESS;
-
- pixman_region_uninit (region);
- return CAIRO_STATUS_NO_MEMORY;
-}
-
-/**
* _cairo_region_extents_rectangle:
* @region: a #pixman_region16_t
* @rect: rectangle into which to store the extents
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index b950145..a9b8e3b 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -567,10 +567,9 @@ _clip_and_composite_trapezoids (cairo_pa
* _cairo_surface_fill_rectangles() or to drawing with a
* clip region, then we have an additional region to clear.
*/
- if (_cairo_region_init_from_rectangle (&clear_region, &extents)) {
- status = CAIRO_STATUS_NO_MEMORY;
- goto out;
- }
+ pixman_region_init_rect (&clear_region,
+ extents.x, extents.y,
+ extents.width, extents.height);
has_clear_region = TRUE;
status = _cairo_clip_intersect_to_region (clip, &clear_region);
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 7f30c33..5630fed 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1893,18 +1893,14 @@ _cairo_surface_composite_fixup_unbounded
/* Now compute the area that is in dst_rectangle but not in drawn_rectangle
*/
- if (_cairo_region_init_from_rectangle (&drawn_region, &drawn_rectangle)) {
- status = CAIRO_STATUS_NO_MEMORY;
- goto CLEANUP_REGIONS;
- }
+ pixman_region_init_rect (&drawn_region,
+ drawn_rectangle.x, drawn_rectangle.y,
+ drawn_rectangle.width, drawn_rectangle.height);
+ pixman_region_init_rect (&clear_region,
+ dst_rectangle.x, dst_rectangle.y,
+ dst_rectangle.width, dst_rectangle.height);
has_drawn_region = TRUE;
-
- if (_cairo_region_init_from_rectangle (&clear_region, &dst_rectangle)) {
- status = CAIRO_STATUS_NO_MEMORY;
- goto CLEANUP_REGIONS;
- }
-
has_clear_region = TRUE;
if (PIXMAN_REGION_STATUS_SUCCESS !=
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 3e5a0f6..c2707ef 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -553,7 +553,7 @@ _cairo_traps_extract_region (cairo_traps
return CAIRO_INT_STATUS_UNSUPPORTED;
}
- pixman_region_init (region, NULL);
+ pixman_region_init (region);
for (i = 0; i < traps->num_traps; i++) {
int x = _cairo_fixed_integer_part(traps->traps[i].left.p1.x);
diff --git a/src/cairoint.h b/src/cairoint.h
index 2741dc7..77eda90 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2429,10 +2429,6 @@ _cairo_gstate_get_antialias (cairo_gstat
/* cairo-region.c */
-cairo_private cairo_status_t
-_cairo_region_init_from_rectangle (pixman_region16_t *region,
- cairo_rectangle_int16_t *rect);
-
cairo_private void
_cairo_region_extents_rectangle (pixman_region16_t *region,
cairo_rectangle_int16_t *rect);
diff-tree 9436959a838412b5336279c7d5c35bf4e586f984 (from 99f4bfada807aa7062051bb81fd29d4d3a87fbd1)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 01:37:28 2007 +0100
Update function map
diff --git a/pixman/src/pixman-remap.h b/pixman/src/pixman-remap.h
index 290df32..d92cf5a 100644
--- a/pixman/src/pixman-remap.h
+++ b/pixman/src/pixman-remap.h
@@ -56,9 +56,8 @@
#define pixman_region_contains_point _cairo_pixman_region_contains_point
#define pixman_region_contains_rectangle _cairo_pixman_region_contains_rectangle
#define pixman_region_copy _cairo_pixman_region_copy
-#define pixman_region_create _cairo_pixman_region_create
-#define pixman_region_create_simple _cairo_pixman_region_create_simple
-#define pixman_region_destroy _cairo_pixman_region_destroy
+#define pixman_region_init _cairo_pixman_region_init
+#define pixman_region_uninit _cairo_pixman_region_uninit
#define pixman_region_empty _cairo_pixman_region_empty
#define pixman_region_extents _cairo_pixman_region_extents
#define pixman_region_intersect _cairo_pixman_region_intersect
diff-tree 99f4bfada807aa7062051bb81fd29d4d3a87fbd1 (from 4532c023e0810c2e8d0d5928074bcae8865c5e14)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 01:35:40 2007 +0100
Remove abdoned pixman_region_{create,destroy}
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index f5c5684..3f6830a 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -131,17 +131,11 @@ typedef enum {
/* creation/destruction */
-pixman_private pixman_region16_t *
-pixman_region_create (void);
-
pixman_private void
pixman_region_init(pixman_region16_t *region, pixman_box16_t *extents);
pixman_private void
pixman_region_uninit (pixman_region16_t *region);
-pixman_private void
-pixman_region_destroy (pixman_region16_t *region);
-
/* manipulation */
pixman_private void
diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index 08f48c7..a1bfd21 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -75,7 +75,6 @@ static pixman_box16_t pixman_region_empt
static pixman_region16_data_t pixman_region_emptyData = {0, 0};
static pixman_region16_data_t pixman_brokendata = {0, 0};
-static pixman_region16_t pixman_brokenregion = { { 0, 0, 0, 0 }, &pixman_brokendata };
static pixman_region_status_t
pixman_break (pixman_region16_t *pReg);
@@ -289,21 +288,6 @@ pixman_region16_valid(reg)
#endif /* DEBUG_PIXREGION */
-/* Create a new empty region */
-pixman_region16_t *
-pixman_region_create (void)
-{
- pixman_region16_t *region;
-
- region = malloc (sizeof (pixman_region16_t));
- if (region == NULL)
- return &pixman_brokenregion;
-
- pixman_region_init (region, NULL);
-
- return region;
-}
-
/*****************************************************************
* RegionInit(pReg, rect, size)
* Outer region rect is statically allocated.
@@ -331,15 +315,6 @@ pixman_region_uninit (pixman_region16_t
freeData (region);
}
-void
-pixman_region_destroy (pixman_region16_t *region)
-{
- pixman_region_uninit (region);
-
- if (region != &pixman_brokenregion)
- free (region);
-}
-
int
pixman_region_num_rects (pixman_region16_t *region)
{
diff-tree 4532c023e0810c2e8d0d5928074bcae8865c5e14 (from 65f269f3a4148a6cf3b2158ea893bb8452c3ad5e)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 01:31:53 2007 +0100
Make clientClip region static, remove abdoned CT_PIXMAP code paths
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 9de0a4c..9d336eb 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -319,7 +319,6 @@ pixman_image_init (pixman_image_t *image
image->clipOrigin.x = 0;
image->clipOrigin.y = 0;
- image->clientClip = NULL;
image->dither = 0L;
@@ -514,17 +513,9 @@ pixman_image_destroy (pixman_image_t *im
void
pixman_image_destroyClip (pixman_image_t *image)
{
- switch (image->clientClipType) {
- case CT_NONE:
- return;
- case CT_PIXMAP:
- pixman_image_destroy (image->clientClip);
- break;
- default:
- pixman_region_destroy (image->clientClip);
- break;
- }
- image->clientClip = NULL;
+ if (CT_NONE != image->clientClipType)
+ pixman_region_uninit (&image->clientClip);
+
image->clientClipType = CT_NONE;
}
@@ -533,9 +524,10 @@ pixman_image_set_clip_region (pixman_ima
pixman_region16_t *region)
{
pixman_image_destroyClip (image);
+
if (region) {
- image->clientClip = pixman_region_create ();
- pixman_region_copy (image->clientClip, region);
+ pixman_region_init (&image->clientClip, NULL);
+ pixman_region_copy (&image->clientClip, region);
image->clientClipType = CT_REGION;
}
@@ -622,7 +614,7 @@ FbClipImageSrc (pixman_region16_t *regio
pixman_region_translate (region,
dx - image->clipOrigin.x,
dy - image->clipOrigin.y);
- pixman_region_intersect (region, image->clientClip, region);
+ pixman_region_intersect (region, &image->clientClip, region);
pixman_region_translate (region,
- (dx - image->clipOrigin.x),
- (dy - image->clipOrigin.y));
@@ -644,192 +636,6 @@ FbClipImageSrc (pixman_region16_t *regio
return 1;
}
-/* XXX: Need to decide what to do with this
-#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val)
-
-#define NEXT_PTR(_type) ((_type) ulist++->ptr)
-
-int
-pixman_image_change (pixman_image_t *image,
- Mask vmask,
- unsigned int *vlist,
- DevUnion *ulist,
- int *error_value)
-{
- BITS32 index2;
- int error = 0;
- BITS32 maskQ;
-
- maskQ = vmask;
- while (vmask && !error)
- {
- index2 = (BITS32) lowbit (vmask);
- vmask &= ~index2;
- image->stateChanges |= index2;
- switch (index2)
- {
- case CPRepeat:
- {
- unsigned int newr;
- newr = NEXT_VAL(unsigned int);
- if (newr <= xTrue)
- image->repeat = newr;
- else
- {
- *error_value = newr;
- error = BadValue;
- }
- }
- break;
- case CPAlphaMap:
- {
- pixman_image_t *iAlpha;
-
- iAlpha = NEXT_PTR(pixman_image_t *);
- if (iAlpha)
- iAlpha->refcnt++;
- if (image->alphaMap)
- pixman_image_destroy ((void *) image->alphaMap);
- image->alphaMap = iAlpha;
- }
- break;
- case CPAlphaXOrigin:
- image->alphaOrigin.x = NEXT_VAL(int16_t);
- break;
- case CPAlphaYOrigin:
- image->alphaOrigin.y = NEXT_VAL(int16_t);
- break;
- case CPClipXOrigin:
- image->clipOrigin.x = NEXT_VAL(int16_t);
- break;
- case CPClipYOrigin:
- image->clipOrigin.y = NEXT_VAL(int16_t);
- break;
- case CPClipMask:
- {
- pixman_image_t *mask;
- int clipType;
-
- mask = NEXT_PTR(pixman_image_t *);
- if (mask) {
- clipType = CT_PIXMAP;
- mask->refcnt++;
- } else {
- clipType = CT_NONE;
- }
- error = pixman_image_change_clip (image, clipType,
- (void *)mask, 0);
- break;
- }
- case CPGraphicsExposure:
- {
- unsigned int newe;
- newe = NEXT_VAL(unsigned int);
- if (newe <= xTrue)
- image->graphicsExposures = newe;
- else
- {
- *error_value = newe;
- error = BadValue;
- }
- }
- break;
- case CPSubwindowMode:
- {
- unsigned int news;
- news = NEXT_VAL(unsigned int);
- if (news == ClipByChildren || news == IncludeInferiors)
- image->subWindowMode = news;
- else
- {
- *error_value = news;
- error = BadValue;
- }
- }
- break;
- case CPPolyEdge:
- {
- unsigned int newe;
- newe = NEXT_VAL(unsigned int);
- if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth)
- image->polyEdge = newe;
- else
- {
- *error_value = newe;
- error = BadValue;
- }
- }
- break;
- case CPPolyMode:
- {
- unsigned int newm;
- newm = NEXT_VAL(unsigned int);
- if (newm == PolyModePrecise || newm == PolyModeImprecise)
- image->polyMode = newm;
- else
- {
- *error_value = newm;
- error = BadValue;
- }
- }
- break;
- case CPDither:
- image->dither = NEXT_VAL(unsigned long);
- break;
- case CPComponentAlpha:
- {
- unsigned int newca;
-
- newca = NEXT_VAL (unsigned int);
- if (newca <= xTrue)
- image->componentAlpha = newca;
- else
- {
- *error_value = newca;
- error = BadValue;
- }
- }
- break;
- default:
- *error_value = maskQ;
- error = BadValue;
- break;
- }
- }
- return error;
-}
-*/
-
-/* XXX: Do we need this?
-int
-SetPictureClipRects (PicturePtr pPicture,
- int xOrigin,
- int yOrigin,
- int nRect,
- xRectangle *rects)
-{
- ScreenPtr pScreen = pPicture->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- pixman_region16_t *clientClip;
- int result;
-
- clientClip = RECTS_TO_REGION(pScreen,
- nRect, rects, CT_UNSORTED);
- if (!clientClip)
- return 1;
- result =(*ps->ChangePictureClip) (pPicture, CT_REGION,
- (void *) clientClip, 0);
- if (result == 0)
- {
- pPicture->clipOrigin.x = xOrigin;
- pPicture->clipOrigin.y = yOrigin;
- pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
- pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
- }
- return result;
-}
-*/
-
int
FbComputeCompositeRegion (pixman_region16_t *region,
pixman_image_t *iSrc,
diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h
index 412687e..b983429 100644
--- a/pixman/src/icimage.h
+++ b/pixman/src/icimage.h
@@ -154,13 +154,13 @@ struct pixman_image {
FbPoint alphaOrigin;
FbPoint clipOrigin;
- void *clientClip;
unsigned long dither;
unsigned long stateChanges;
unsigned long serialNumber;
+ pixman_region16_t clientClip;
pixman_region16_t compositeClip;
pixman_region16_t sourceClip;
diff --git a/pixman/src/icint.h b/pixman/src/icint.h
index 0dc82aa..1d0e59b 100644
--- a/pixman/src/icint.h
+++ b/pixman/src/icint.h
@@ -778,7 +778,7 @@ fbRasterizeTrapezoid (pixman_image_t *p
/* XXX: This is to avoid including gc.h from the server includes */
/* clientClipType field in GC */
#define CT_NONE 0
-#define CT_PIXMAP 1
+/* #define CT_PIXMAP 1 (not used anymore) */
#define CT_REGION 2
#define CT_UNSORTED 6
#define CT_YSORTED 10
diff-tree 65f269f3a4148a6cf3b2158ea893bb8452c3ad5e (from 82cc451148eec1703d001f2b814d5b3712d31727)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 01:24:11 2007 +0100
Avoid pixman_region_create in pixman_composite{,General}
diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 3acf32b..1bd7ab9 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -4198,7 +4198,7 @@ pixman_compositeGeneral (pixman_operator
CARD16 width,
CARD16 height)
{
- pixman_region16_t *region;
+ pixman_region16_t region;
int n;
BoxPtr pbox;
Bool srcRepeat = FALSE;
@@ -4219,22 +4219,12 @@ pixman_compositeGeneral (pixman_operator
if (op == PIXMAN_OPERATOR_OVER && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format_code) && !pSrc->alphaMap)
op = PIXMAN_OPERATOR_SRC;
- region = pixman_region_create();
- pixman_region_union_rect (region, region, xDst, yDst, width, height);
+ pixman_region_init (®ion, NULL);
+ pixman_region_union_rect (®ion, ®ion, xDst, yDst, width, height);
- if (!FbComputeCompositeRegion (region,
- pSrc,
- pMask,
- pDst,
- xSrc,
- ySrc,
- xMask,
- yMask,
- xDst,
- yDst,
- width,
- height))
- return;
+ if (!FbComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height))
+ goto CLEANUP_REGION;
compose_data.op = op;
compose_data.src = pSrc;
@@ -4243,8 +4233,8 @@ pixman_compositeGeneral (pixman_operator
if (width > SCANLINE_BUFFER_LENGTH)
scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32));
- n = pixman_region_num_rects (region);
- pbox = pixman_region_rects (region);
+ n = pixman_region_num_rects (®ion);
+ pbox = pixman_region_rects (®ion);
while (n--)
{
h = pbox->y2 - pbox->y1;
@@ -4298,10 +4288,12 @@ pixman_compositeGeneral (pixman_operator
}
pbox++;
}
- pixman_region_destroy (region);
if (scanline_buffer != _scanline_buffer)
free(scanline_buffer);
+
+CLEANUP_REGION:
+ pixman_region_uninit (®ion);
}
#endif
diff --git a/pixman/src/fbpict.c b/pixman/src/fbpict.c
index 5afcd05..3fd4aa9 100644
--- a/pixman/src/fbpict.c
+++ b/pixman/src/fbpict.c
@@ -1390,7 +1390,7 @@ pixman_composite (pixman_operator_t op,
int width,
int height)
{
- pixman_region16_t *region;
+ pixman_region16_t region;
int n;
pixman_box16_t *pbox;
CompositeFunc func = NULL;
@@ -1933,25 +1933,15 @@ pixman_composite (pixman_operator_t op,
if (maskTransform)
maskRepeat = 0;
- region = pixman_region_create();
- pixman_region_union_rect (region, region, xDst, yDst, width, height);
+ pixman_region_init (®ion, NULL);
+ pixman_region_union_rect (®ion, ®ion, xDst, yDst, width, height);
- if (!FbComputeCompositeRegion (region,
- pSrc,
- pMask,
- pDst,
- xSrc,
- ySrc,
- xMask,
- yMask,
- xDst,
- yDst,
- width,
- height))
- return;
+ if (!FbComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height))
+ goto CLEANUP_REGION;
- n = pixman_region_num_rects (region);
- pbox = pixman_region_rects (region);
+ n = pixman_region_num_rects (®ion);
+ pbox = pixman_region_rects (®ion);
while (n--)
{
h = pbox->y2 - pbox->y1;
@@ -2007,7 +1997,9 @@ pixman_composite (pixman_operator_t op,
}
pbox++;
}
- pixman_region_destroy (region);
+
+CLEANUP_REGION:
+ pixman_region_uninit (®ion);
}
/* The CPU detection code needs to be in a file not compiled with
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 1cacf66..9de0a4c 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -858,67 +858,47 @@ FbComputeCompositeRegion (pixman_region1
y1 = yDst;
v = yDst + height;
y2 = BOUND(v);
+
/* Check for empty operation */
- if (x1 >= x2 ||
- y1 >= y2)
- {
+ if (x1 >= x2 || y1 >= y2) {
pixman_region_empty (region);
return 1;
}
+
/* clip against src */
if (!FbClipImageSrc (region, iSrc, xDst - xSrc, yDst - ySrc))
- {
- pixman_region_destroy (region);
return 0;
- }
- if (iSrc->alphaMap)
- {
- if (!FbClipImageSrc (region, iSrc->alphaMap,
- xDst - (xSrc + iSrc->alphaOrigin.x),
- yDst - (ySrc + iSrc->alphaOrigin.y)))
- {
- pixman_region_destroy (region);
- return 0;
- }
- }
+
+ if (iSrc->alphaMap &&
+ !FbClipImageSrc (region, iSrc->alphaMap,
+ xDst - (xSrc + iSrc->alphaOrigin.x),
+ yDst - (ySrc + iSrc->alphaOrigin.y)))
+ return 0;
+
/* clip against mask */
- if (iMask)
- {
+ if (iMask) {
if (!FbClipImageSrc (region, iMask, xDst - xMask, yDst - yMask))
- {
- pixman_region_destroy (region);
return 0;
- }
- if (iMask->alphaMap)
- {
- if (!FbClipImageSrc (region, iMask->alphaMap,
- xDst - (xMask + iMask->alphaOrigin.x),
- yDst - (yMask + iMask->alphaOrigin.y)))
- {
- pixman_region_destroy (region);
- return 0;
- }
- }
+
+ if (iMask->alphaMap &&
+ !FbClipImageSrc (region, iMask->alphaMap,
+ xDst - (xMask + iMask->alphaOrigin.x),
+ yDst - (yMask + iMask->alphaOrigin.y)))
+ return 0;
}
if (!FbClipImageReg (region,
iDst->hasCompositeClip ?
&iDst->compositeClip : NULL,
- 0, 0)) {
- pixman_region_destroy (region);
+ 0, 0))
return 0;
- }
- if (iDst->alphaMap) {
- if (!FbClipImageReg (region,
- iDst->hasCompositeClip ?
- &iDst->alphaMap->compositeClip : NULL,
- -iDst->alphaOrigin.x,
- -iDst->alphaOrigin.y)) {
- pixman_region_destroy (region);
- return 0;
- }
- }
+ if (iDst->alphaMap &&
+ !FbClipImageReg (region,
+ iDst->hasCompositeClip ?
+ &iDst->alphaMap->compositeClip : NULL,
+ -iDst->alphaOrigin.x, -iDst->alphaOrigin.y))
+ return 0;
return 1;
}
diff-tree 82cc451148eec1703d001f2b814d5b3712d31727 (from 041371533746d4aae3245a74459c0b0d1a4628fb)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 01:21:18 2007 +0100
Make clip regions of pixman_image_t static
diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 66bbe30..3acf32b 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -3374,8 +3374,8 @@ static void fbFetchTransformed(PicturePt
if (pict->filter == PIXMAN_FILTER_NEAREST || pict->filter == PIXMAN_FILTER_FAST)
{
if (pict->repeat == RepeatNormal) {
- if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
- box = pict->pSourceClip->extents;
+ if (PIXREGION_NUM_RECTS(&pict->sourceClip) == 1) {
+ box = pict->sourceClip.extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3410,7 +3410,7 @@ static void fbFetchTransformed(PicturePt
y = MOD(v.vector[1]>>16, pict->pDrawable->height);
x = MOD(v.vector[0]>>16, pict->pDrawable->width);
}
- if (pixman_region_contains_point (pict->pSourceClip, x, y, &box))
+ if (pixman_region_contains_point (&pict->sourceClip, x, y, &box))
buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
else
buffer[i] = 0;
@@ -3422,8 +3422,8 @@ static void fbFetchTransformed(PicturePt
}
}
} else {
- if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
- box = pict->pSourceClip->extents;
+ if (PIXREGION_NUM_RECTS(&pict->sourceClip) == 1) {
+ box = pict->sourceClip.extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3457,7 +3457,7 @@ static void fbFetchTransformed(PicturePt
y = v.vector[1]>>16;
x = v.vector[0]>>16;
}
- if (pixman_region_contains_point (pict->pSourceClip, x, y, &box))
+ if (pixman_region_contains_point (&pict->sourceClip, x, y, &box))
buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
else
buffer[i] = 0;
@@ -3476,8 +3476,8 @@ static void fbFetchTransformed(PicturePt
unit.vector[1] -= unit.vector[2]/2;
if (pict->repeat == RepeatNormal) {
- if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
- box = pict->pSourceClip->extents;
+ if (PIXREGION_NUM_RECTS(&pict->sourceClip) == 1) {
+ box = pict->sourceClip.extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3580,14 +3580,14 @@ static void fbFetchTransformed(PicturePt
b = bits + (y1 + pict->pDrawable->y)*stride;
- tl = pixman_region_contains_point(pict->pSourceClip, x1, y1, &box)
+ tl = pixman_region_contains_point(&pict->sourceClip, x1, y1, &box)
? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
- tr = pixman_region_contains_point(pict->pSourceClip, x2, y1, &box)
+ tr = pixman_region_contains_point(&pict->sourceClip, x2, y1, &box)
? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
b = bits + (y2 + pict->pDrawable->y)*stride;
- bl = pixman_region_contains_point(pict->pSourceClip, x1, y2, &box)
+ bl = pixman_region_contains_point(&pict->sourceClip, x1, y2, &box)
? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
- br = pixman_region_contains_point(pict->pSourceClip, x2, y2, &box)
+ br = pixman_region_contains_point(&pict->sourceClip, x2, y2, &box)
? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
@@ -3611,8 +3611,8 @@ static void fbFetchTransformed(PicturePt
}
}
} else {
- if (PIXREGION_NUM_RECTS(pict->pSourceClip) == 1) {
- box = pict->pSourceClip->extents;
+ if (PIXREGION_NUM_RECTS(&pict->sourceClip) == 1) {
+ box = pict->sourceClip.extents;
for (i = 0; i < width; ++i) {
if (!mask || mask[i] & maskBits)
{
@@ -3713,14 +3713,14 @@ static void fbFetchTransformed(PicturePt
b = bits + (y1 + pict->pDrawable->y)*stride;
x_off = x1 + pict->pDrawable->x;
- tl = pixman_region_contains_point(pict->pSourceClip, x1, y1, &box)
+ tl = pixman_region_contains_point(&pict->sourceClip, x1, y1, &box)
? fetch(b, x_off, indexed) : 0;
- tr = pixman_region_contains_point(pict->pSourceClip, x2, y1, &box)
+ tr = pixman_region_contains_point(&pict->sourceClip, x2, y1, &box)
? fetch(b, x_off + 1, indexed) : 0;
b += stride;
- bl = pixman_region_contains_point(pict->pSourceClip, x1, y2, &box)
+ bl = pixman_region_contains_point(&pict->sourceClip, x1, y2, &box)
? fetch(b, x_off, indexed) : 0;
- br = pixman_region_contains_point(pict->pSourceClip, x2, y2, &box)
+ br = pixman_region_contains_point(&pict->sourceClip, x2, y2, &box)
? fetch(b, x_off + 1, indexed) : 0;
ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
@@ -3782,7 +3782,7 @@ static void fbFetchTransformed(PicturePt
for (x = x1; x < x2; x++) {
if (*p) {
int tx = (pict->repeat == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
- if (pixman_region_contains_point (pict->pSourceClip, tx, ty, &box)) {
+ if (pixman_region_contains_point (&pict->sourceClip, tx, ty, &box)) {
FbBits *b = bits + (ty + pict->pDrawable->y)*stride;
CARD32 c = fetch(b, tx + pict->pDrawable->x, indexed);
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 7227dd6..1cacf66 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -307,8 +307,8 @@ pixman_image_init (pixman_image_t *image
* In the server this was 0 because the composite clip list
* can be referenced from a window (and often is)
*/
- image->freeCompClip = 0;
- image->freeSourceClip = 0;
+ image->hasCompositeClip = 0;
+ image->hasSourceClip = 0;
image->clientClipType = CT_NONE;
image->componentAlpha = 0;
image->compositeClipSource = 0;
@@ -328,24 +328,34 @@ pixman_image_init (pixman_image_t *image
image->serialNumber = GC_CHANGE_SERIAL_BIT;
*/
- if (image->pixels)
- {
- image->pCompositeClip = pixman_region_create();
- pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
+ if (image->pixels) {
+ if (!image->hasCompositeClip) {
+ pixman_region_init (&image->compositeClip, NULL);
+ image->hasCompositeClip = 1;
+ }
+
+ pixman_region_union_rect (&image->compositeClip, &image->compositeClip,
0, 0, image->pixels->width,
image->pixels->height);
- image->freeCompClip = 1;
- image->pSourceClip = pixman_region_create ();
- pixman_region_union_rect (image->pSourceClip, image->pSourceClip,
+ if (!image->hasSourceClip) {
+ pixman_region_init (&image->sourceClip, NULL);
+ image->hasSourceClip = 1;
+ }
+
+ pixman_region_union_rect (&image->sourceClip, &image->sourceClip,
0, 0, image->pixels->width,
image->pixels->height);
- image->freeSourceClip = 1;
- }
- else
- {
- image->pCompositeClip = NULL;
- image->pSourceClip = NULL;
+ } else {
+ if (image->hasCompositeClip) {
+ pixman_region_uninit (&image->compositeClip);
+ image->hasCompositeClip = FALSE;
+ }
+
+ if (image->hasSourceClip) {
+ pixman_region_uninit (&image->sourceClip);
+ image->hasSourceClip = FALSE;
+ }
}
image->transform = NULL;
@@ -473,14 +483,14 @@ pixman_image_destroy (pixman_image_t *im
{
pixman_image_destroyClip (image);
- if (image->freeCompClip) {
- pixman_region_destroy (image->pCompositeClip);
- image->pCompositeClip = NULL;
+ if (image->hasCompositeClip) {
+ pixman_region_uninit (&image->compositeClip);
+ image->hasCompositeClip = 0;
}
- if (image->freeSourceClip) {
- pixman_region_destroy (image->pSourceClip);
- image->pSourceClip = NULL;
+ if (image->hasSourceClip) {
+ pixman_region_uninit (&image->sourceClip);
+ image->hasSourceClip = 0;
}
if (image->owns_pixels) {
@@ -533,20 +543,22 @@ pixman_image_set_clip_region (pixman_ima
if (image->pSourcePict)
return 0;
- if (image->freeCompClip)
- pixman_region_destroy (image->pCompositeClip);
- image->pCompositeClip = pixman_region_create();
- pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
+ if (image->hasCompositeClip)
+ pixman_region_uninit (&image->compositeClip);
+
+ pixman_region_init (&image->compositeClip, NULL);
+ pixman_region_union_rect (&image->compositeClip, &image->compositeClip,
0, 0, image->pixels->width, image->pixels->height);
- image->freeCompClip = 1;
+ image->hasCompositeClip = 1;
+
if (region) {
- pixman_region_translate (image->pCompositeClip,
+ pixman_region_translate (&image->compositeClip,
- image->clipOrigin.x,
- image->clipOrigin.y);
- pixman_region_intersect (image->pCompositeClip,
- image->pCompositeClip,
+ pixman_region_intersect (&image->compositeClip,
+ &image->compositeClip,
region);
- pixman_region_translate (image->pCompositeClip,
+ pixman_region_translate (&image->compositeClip,
image->clipOrigin.x,
image->clipOrigin.y);
}
@@ -601,13 +613,12 @@ FbClipImageSrc (pixman_region16_t *regio
/* XXX what to do with clipping from transformed pictures? */
if (image->transform)
return 1;
+
/* XXX davidr hates this, wants to never use source-based clipping */
- if (image->repeat != PIXMAN_REPEAT_NONE || image->pSourcePict)
- {
+ if (image->repeat != PIXMAN_REPEAT_NONE || image->pSourcePict) {
/* XXX no source clipping */
if (image->compositeClipSource &&
- image->clientClipType != CT_NONE)
- {
+ image->clientClipType != CT_NONE) {
pixman_region_translate (region,
dx - image->clipOrigin.x,
dy - image->clipOrigin.y);
@@ -616,21 +627,20 @@ FbClipImageSrc (pixman_region16_t *regio
- (dx - image->clipOrigin.x),
- (dy - image->clipOrigin.y));
}
+
return 1;
- }
- else
- {
- pixman_region16_t *clip;
+ } else {
+ pixman_region16_t *clip;
+
+ if (image->compositeClipSource) {
+ clip = (image->hasCompositeClip ? &image->compositeClip : NULL);
+ } else {
+ clip = (image->hasSourceClip ? &image->sourceClip : NULL);
+ }
- if (image->compositeClipSource)
- clip = image->pCompositeClip;
- else
- clip = image->pSourceClip;
- return FbClipImageReg (region,
- clip,
- dx,
- dy);
+ return FbClipImageReg (region, clip, dx, dy);
}
+
return 1;
}
@@ -890,21 +900,26 @@ FbComputeCompositeRegion (pixman_region1
}
}
}
- if (!FbClipImageReg (region, iDst->pCompositeClip, 0, 0))
- {
+
+ if (!FbClipImageReg (region,
+ iDst->hasCompositeClip ?
+ &iDst->compositeClip : NULL,
+ 0, 0)) {
pixman_region_destroy (region);
return 0;
}
- if (iDst->alphaMap)
- {
- if (!FbClipImageReg (region, iDst->alphaMap->pCompositeClip,
+
+ if (iDst->alphaMap) {
+ if (!FbClipImageReg (region,
+ iDst->hasCompositeClip ?
+ &iDst->alphaMap->compositeClip : NULL,
-iDst->alphaOrigin.x,
- -iDst->alphaOrigin.y))
- {
+ -iDst->alphaOrigin.y)) {
pixman_region_destroy (region);
return 0;
}
}
+
return 1;
}
diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h
index bbf41b9..412687e 100644
--- a/pixman/src/icimage.h
+++ b/pixman/src/icimage.h
@@ -143,8 +143,8 @@ struct pixman_image {
unsigned int subWindowMode : 1;
unsigned int polyEdge : 1;
unsigned int polyMode : 1;
- unsigned int freeCompClip : 1;
- unsigned int freeSourceClip : 1;
+ unsigned int hasCompositeClip : 1;
+ unsigned int hasSourceClip : 1;
unsigned int clientClipType : 2;
unsigned int componentAlpha : 1;
unsigned int compositeClipSource : 1;
@@ -161,8 +161,8 @@ struct pixman_image {
unsigned long stateChanges;
unsigned long serialNumber;
- pixman_region16_t *pCompositeClip;
- pixman_region16_t *pSourceClip;
+ pixman_region16_t compositeClip;
+ pixman_region16_t sourceClip;
pixman_transform_t *transform;
diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c
index 44e97b0..af4311a 100644
--- a/pixman/src/icrect.c
+++ b/pixman/src/icrect.c
@@ -209,13 +209,16 @@ pixman_color_rects (pixman_image_t *dst
dst->pixels->x, dst->pixels->y,
dst->pixels->width, dst->pixels->height);
- pixman_region_intersect (&clip, &clip, clipPict->pCompositeClip);
+ pixman_region_intersect (&clip, &clip, clipPict->hasCompositeClip ?
+ &clipPict->compositeClip : NULL);
if (clipPict->alphaMap)
{
pixman_region_translate (&clip,
-clipPict->alphaOrigin.x,
-clipPict->alphaOrigin.y);
- pixman_region_intersect (&clip, &clip, clipPict->alphaMap->pCompositeClip);
+ pixman_region_intersect (&clip, &clip,
+ clipPict->alphaMap->hasCompositeClip ?
+ &clipPict->alphaMap->compositeClip : NULL);
pixman_region_translate (&clip,
clipPict->alphaOrigin.x,
clipPict->alphaOrigin.y);
diff-tree 041371533746d4aae3245a74459c0b0d1a4628fb (from 5a6ca4794bfd96026937cd8736a8bcb723b2b2ff)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 00:59:36 2007 +0100
Avoid pixman_region_create in pixman_color_rects
diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c
index 5b64f96..44e97b0 100644
--- a/pixman/src/icrect.c
+++ b/pixman/src/icrect.c
@@ -189,9 +189,9 @@ pixman_color_rects (pixman_image_t *dst
int xoff,
int yoff)
{
- pixman_bits_t pixel;
- pixman_region16_t *clip;
- pixman_region16_t *rects_as_region;
+ pixman_bits_t pixel;
+ pixman_region16_t clip;
+ pixman_region16_t rects_as_region;
pixman_box16_t *clipped_rects;
int i, n_clipped_rects;
FillFunc func;
@@ -204,19 +204,19 @@ pixman_color_rects (pixman_image_t *dst
xoff -= dst->pixels->x;
yoff -= dst->pixels->y;
- clip = pixman_region_create();
- pixman_region_union_rect (clip, clip,
+ pixman_region_init (&clip, NULL);
+ pixman_region_union_rect (&clip, &clip,
dst->pixels->x, dst->pixels->y,
dst->pixels->width, dst->pixels->height);
- pixman_region_intersect (clip, clip, clipPict->pCompositeClip);
+ pixman_region_intersect (&clip, &clip, clipPict->pCompositeClip);
if (clipPict->alphaMap)
{
- pixman_region_translate (clip,
+ pixman_region_translate (&clip,
-clipPict->alphaOrigin.x,
-clipPict->alphaOrigin.y);
- pixman_region_intersect (clip, clip, clipPict->alphaMap->pCompositeClip);
- pixman_region_translate (clip,
+ pixman_region_intersect (&clip, &clip, clipPict->alphaMap->pCompositeClip);
+ pixman_region_translate (&clip,
clipPict->alphaOrigin.x,
clipPict->alphaOrigin.y);
}
@@ -230,19 +230,19 @@ pixman_color_rects (pixman_image_t *dst
}
}
- rects_as_region = pixman_region_create ();
+ pixman_region_init (&rects_as_region, NULL);
for (i = 0; i < nRect; i++)
{
- pixman_region_union_rect (rects_as_region, rects_as_region,
+ pixman_region_union_rect (&rects_as_region, &rects_as_region,
rects[i].x, rects[i].y,
rects[i].width, rects[i].height);
}
- pixman_region_intersect (rects_as_region, rects_as_region, clip);
- pixman_region_destroy (clip);
+ pixman_region_intersect (&rects_as_region, &rects_as_region, &clip);
+ pixman_region_uninit (&clip);
- n_clipped_rects = pixman_region_num_rects (rects_as_region);
- clipped_rects = pixman_region_rects (rects_as_region);
+ n_clipped_rects = pixman_region_num_rects (&rects_as_region);
+ clipped_rects = pixman_region_rects (&rects_as_region);
if (dst->pixels->bpp == 8)
func = pixman_fill_rect_8bpp;
@@ -262,7 +262,7 @@ pixman_color_rects (pixman_image_t *dst
&pixel);
}
- pixman_region_destroy (rects_as_region);
+ pixman_region_uninit (&rects_as_region);
if (xoff || yoff)
{
diff-tree 5a6ca4794bfd96026937cd8736a8bcb723b2b2ff (from f9057f27520842159f73dbfd6de49cb8feee1c39)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 00:55:46 2007 +0100
Replace pixman_region_create_simple by pixman_region_init
diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c
index 3e0186a..7a90cf0 100644
--- a/pixman/src/ictrap.c
+++ b/pixman/src/ictrap.c
@@ -116,7 +116,7 @@ pixman_composite_trapezoids (pixman_oper
{
pixman_image_t *image = NULL;
pixman_box16_t traps_bounds, dst_bounds, bounds;
- pixman_region16_t *traps_region, *dst_region;
+ pixman_region16_t traps_region, dst_region;
int16_t xDst, yDst;
int16_t xRel, yRel;
pixman_format_t *format;
@@ -139,7 +139,7 @@ pixman_composite_trapezoids (pixman_oper
pixman_trapezoid_bounds (ntraps, traps, &traps_bounds);
- traps_region = pixman_region_create_simple (&traps_bounds);
+ pixman_region_init (&traps_region, &traps_bounds);
/* XXX: If the image has a clip region set, we should really be
* fetching it here instead, but it looks like we don't yet expose
@@ -149,14 +149,14 @@ pixman_composite_trapezoids (pixman_oper
dst_bounds.x2 = pixman_image_get_width (dst);
dst_bounds.y2 = pixman_image_get_height (dst);
- dst_region = pixman_region_create_simple (&dst_bounds);
+ pixman_region_init (&dst_region, &dst_bounds);
- pixman_region_intersect (traps_region, traps_region, dst_region);
+ pixman_region_intersect (&traps_region, &traps_region, &dst_region);
- bounds = *(pixman_region_extents (traps_region));
+ bounds = *(pixman_region_extents (&traps_region));
- pixman_region_destroy (traps_region);
- pixman_region_destroy (dst_region);
+ pixman_region_uninit (&traps_region);
+ pixman_region_uninit (&dst_region);
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return;
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index df343b2..f5c5684 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -134,9 +134,6 @@ typedef enum {
pixman_private pixman_region16_t *
pixman_region_create (void);
-pixman_private pixman_region16_t *
-pixman_region_create_simple (pixman_box16_t *extents);
-
pixman_private void
pixman_region_init(pixman_region16_t *region, pixman_box16_t *extents);
pixman_private void
diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index e408eaf..08f48c7 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -293,24 +293,13 @@ pixman_region16_valid(reg)
pixman_region16_t *
pixman_region_create (void)
{
- return pixman_region_create_simple (NULL);
-}
-
-/*****************************************************************
- * pixman_region_create_simple (extents)
- * This routine creates a pixman_region16_t for a simple
- * rectangular region.
- *****************************************************************/
-pixman_region16_t *
-pixman_region_create_simple (pixman_box16_t *extents)
-{
pixman_region16_t *region;
region = malloc (sizeof (pixman_region16_t));
if (region == NULL)
return &pixman_brokenregion;
- pixman_region_init (region, extents);
+ pixman_region_init (region, NULL);
return region;
}
diff-tree f9057f27520842159f73dbfd6de49cb8feee1c39 (from 82cbb6886cf621fd6b10be5e04ce11ff05127fc6)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 00:48:43 2007 +0100
Avoid pixman_create_region in glitz-surface
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index b9e4f72..7d7b2b4 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -33,7 +33,8 @@ typedef struct _cairo_glitz_surface {
glitz_surface_t *surface;
glitz_format_t *format;
- pixman_region16_t *clip;
+ cairo_bool_t has_clip;
+ pixman_region16_t clip;
} cairo_glitz_surface_t;
static const cairo_surface_backend_t *
@@ -44,10 +45,9 @@ _cairo_glitz_surface_finish (void *abstr
{
cairo_glitz_surface_t *surface = abstract_surface;
- if (surface->clip)
- {
- glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0);
- pixman_region_destroy (surface->clip);
+ if (surface->has_clip) {
+ glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0);
+ pixman_region_uninit (&surface->clip);
}
glitz_surface_destroy (surface->surface);
@@ -208,7 +208,7 @@ _cairo_glitz_surface_get_image (cairo_gl
}
/* clear out the glitz clip; the clip affects glitz_get_pixels */
- if (surface->clip)
+ if (surface->has_clip)
glitz_surface_set_clip_region (surface->surface,
0, 0, NULL, 0);
@@ -221,12 +221,12 @@ _cairo_glitz_surface_get_image (cairo_gl
glitz_buffer_destroy (buffer);
/* restore the clip, if any */
- if (surface->clip) {
+ if (surface->has_clip) {
glitz_box_t *box;
int n;
- box = (glitz_box_t *) pixman_region_rects (surface->clip);
- n = pixman_region_num_rects (surface->clip);
+ box = (glitz_box_t *) pixman_region_rects (&surface->clip);
+ n = pixman_region_num_rects (&surface->clip);
glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
}
@@ -1283,26 +1283,25 @@ _cairo_glitz_surface_set_clip_region (vo
glitz_box_t *box;
int n;
- if (!surface->clip)
- {
- surface->clip = pixman_region_create ();
- if (!surface->clip)
- return CAIRO_STATUS_NO_MEMORY;
- }
- pixman_region_copy (surface->clip, region);
+ if (!surface->has_clip) {
+ pixman_region_init (&surface->clip, NULL);
+ surface->has_clip = TRUE;
+ }
+
+ pixman_region_copy (&surface->clip, region);
+ box = (glitz_box_t *) pixman_region_rects (&surface->clip);
+ n = pixman_region_num_rects (&surface->clip);
- box = (glitz_box_t *) pixman_region_rects (surface->clip);
- n = pixman_region_num_rects (surface->clip);
glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
}
else
{
glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0);
- if (surface->clip)
- pixman_region_destroy (surface->clip);
-
- surface->clip = NULL;
+ if (surface->has_clip) {
+ pixman_region_uninit (&surface->clip);
+ surface->has_clip = FALSE;
+ }
}
return CAIRO_STATUS_SUCCESS;
@@ -2240,9 +2239,9 @@ cairo_glitz_surface_create (glitz_surfac
glitz_surface_reference (surface);
- crsurface->surface = surface;
- crsurface->format = format;
- crsurface->clip = NULL;
+ crsurface->surface = surface;
+ crsurface->format = format;
+ crsurface->has_clip = FALSE;
return (cairo_surface_t *) crsurface;
}
diff-tree 82cbb6886cf621fd6b10be5e04ce11ff05127fc6 (from 5ae309c4561418fb057a8049f047ffcb03f3b698)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 00:46:34 2007 +0100
Remove redundant _cairo_clip_fini function
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index a2e8d9b..fbcb352 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -85,9 +85,6 @@ cairo_private void
_cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target);
cairo_private void
-_cairo_clip_fini (cairo_clip_t *clip);
-
-cairo_private void
_cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other);
cairo_private void
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 1698ddb..770be12 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -68,23 +68,6 @@ _cairo_clip_init (cairo_clip_t *clip, ca
}
void
-_cairo_clip_fini (cairo_clip_t *clip)
-{
- cairo_surface_destroy (clip->surface);
- clip->surface = NULL;
-
- clip->serial = 0;
-
- if (clip->has_region) {
- pixman_region_uninit (&clip->region);
- clip->has_region = FALSE;
- }
-
- _cairo_clip_path_destroy (clip->path);
- clip->path = NULL;
-}
-
-void
_cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
{
clip->mode = other->mode;
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 0d11f98..41da4f4 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -158,7 +158,7 @@ _cairo_gstate_fini (cairo_gstate_t *gsta
cairo_scaled_font_destroy (gstate->scaled_font);
gstate->scaled_font = NULL;
- _cairo_clip_fini (&gstate->clip);
+ _cairo_clip_reset (&gstate->clip);
cairo_surface_destroy (gstate->target);
gstate->target = NULL;
@@ -316,7 +316,7 @@ _cairo_gstate_redirect_target (cairo_gst
* since its ref is now owned by gstate->parent_target */
gstate->target = cairo_surface_reference (child);
- _cairo_clip_fini (&gstate->clip);
+ _cairo_clip_reset (&gstate->clip);
_cairo_clip_init_deep_copy (&gstate->clip, &gstate->next->clip, child);
/* The clip is in surface backend coordinates for the previous target;
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index e196df2..457bfe2 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -773,7 +773,7 @@ _cairo_meta_surface_replay (cairo_surfac
break;
}
- _cairo_clip_fini (&clip);
+ _cairo_clip_reset (&clip);
return status;
}
diff-tree 5ae309c4561418fb057a8049f047ffcb03f3b698 (from 241482b5505427d221f4aaa970e7500a78fb2da1)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 00:40:44 2007 +0100
Avoid pixman_region_create in _cairo_traps_extract_region
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index 65075c2..3e5a0f6 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -534,11 +534,12 @@ _cairo_traps_extents (cairo_traps_t *tra
* Determines if a set of trapezoids are exactly representable as a
* pixman region, and if so creates such a region.
*
- * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
+ * Return value: %CAIRO_STATUS_SUCCESS, %CAIRO_INT_STATUS_UNSUPPORTED
+ * or %CAIRO_STATUS_NO_MEMORY
**/
-cairo_status_t
-_cairo_traps_extract_region (cairo_traps_t *traps,
- pixman_region16_t **region)
+cairo_int_status_t
+_cairo_traps_extract_region (cairo_traps_t *traps,
+ pixman_region16_t *region)
{
int i;
@@ -549,11 +550,10 @@ _cairo_traps_extract_region (cairo_traps
&& _cairo_fixed_is_integer(traps->traps[i].bottom)
&& _cairo_fixed_is_integer(traps->traps[i].left.p1.x)
&& _cairo_fixed_is_integer(traps->traps[i].right.p1.x))) {
- *region = NULL;
- return CAIRO_STATUS_SUCCESS;
+ return CAIRO_INT_STATUS_UNSUPPORTED;
}
- *region = pixman_region_create ();
+ pixman_region_init (region, NULL);
for (i = 0; i < traps->num_traps; i++) {
int x = _cairo_fixed_integer_part(traps->traps[i].left.p1.x);
@@ -568,9 +568,9 @@ _cairo_traps_extract_region (cairo_traps
if (width == 0 || height == 0)
continue;
- if (pixman_region_union_rect (*region, *region,
+ if (pixman_region_union_rect (region, region,
x, y, width, height) != PIXMAN_REGION_STATUS_SUCCESS) {
- pixman_region_destroy (*region);
+ pixman_region_uninit (region);
return CAIRO_STATUS_NO_MEMORY;
}
}
diff --git a/src/cairoint.h b/src/cairoint.h
index 08414d0..2741dc7 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2320,9 +2320,9 @@ _cairo_traps_contain (cairo_traps_t *tra
cairo_private void
_cairo_traps_extents (cairo_traps_t *traps, cairo_box_t *extents);
-cairo_private cairo_status_t
-_cairo_traps_extract_region (cairo_traps_t *tr,
- pixman_region16_t **region);
+cairo_private cairo_int_status_t
+_cairo_traps_extract_region (cairo_traps_t *tr,
+ pixman_region16_t *region);
cairo_private void
_cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
diff-tree 241482b5505427d221f4aaa970e7500a78fb2da1 (from efc9775149c4c87645c58235c7626cc4f72e69c3)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date: Wed Mar 14 00:28:49 2007 +0100
Avoid malloc in _cairo_region_create_from_rectangle
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 74b0a68..1698ddb 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -181,26 +181,24 @@ _cairo_clip_intersect_to_rectangle (cair
}
if (clip->has_region) {
- pixman_region16_t *intersection;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
- pixman_region_status_t pixman_status;
+ pixman_region16_t intersection;
- intersection = _cairo_region_create_from_rectangle (rectangle);
- if (intersection == NULL)
+ if (_cairo_region_init_from_rectangle (&intersection, rectangle))
return CAIRO_STATUS_NO_MEMORY;
- pixman_status = pixman_region_intersect (intersection,
- &clip->region,
- intersection);
- if (pixman_status == PIXMAN_REGION_STATUS_SUCCESS)
- _cairo_region_extents_rectangle (intersection, rectangle);
- else
+ if (PIXMAN_REGION_STATUS_SUCCESS !=
+ pixman_region_intersect (&intersection, &clip->region,
+ &intersection)) {
status = CAIRO_STATUS_NO_MEMORY;
+ } else {
+ _cairo_region_extents_rectangle (&intersection, rectangle);
+ }
- pixman_region_destroy (intersection);
+ pixman_region_uninit (&intersection);
- if (status)
- return status;
+ if (status)
+ return status;
}
if (clip->surface)
@@ -224,24 +222,20 @@ _cairo_clip_intersect_to_region (cairo_c
pixman_region_intersect (region, &clip->region, region);
if (clip->surface) {
- pixman_region16_t *clip_rect;
- pixman_region_status_t pixman_status;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
+ pixman_region16_t clip_rect;
- clip_rect = _cairo_region_create_from_rectangle (&clip->surface_rect);
- if (clip_rect == NULL)
+ if (_cairo_region_init_from_rectangle (&clip_rect, &clip->surface_rect))
return CAIRO_STATUS_NO_MEMORY;
- pixman_status = pixman_region_intersect (region,
- clip_rect,
- region);
- if (pixman_status != PIXMAN_REGION_STATUS_SUCCESS)
+ if (PIXMAN_REGION_STATUS_SUCCESS !=
+ pixman_region_intersect (region, &clip_rect, region))
status = CAIRO_STATUS_NO_MEMORY;
- pixman_region_destroy (clip_rect);
+ pixman_region_uninit (&clip_rect);
- if (status)
- return status;
+ if (status)
+ return status;
}
return CAIRO_STATUS_SUCCESS;
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 4ba2852..1e1c86f 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -36,30 +36,28 @@
#include "cairoint.h"
/**
- * _cairo_region_create_from_rectangle:
+ * _cairo_region_init_from_rectangle:
+ * @region: a #pixman_region16_t
* @rect: a #cairo_rectangle_int16_t
*
- * Creates a region with extents initialized from the given
- * rectangle.
+ * Initializes a region with extents from the given rectangle.
*
- * Return value: a newly created #pixman_region16_t or %NULL if
- * memory couldn't a allocated.
+ * Return value: #CAIRO_STATUS_SUCCESS on success, or
+ * #CAIRO_STATUS_NO_MEMORY when pixman fails to initialize
+ * the region.
**/
-pixman_region16_t *
-_cairo_region_create_from_rectangle (cairo_rectangle_int16_t *rect)
+cairo_status_t
+_cairo_region_init_from_rectangle (pixman_region16_t *region,
+ cairo_rectangle_int16_t *rect)
{
- /* We can't use pixman_region_create_simple(), because it doesn't
- * have an error return
- */
- pixman_region16_t *region = pixman_region_create ();
- if (pixman_region_union_rect (region, region,
- rect->x, rect->y,
- rect->width, rect->height) != PIXMAN_REGION_STATUS_SUCCESS) {
- pixman_region_destroy (region);
- return NULL;
- }
+ pixman_region_init (region, NULL);
+
+ if (PIXMAN_REGION_STATUS_SUCCESS == pixman_region_union_rect (
+ region, region, rect->x, rect->y, rect->width, rect->height))
+ return CAIRO_STATUS_SUCCESS;
- return region;
+ pixman_region_uninit (region);
+ return CAIRO_STATUS_NO_MEMORY;
}
/**
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 004de68..b950145 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -513,145 +513,157 @@ _clip_and_composite_trapezoids (cairo_pa
cairo_antialias_t antialias)
{
cairo_status_t status;
- pixman_region16_t *trap_region = NULL;
- pixman_region16_t *clear_region = NULL;
+ pixman_region16_t trap_region;
+ pixman_region16_t clear_region;
+ cairo_bool_t has_trap_region = FALSE;
+ cairo_bool_t has_clear_region = FALSE;
cairo_rectangle_int16_t extents;
cairo_composite_traps_info_t traps_info;
if (traps->num_traps == 0)
- return CAIRO_STATUS_SUCCESS;
+ return CAIRO_STATUS_SUCCESS;
status = _cairo_surface_get_extents (dst, &extents);
- if (status)
- return status;
- status = _cairo_traps_extract_region (traps, &trap_region);
if (status)
- return status;
+ return status;
- if (_cairo_operator_bounded_by_mask (op))
- {
- cairo_rectangle_int16_t trap_extents;
- if (trap_region) {
- status = _cairo_clip_intersect_to_region (clip, trap_region);
- if (status)
- goto out;
-
- _cairo_region_extents_rectangle (trap_region, &trap_extents);
- } else {
- cairo_box_t trap_box;
- _cairo_traps_extents (traps, &trap_box);
- _cairo_box_round_to_rectangle (&trap_box, &trap_extents);
- }
+ status = _cairo_traps_extract_region (traps, &trap_region);
- _cairo_rectangle_intersect (&extents, &trap_extents);
- status = _cairo_clip_intersect_to_rectangle (clip, &extents);
- if (status)
- goto out;
+ if (CAIRO_INT_STATUS_UNSUPPORTED == status) {
+ has_trap_region = FALSE;
+ } else if (status) {
+ return status;
+ } else {
+ has_trap_region = TRUE;
}
- else
- {
- cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
- if (trap_region && !clip_surface) {
- /* If we optimize drawing with an unbounded operator to
- * _cairo_surface_fill_rectangles() or to drawing with a
- * clip region, then we have an additional region to clear.
- */
- clear_region = _cairo_region_create_from_rectangle (&extents);
- if (clear_region == NULL)
- return CAIRO_STATUS_NO_MEMORY;
-
- status = _cairo_clip_intersect_to_region (clip, clear_region);
- if (status)
- return status;
-
- _cairo_region_extents_rectangle (clear_region, &extents);
-
- if (pixman_region_subtract (clear_region, clear_region, trap_region) != PIXMAN_REGION_STATUS_SUCCESS)
- return CAIRO_STATUS_NO_MEMORY;
-
- if (!pixman_region_not_empty (clear_region)) {
- pixman_region_destroy (clear_region);
- clear_region = NULL;
- }
- } else {
- status = _cairo_clip_intersect_to_rectangle (clip, &extents);
- if (status)
- return status;
- }
- }
+ if (_cairo_operator_bounded_by_mask (op)) {
+ cairo_rectangle_int16_t trap_extents;
- if (status)
- goto out;
+ if (has_trap_region) {
+ status = _cairo_clip_intersect_to_region (clip, &trap_region);
- if (trap_region)
- {
- cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
+ if (status)
+ goto out;
- if ((src->type == CAIRO_PATTERN_TYPE_SOLID || op == CAIRO_OPERATOR_CLEAR) &&
- !clip_surface)
- {
- const cairo_color_t *color;
+ _cairo_region_extents_rectangle (&trap_region, &trap_extents);
+ } else {
+ cairo_box_t trap_box;
+ _cairo_traps_extents (traps, &trap_box);
+ _cairo_box_round_to_rectangle (&trap_box, &trap_extents);
+ }
+
+ _cairo_rectangle_intersect (&extents, &trap_extents);
+ status = _cairo_clip_intersect_to_rectangle (clip, &extents);
+
+ if (status)
+ goto out;
+ } else {
+ cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
+
+ if (has_trap_region && !clip_surface) {
+ /* If we optimize drawing with an unbounded operator to
+ * _cairo_surface_fill_rectangles() or to drawing with a
+ * clip region, then we have an additional region to clear.
+ */
+ if (_cairo_region_init_from_rectangle (&clear_region, &extents)) {
+ status = CAIRO_STATUS_NO_MEMORY;
+ goto out;
+ }
+
+ has_clear_region = TRUE;
+ status = _cairo_clip_intersect_to_region (clip, &clear_region);
+
+ if (status)
+ goto out;
+
+ _cairo_region_extents_rectangle (&clear_region, &extents);
+
+ if (PIXMAN_REGION_STATUS_SUCCESS !=
+ pixman_region_subtract (&clear_region, &clear_region, &trap_region)) {
+ status = CAIRO_STATUS_NO_MEMORY;
+ goto out;
+ }
+
+ if (!pixman_region_not_empty (&clear_region)) {
+ pixman_region_uninit (&clear_region);
+ has_clear_region = FALSE;
+ }
+ } else {
+ status = _cairo_clip_intersect_to_rectangle (clip, &extents);
+ }
+ }
- if (op == CAIRO_OPERATOR_CLEAR)
- color = CAIRO_COLOR_TRANSPARENT;
- else
- color = &((cairo_solid_pattern_t *)src)->color;
-
- /* Solid rectangles special case */
- status = _cairo_surface_fill_region (dst, op, color, trap_region);
- if (!status && clear_region)
- status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_CLEAR,
- CAIRO_COLOR_TRANSPARENT,
- clear_region);
+ if (status)
+ goto out;
- goto out;
- }
+ if (has_trap_region) {
+ cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
- if ((_cairo_operator_bounded_by_mask (op) && op != CAIRO_OPERATOR_SOURCE) ||
- !clip_surface)
- {
- /* For a simple rectangle, we can just use composite(), for more
- * rectangles, we have to set a clip region. The cost of rasterizing
- * trapezoids is pretty high for most backends currently, so it's
- * worthwhile even if a region is needed.
- *
- * If we have a clip surface, we set it as the mask; this only works
- * for bounded operators other than SOURCE; for unbounded operators,
- * clip and mask cannot be interchanged. For SOURCE, the operator
- * as implemented by the backends is different in it's handling
- * of the mask then what we want.
- *
- * CAIRO_INT_STATUS_UNSUPPORTED will be returned if the region has
- * more than rectangle and the destination doesn't support clip
- * regions. In that case, we fall through.
- */
- status = _composite_trap_region (clip, src, op, dst,
- trap_region, &extents);
- if (status != CAIRO_INT_STATUS_UNSUPPORTED)
- {
- if (!status && clear_region)
- status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_CLEAR,
- CAIRO_COLOR_TRANSPARENT,
- clear_region);
- goto out;
- }
- }
+ if ((src->type == CAIRO_PATTERN_TYPE_SOLID ||
+ op == CAIRO_OPERATOR_CLEAR) && !clip_surface) {
+ const cairo_color_t *color;
+
+ if (op == CAIRO_OPERATOR_CLEAR) {
+ color = CAIRO_COLOR_TRANSPARENT;
+ } else {
+ color = &((cairo_solid_pattern_t *)src)->color;
+ }
+
+ /* Solid rectangles special case */
+ status = _cairo_surface_fill_region (dst, op, color, &trap_region);
+
+ if (!status && has_clear_region)
+ status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_CLEAR,
+ CAIRO_COLOR_TRANSPARENT,
+ &clear_region);
+
+ goto out;
+ }
+
+ if ((_cairo_operator_bounded_by_mask (op) &&
+ op != CAIRO_OPERATOR_SOURCE) || !clip_surface) {
+ /* For a simple rectangle, we can just use composite(), for more
+ * rectangles, we have to set a clip region. The cost of rasterizing
+ * trapezoids is pretty high for most backends currently, so it's
+ * worthwhile even if a region is needed.
+ *
+ * If we have a clip surface, we set it as the mask; this only works
+ * for bounded operators other than SOURCE; for unbounded operators,
+ * clip and mask cannot be interchanged. For SOURCE, the operator
+ * as implemented by the backends is different in it's handling
+ * of the mask then what we want.
+ *
+ * CAIRO_INT_STATUS_UNSUPPORTED will be returned if the region has
+ * more than rectangle and the destination doesn't support clip
+ * regions. In that case, we fall through.
+ */
+ status = _composite_trap_region (clip, src, op, dst,
+ &trap_region, &extents);
+
+ if (status != CAIRO_INT_STATUS_UNSUPPORTED) {
+ if (!status && has_clear_region)
+ status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_CLEAR,
+ CAIRO_COLOR_TRANSPARENT,
+ &clear_region);
+ goto out;
+ }
+ }
}
traps_info.traps = traps;
traps_info.antialias = antialias;
status = _clip_and_composite (clip, op, src,
- _composite_traps_draw_func, &traps_info,
- dst, &extents);
+ _composite_traps_draw_func,
+ &traps_info, dst, &extents);
- out:
- if (trap_region)
- pixman_region_destroy (trap_region);
- if (clear_region)
- pixman_region_destroy (clear_region);
+out:
+ if (has_trap_region)
+ pixman_region_uninit (&trap_region);
+ if (has_clear_region)
+ pixman_region_uninit (&clear_region);
return status;
}
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 9b69b65..7f30c33 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1869,9 +1869,11 @@ _cairo_surface_composite_fixup_unbounded
{
cairo_rectangle_int16_t dst_rectangle;
cairo_rectangle_int16_t drawn_rectangle;
- pixman_region16_t *drawn_region;
- pixman_region16_t *clear_region;
- cairo_status_t status = CAIRO_STATUS_SUCCESS;
+ cairo_bool_t has_drawn_region = FALSE;
+ cairo_bool_t has_clear_region = FALSE;
+ pixman_region16_t drawn_region;
+ pixman_region16_t clear_region;
+ cairo_status_t status;
/* The area that was drawn is the area in the destination rectangle but not within
* the source or the mask.
@@ -1884,34 +1886,42 @@ _cairo_surface_composite_fixup_unbounded
drawn_rectangle = dst_rectangle;
if (src_rectangle)
- _cairo_rectangle_intersect (&drawn_rectangle, src_rectangle);
+ _cairo_rectangle_intersect (&drawn_rectangle, src_rectangle);
if (mask_rectangle)
- _cairo_rectangle_intersect (&drawn_rectangle, mask_rectangle);
+ _cairo_rectangle_intersect (&drawn_rectangle, mask_rectangle);
/* Now compute the area that is in dst_rectangle but not in drawn_rectangle
*/
- drawn_region = _cairo_region_create_from_rectangle (&drawn_rectangle);
- clear_region = _cairo_region_create_from_rectangle (&dst_rectangle);
- if (!drawn_region || !clear_region) {
- status = CAIRO_STATUS_NO_MEMORY;
- goto CLEANUP_REGIONS;
+ if (_cairo_region_init_from_rectangle (&drawn_region, &drawn_rectangle)) {
+ status = CAIRO_STATUS_NO_MEMORY;
+ goto CLEANUP_REGIONS;
}
- if (pixman_region_subtract (clear_region, clear_region, drawn_region) != PIXMAN_REGION_STATUS_SUCCESS) {
- status = CAIRO_STATUS_NO_MEMORY;
- goto CLEANUP_REGIONS;
+ has_drawn_region = TRUE;
+
+ if (_cairo_region_init_from_rectangle (&clear_region, &dst_rectangle)) {
+ status = CAIRO_STATUS_NO_MEMORY;
+ goto CLEANUP_REGIONS;
+ }
+
+ has_clear_region = TRUE;
+
+ if (PIXMAN_REGION_STATUS_SUCCESS !=
+ pixman_region_subtract (&clear_region, &clear_region, &drawn_region)) {
+ status = CAIRO_STATUS_NO_MEMORY;
+ goto CLEANUP_REGIONS;
}
status = _cairo_surface_fill_region (dst, CAIRO_OPERATOR_SOURCE,
- CAIRO_COLOR_TRANSPARENT,
- clear_region);
+ CAIRO_COLOR_TRANSPARENT,
+ &clear_region);
- CLEANUP_REGIONS:
- if (drawn_region)
- pixman_region_destroy (drawn_region);
- if (clear_region)
- pixman_region_destroy (clear_region);
+CLEANUP_REGIONS:
+ if (has_drawn_region)
+ pixman_region_uninit (&drawn_region);
+ if (has_clear_region)
+ pixman_region_uninit (&clear_region);
return status;
}
diff --git a/src/cairoint.h b/src/cairoint.h
index c5333fb..08414d0 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2429,8 +2429,9 @@ _cairo_gstate_get_antialias (cairo_gstat
/* cairo-region.c */
-cairo_private pixman_region16_t *
-_cairo_region_create_from_rectangle (cairo_rectangle_int16_t *rect);
+cairo_private cairo_status_t
+_cairo_region_init_from_rectangle (pixman_region16_t *region,
+ cairo_rectangle_int16_t *rect);
cairo_private void
_cairo_region_extents_rectangle (pixman_region16_t *region,
diff-tree efc9775149c4c87645c58235c7626cc4f72e69c3 (from 0e7df34e07d7816b29c1ac1f67608b87c5e0efc2)
Author: Mathias Hasselmann <mathias at pergamaunz.(none)>
Date: Tue Mar 13 23:58:14 2007 +0100
Make sure clip->region is always initialized
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 81f4173..74b0a68 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -61,6 +61,7 @@ _cairo_clip_init (cairo_clip_t *clip, ca
clip->serial = 0;
+ pixman_region_init (&clip->region, NULL);
clip->has_region = FALSE;
clip->path = NULL;
@@ -93,6 +94,8 @@ _cairo_clip_init_copy (cairo_clip_t *cli
clip->serial = other->serial;
+ pixman_region_init (&clip->region, NULL);
+
if (other->has_region) {
pixman_region_copy (&clip->region, &other->region);
clip->has_region = TRUE;
@@ -113,7 +116,12 @@ _cairo_clip_reset (cairo_clip_t *clip)
clip->serial = 0;
if (clip->has_region) {
+ /* pixman_region_uninit just releases the resources used but
+ * doesn't bother with leaving the region in a valid state.
+ * So pixman_region_init has to be called afterwards. */
pixman_region_uninit (&clip->region);
+ pixman_region_init (&clip->region, NULL);
+
clip->has_region = FALSE;
}
diff-tree 0e7df34e07d7816b29c1ac1f67608b87c5e0efc2 (from ced7b4a4ab4b5a8d639bfca0dd5db38f1ae4825d)
Author: Mathias Hasselmann <mathias at pergamaunz.(none)>
Date: Tue Mar 13 23:38:20 2007 +0100
Make region of cairo_clip_t static
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index d2811d5..a2e8d9b 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -72,7 +72,8 @@ struct _cairo_clip {
/*
* A clip region that can be placed in the surface
*/
- pixman_region16_t *region;
+ pixman_region16_t region;
+ cairo_bool_t has_region;
/*
* If the surface supports path clipping, we store the list of
* clipping paths that has been set here as a linked list.
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index efecd89..81f4173 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -61,7 +61,7 @@ _cairo_clip_init (cairo_clip_t *clip, ca
clip->serial = 0;
- clip->region = NULL;
+ clip->has_region = FALSE;
clip->path = NULL;
}
@@ -74,9 +74,10 @@ _cairo_clip_fini (cairo_clip_t *clip)
clip->serial = 0;
- if (clip->region)
- pixman_region_destroy (clip->region);
- clip->region = NULL;
+ if (clip->has_region) {
+ pixman_region_uninit (&clip->region);
+ clip->has_region = FALSE;
+ }
_cairo_clip_path_destroy (clip->path);
clip->path = NULL;
@@ -92,11 +93,11 @@ _cairo_clip_init_copy (cairo_clip_t *cli
clip->serial = other->serial;
- if (other->region == NULL) {
- clip->region = other->region;
+ if (other->has_region) {
+ pixman_region_copy (&clip->region, &other->region);
+ clip->has_region = TRUE;
} else {
- clip->region = pixman_region_create ();
- pixman_region_copy (clip->region, other->region);
+ clip->has_region = FALSE;
}
clip->path = _cairo_clip_path_reference (other->path);
@@ -111,9 +112,10 @@ _cairo_clip_reset (cairo_clip_t *clip)
clip->serial = 0;
- if (clip->region)
- pixman_region_destroy (clip->region);
- clip->region = NULL;
+ if (clip->has_region) {
+ pixman_region_uninit (&clip->region);
+ clip->has_region = FALSE;
+ }
_cairo_clip_path_destroy (clip->path);
clip->path = NULL;
@@ -170,7 +172,7 @@ _cairo_clip_intersect_to_rectangle (cair
return status;
}
- if (clip->region) {
+ if (clip->has_region) {
pixman_region16_t *intersection;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
pixman_region_status_t pixman_status;
@@ -180,7 +182,7 @@ _cairo_clip_intersect_to_rectangle (cair
return CAIRO_STATUS_NO_MEMORY;
pixman_status = pixman_region_intersect (intersection,
- clip->region,
+ &clip->region,
intersection);
if (pixman_status == PIXMAN_REGION_STATUS_SUCCESS)
_cairo_region_extents_rectangle (intersection, rectangle);
@@ -210,8 +212,8 @@ _cairo_clip_intersect_to_region (cairo_c
/* Intersect clip path into region. */
}
- if (clip->region)
- pixman_region_intersect (region, clip->region, region);
+ if (clip->has_region)
+ pixman_region_intersect (region, &clip->region, region);
if (clip->surface) {
pixman_region16_t *clip_rect;
@@ -329,42 +331,43 @@ _cairo_clip_path_destroy (cairo_clip_pat
free (clip_path);
}
-static cairo_status_t
+static cairo_int_status_t
_cairo_clip_intersect_region (cairo_clip_t *clip,
cairo_traps_t *traps,
cairo_surface_t *target)
{
- pixman_region16_t *region;
- cairo_status_t status;
+ pixman_region16_t region;
+ cairo_int_status_t status;
if (clip->mode != CAIRO_CLIP_MODE_REGION)
return CAIRO_INT_STATUS_UNSUPPORTED;
status = _cairo_traps_extract_region (traps, ®ion);
+
if (status)
return status;
- if (region == NULL)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
status = CAIRO_STATUS_SUCCESS;
- if (clip->region == NULL) {
- clip->region = region;
+
+ if (!clip->has_region) {
+ pixman_region_copy (&clip->region, ®ion);
+ clip->has_region = TRUE;
} else {
- pixman_region16_t *intersection = pixman_region_create();
+ pixman_region16_t intersection;
+ pixman_region_init (&intersection, NULL);
- if (pixman_region_intersect (intersection,
- clip->region, region)
- == PIXMAN_REGION_STATUS_SUCCESS) {
- pixman_region_destroy (clip->region);
- clip->region = intersection;
- } else {
- status = CAIRO_STATUS_NO_MEMORY;
- }
- pixman_region_destroy (region);
+ if (PIXMAN_REGION_STATUS_SUCCESS ==
+ pixman_region_intersect (&intersection, &clip->region, ®ion)) {
+ pixman_region_copy (&clip->region, &intersection);
+ } else {
+ status = CAIRO_STATUS_NO_MEMORY;
+ }
+
+ pixman_region_uninit (&intersection);
}
clip->serial = _cairo_surface_allocate_clip_serial (target);
+ pixman_region_uninit (®ion);
return status;
}
@@ -509,8 +512,8 @@ _cairo_clip_translate (cairo_clip_t *cl
cairo_fixed_t tx,
cairo_fixed_t ty)
{
- if (clip->region) {
- pixman_region_translate (clip->region,
+ if (clip->has_region) {
+ pixman_region_translate (&clip->region,
_cairo_fixed_integer_part (tx),
_cairo_fixed_integer_part (ty));
}
@@ -560,9 +563,9 @@ _cairo_clip_init_deep_copy (cairo_clip_t
/* We should reapply the original clip path in this case, and let
* whatever the right handling is happen */
} else {
- if (other->region) {
- clip->region = pixman_region_create ();
- pixman_region_copy (clip->region, other->region);
+ if (other->has_region) {
+ pixman_region_copy (&clip->region, &other->region);
+ clip->has_region = TRUE;
}
if (other->surface) {
@@ -613,16 +616,16 @@ _cairo_clip_copy_rectangle_list (cairo_c
if (clip->path || clip->surface)
return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
- n_boxes = clip->region ? pixman_region_num_rects (clip->region) : 1;
+ n_boxes = clip->has_region ? pixman_region_num_rects (&clip->region) : 1;
rectangles = malloc (sizeof (cairo_rectangle_t)*n_boxes);
if (rectangles == NULL)
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
- if (clip->region) {
+ if (clip->has_region) {
pixman_box16_t *boxes;
int i;
- boxes = pixman_region_rects (clip->region);
+ boxes = pixman_region_rects (&clip->region);
for (i = 0; i < n_boxes; ++i) {
if (!_cairo_clip_rect_to_user(gstate, boxes[i].x1, boxes[i].y1,
boxes[i].x2 - boxes[i].x1,
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 115824d..9b69b65 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1704,9 +1704,9 @@ _cairo_surface_set_clip (cairo_surface_t
clip->path,
clip->serial);
- if (clip->region)
+ if (clip->has_region)
return _cairo_surface_set_clip_region (surface,
- clip->region,
+ &clip->region,
clip->serial);
}
diff-tree ced7b4a4ab4b5a8d639bfca0dd5db38f1ae4825d (from 4d9065fcebbaf857d8d5fe49bcbb33f270c0bf26)
Author: Mathias Hasselmann <mathias at pergamaunz.(none)>
Date: Tue Mar 13 22:34:23 2007 +0100
Make pixman_region_{init,uninit} public
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index 236bcc8..df343b2 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -138,6 +138,11 @@ pixman_private pixman_region16_t *
pixman_region_create_simple (pixman_box16_t *extents);
pixman_private void
+pixman_region_init(pixman_region16_t *region, pixman_box16_t *extents);
+pixman_private void
+pixman_region_uninit (pixman_region16_t *region);
+
+pixman_private void
pixman_region_destroy (pixman_region16_t *region);
/* manipulation */
diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index e948c19..e408eaf 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -80,12 +80,6 @@ static pixman_region16_t pixman_broken
static pixman_region_status_t
pixman_break (pixman_region16_t *pReg);
-static void
-pixman_init (pixman_region16_t *region, pixman_box16_t *rect);
-
-static void
-pixman_uninit (pixman_region16_t *region);
-
/*
* The functions in this file implement the Region abstraction used extensively
* throughout the X11 sample server. A Region is simply a set of disjoint
@@ -316,7 +310,7 @@ pixman_region_create_simple (pixman_box1
if (region == NULL)
return &pixman_brokenregion;
- pixman_init (region, extents);
+ pixman_region_init (region, extents);
return region;
}
@@ -326,8 +320,8 @@ pixman_region_create_simple (pixman_box1
* Outer region rect is statically allocated.
*****************************************************************/
-static void
-pixman_init(pixman_region16_t *region, pixman_box16_t *extents)
+void
+pixman_region_init(pixman_region16_t *region, pixman_box16_t *extents)
{
if (extents)
{
@@ -341,8 +335,8 @@ pixman_init(pixman_region16_t *region, p
}
}
-static void
-pixman_uninit (pixman_region16_t *region)
+void
+pixman_region_uninit (pixman_region16_t *region)
{
good (region);
freeData (region);
@@ -351,7 +345,7 @@ pixman_uninit (pixman_region16_t *region
void
pixman_region_destroy (pixman_region16_t *region)
{
- pixman_uninit (region);
+ pixman_region_uninit (region);
if (region != &pixman_brokenregion)
free (region);
diff-tree 4d9065fcebbaf857d8d5fe49bcbb33f270c0bf26 (from dce3e5e6b556b817bf95182122adbf6f816b71e9)
Author: Mathias Hasselmann <mathias at pergamaunz.(none)>
Date: Tue Mar 13 21:51:46 2007 +0100
Move struct pixman_region16 to pixman.h
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index 9120eb6..236bcc8 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -113,12 +113,17 @@ extern "C" {
/* pixregion.h */
-typedef struct pixman_region16 pixman_region16_t;
+typedef struct pixman_region16_data pixman_region16_data_t;
typedef struct pixman_box16 {
short x1, y1, x2, y2;
} pixman_box16_t;
+typedef struct pixman_region16 {
+ pixman_box16_t extents;
+ pixman_region16_data_t *data;
+} pixman_region16_t;
+
typedef enum {
PIXMAN_REGION_STATUS_FAILURE,
PIXMAN_REGION_STATUS_SUCCESS
diff --git a/pixman/src/pixregionint.h b/pixman/src/pixregionint.h
index b5b53fd..385a7f2 100644
--- a/pixman/src/pixregionint.h
+++ b/pixman/src/pixregionint.h
@@ -48,16 +48,11 @@ SOFTWARE.
#include "pixman.h"
-typedef struct pixman_region16_data {
+struct pixman_region16_data {
long size;
long numRects;
/* XXX: And why, exactly, do we have this bogus struct definition? */
/* pixman_box16_t rects[size]; in memory but not explicitly declared */
-} pixman_region16_data_t;
-
-struct pixman_region16 {
- pixman_box16_t extents;
- pixman_region16_data_t *data;
};
typedef struct pixman_region16_point {
More information about the cairo-commit
mailing list