[cairo-commit] 5 commits - src/cairo-gl-surface.c src/cairo-image-surface.c src/cairo-surface-fallback.c
Benjamin Otte
company at kemper.freedesktop.org
Wed Apr 28 11:27:17 PDT 2010
src/cairo-gl-surface.c | 12 +--
src/cairo-image-surface.c | 44 ++++++------
src/cairo-surface-fallback.c | 152 ++++++++++++++++++++++++++++---------------
3 files changed, 129 insertions(+), 79 deletions(-)
New commits:
commit 9ce8bef9d6e6d773dd1f4b184916ed5c96c3541d
Author: Benjamin Otte <otte at redhat.com>
Date: Wed Apr 28 18:34:20 2010 +0200
fallback: Propagate extents properly
Otherwise unbounded operators will clear the full surface.
Improves the score for the unbounded-operator test, in particular the
output for the test-fallback case.
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 99fa64e..5149a96 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -538,18 +538,33 @@ _composite_traps_draw_func (void *closure,
cairo_region_t *clip_region)
{
cairo_composite_traps_info_t *info = closure;
+ cairo_status_t status;
+ cairo_region_t *extents_region = NULL;
if (dst_x != 0 || dst_y != 0)
_cairo_traps_translate (info->traps, - dst_x, - dst_y);
- return _cairo_surface_composite_trapezoids (op,
- src, dst, info->antialias,
- extents->x, extents->y,
- extents->x - dst_x, extents->y - dst_y,
- extents->width, extents->height,
- info->traps->traps,
- info->traps->num_traps,
- clip_region);
+ if (clip_region == NULL &&
+ !_cairo_operator_bounded_by_source (op)) {
+ extents_region = cairo_region_create_rectangle (extents);
+ if (unlikely (extents_region->status))
+ return extents_region->status;
+ clip_region = extents_region;
+ }
+
+ status = _cairo_surface_composite_trapezoids (op,
+ src, dst, info->antialias,
+ extents->x, extents->y,
+ extents->x - dst_x, extents->y - dst_y,
+ extents->width, extents->height,
+ info->traps->traps,
+ info->traps->num_traps,
+ clip_region);
+
+ if (extents_region)
+ cairo_region_destroy (extents_region);
+
+ return status;
}
enum {
@@ -971,24 +986,39 @@ _cairo_surface_mask_draw_func (void *closure,
cairo_region_t *clip_region)
{
cairo_pattern_t *mask = closure;
+ cairo_status_t status;
+ cairo_region_t *extents_region = NULL;
+
+ if (clip_region == NULL &&
+ !_cairo_operator_bounded_by_source (op)) {
+ extents_region = cairo_region_create_rectangle (extents);
+ if (unlikely (extents_region->status))
+ return extents_region->status;
+ clip_region = extents_region;
+ }
if (src) {
- return _cairo_surface_composite (op,
- src, mask, dst,
- extents->x, extents->y,
- extents->x, extents->y,
- extents->x - dst_x, extents->y - dst_y,
- extents->width, extents->height,
- clip_region);
+ status = _cairo_surface_composite (op,
+ src, mask, dst,
+ extents->x, extents->y,
+ extents->x, extents->y,
+ extents->x - dst_x, extents->y - dst_y,
+ extents->width, extents->height,
+ clip_region);
} else {
- return _cairo_surface_composite (op,
- mask, NULL, dst,
- extents->x, extents->y,
- 0, 0, /* unused */
- extents->x - dst_x, extents->y - dst_y,
- extents->width, extents->height,
- clip_region);
+ status = _cairo_surface_composite (op,
+ mask, NULL, dst,
+ extents->x, extents->y,
+ 0, 0, /* unused */
+ extents->x - dst_x, extents->y - dst_y,
+ extents->width, extents->height,
+ clip_region);
}
+
+ if (extents_region)
+ cairo_region_destroy (extents_region);
+
+ return status;
}
cairo_status_t
@@ -1272,6 +1302,15 @@ _cairo_surface_old_show_glyphs_draw_func (void *closure
{
cairo_show_glyphs_info_t *glyph_info = closure;
cairo_status_t status;
+ cairo_region_t *extents_region = NULL;
+
+ if (clip_region == NULL &&
+ !_cairo_operator_bounded_by_source (op)) {
+ extents_region = cairo_region_create_rectangle (extents);
+ if (unlikely (extents_region->status))
+ return extents_region->status;
+ clip_region = extents_region;
+ }
/* Modifying the glyph array is fine because we know that this function
* will be called only once, and we've already made a copy of the
@@ -1296,19 +1335,24 @@ _cairo_surface_old_show_glyphs_draw_func (void *closure
glyph_info->glyphs,
glyph_info->num_glyphs,
clip_region);
- if (status != CAIRO_INT_STATUS_UNSUPPORTED)
- return status;
- return _cairo_scaled_font_show_glyphs (glyph_info->font,
- op,
- src, dst,
- extents->x, extents->y,
- extents->x - dst_x,
- extents->y - dst_y,
- extents->width, extents->height,
- glyph_info->glyphs,
- glyph_info->num_glyphs,
- clip_region);
+ if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ status = _cairo_scaled_font_show_glyphs (glyph_info->font,
+ op,
+ src, dst,
+ extents->x, extents->y,
+ extents->x - dst_x,
+ extents->y - dst_y,
+ extents->width, extents->height,
+ glyph_info->glyphs,
+ glyph_info->num_glyphs,
+ clip_region);
+ }
+
+ if (extents_region)
+ cairo_region_destroy (extents_region);
+
+ return status;
}
cairo_status_t
commit 91fd97ae7c4de23c61d481c98c9352f0639d76dd
Author: Benjamin Otte <otte at redhat.com>
Date: Wed Apr 28 20:21:37 2010 +0200
fallback: Pass the correct extents for unbounbded operations
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index ea3abec..99fa64e 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -949,7 +949,8 @@ _cairo_surface_fallback_paint (cairo_surface_t *surface,
status = _clip_and_composite_trapezoids (source, op, surface,
&traps, CAIRO_ANTIALIAS_DEFAULT,
- clip, &extents.bounded);
+ clip,
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
_cairo_traps_fini (&traps);
CLEANUP_BOXES:
@@ -1022,7 +1023,8 @@ _cairo_surface_fallback_mask (cairo_surface_t *surface,
return _clip_and_composite (clip, op, source,
_cairo_surface_mask_draw_func,
(void *) mask,
- surface, &extents.bounded);
+ surface,
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
}
cairo_status_t
@@ -1108,7 +1110,8 @@ _cairo_surface_fallback_stroke (cairo_surface_t *surface,
status = _clip_and_composite (clip, op, source,
_composite_spans_draw_func,
- &info, surface, &extents.bounded);
+ &info, surface,
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
goto CLEANUP;
}
@@ -1122,7 +1125,8 @@ _cairo_surface_fallback_stroke (cairo_surface_t *surface,
DO_TRAPS:
status = _clip_and_composite_trapezoids (source, op, surface,
&traps, antialias,
- clip, &extents.bounded);
+ clip,
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
CLEANUP:
_cairo_traps_fini (&traps);
_cairo_polygon_fini (&polygon);
@@ -1224,7 +1228,8 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface,
status = _clip_and_composite (clip, op, source,
_composite_spans_draw_func,
- &info, surface, &extents.bounded);
+ &info, surface,
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
goto CLEANUP;
}
@@ -1238,7 +1243,8 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface,
DO_TRAPS:
status = _clip_and_composite_trapezoids (source, op, surface,
&traps, antialias,
- clip, &extents.bounded);
+ clip,
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
CLEANUP:
_cairo_traps_fini (&traps);
_cairo_polygon_fini (&polygon);
@@ -1350,7 +1356,7 @@ _cairo_surface_fallback_show_glyphs (cairo_surface_t *surface,
_cairo_surface_old_show_glyphs_draw_func,
&glyph_info,
surface,
- &extents.bounded);
+ extents.is_bounded ? &extents.bounded : &extents.unbounded);
}
cairo_surface_t *
commit 06e9caf86199e8261a07db6d4774628fa147728d
Author: Benjamin Otte <otte at redhat.com>
Date: Wed Apr 28 20:05:13 2010 +0200
image: pixman_image_fill_rectangles() => pixman_image_fill_boxes()
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 662e94e..77f5ce7 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -4140,8 +4140,8 @@ _cairo_image_surface_fill_rectangles (void *abstract_surface,
cairo_image_surface_t *surface = abstract_surface;
pixman_color_t pixman_color;
- pixman_rectangle16_t stack_rects[CAIRO_STACK_ARRAY_LENGTH (pixman_rectangle16_t)];
- pixman_rectangle16_t *pixman_rects = stack_rects;
+ pixman_box32_t stack_boxes[CAIRO_STACK_ARRAY_LENGTH (pixman_rectangle16_t)];
+ pixman_box32_t *pixman_boxes = stack_boxes;
int i;
cairo_int_status_t status;
@@ -4154,31 +4154,31 @@ _cairo_image_surface_fill_rectangles (void *abstract_surface,
pixman_color.blue = color->blue_short;
pixman_color.alpha = color->alpha_short;
- if (num_rects > ARRAY_LENGTH (stack_rects)) {
- pixman_rects = _cairo_malloc_ab (num_rects, sizeof (pixman_rectangle16_t));
- if (unlikely (pixman_rects == NULL))
+ if (num_rects > ARRAY_LENGTH (stack_boxes)) {
+ pixman_boxes = _cairo_malloc_ab (num_rects, sizeof (pixman_rectangle16_t));
+ if (unlikely (pixman_boxes == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
for (i = 0; i < num_rects; i++) {
- pixman_rects[i].x = rects[i].x;
- pixman_rects[i].y = rects[i].y;
- pixman_rects[i].width = rects[i].width;
- pixman_rects[i].height = rects[i].height;
+ pixman_boxes[i].x1 = rects[i].x;
+ pixman_boxes[i].y1 = rects[i].y;
+ pixman_boxes[i].x2 = rects[i].x + rects[i].width;
+ pixman_boxes[i].y2 = rects[i].y + rects[i].height;
}
status = CAIRO_STATUS_SUCCESS;
- if (! pixman_image_fill_rectangles (_pixman_operator (op),
- surface->pixman_image,
- &pixman_color,
- num_rects,
- pixman_rects))
+ if (! pixman_image_fill_boxes (_pixman_operator (op),
+ surface->pixman_image,
+ &pixman_color,
+ num_rects,
+ pixman_boxes))
{
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
- if (pixman_rects != stack_rects)
- free (pixman_rects);
+ if (pixman_boxes != stack_boxes)
+ free (pixman_boxes);
return status;
}
commit bc49df322770b3bd1797c0e153b97f1f296fbd1e
Author: Benjamin Otte <otte at redhat.com>
Date: Wed Apr 28 19:56:36 2010 +0200
pixman_image_composite => pixman_image_composite32
Fix up the remaining callers
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 497a9c9..db837aa 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1230,12 +1230,12 @@ _render_gradient (const cairo_gl_context_t *ctx,
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
- pixman_image_composite (PIXMAN_OP_SRC,
- gradient, NULL, image,
- 0, 0,
- 0, 0,
- 0, 0,
- width, 1);
+ pixman_image_composite32 (PIXMAN_OP_SRC,
+ gradient, NULL, image,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ width, 1);
pixman_image_unref (gradient);
pixman_image_unref (image);
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 891e5bc..662e94e 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1649,12 +1649,12 @@ _cairo_image_surface_fixup_unbounded (cairo_image_surface_t *dst,
int height = rects->unbounded.height;
if (mask != NULL) {
- pixman_image_composite (PIXMAN_OP_OUT_REVERSE,
- mask, NULL, dst->pixman_image,
- x + mask_x, y + mask_y,
- 0, 0,
- x, y,
- width, height);
+ pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
+ mask, NULL, dst->pixman_image,
+ x + mask_x, y + mask_y,
+ 0, 0,
+ x, y,
+ width, height);
} else {
pixman_color_t color = { 0, };
pixman_box32_t box = { x, y, width, height };
commit 393da364a7f26e696141c58d4fb6fdefb2ea245a
Author: Benjamin Otte <otte at redhat.com>
Date: Wed Apr 28 18:18:15 2010 +0200
fallback: Sanitize code that queries surface extents
The previous code was setting extents.is_bounded, but that value has a
completely different meaning.
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 36ff667..ea3abec 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -907,8 +907,8 @@ _cairo_surface_fallback_paint (cairo_surface_t *surface,
cairo_status_t status;
cairo_traps_t traps;
- extents.is_bounded = _cairo_surface_get_extents (surface, &rect);
- assert (extents.is_bounded || clip);
+ if (!_cairo_surface_get_extents (surface, &rect))
+ ASSERT_NOT_REACHED;
status = _cairo_composite_rectangles_init_for_paint (&extents,
rect.width,
@@ -1001,8 +1001,8 @@ _cairo_surface_fallback_mask (cairo_surface_t *surface,
cairo_rectangle_int_t rect;
cairo_status_t status;
- extents.is_bounded = _cairo_surface_get_extents (surface, &rect);
- assert (extents.is_bounded || clip);
+ if (!_cairo_surface_get_extents (surface, &rect))
+ ASSERT_NOT_REACHED;
status = _cairo_composite_rectangles_init_for_mask (&extents,
rect.width, rect.height,
@@ -1045,8 +1045,8 @@ _cairo_surface_fallback_stroke (cairo_surface_t *surface,
cairo_rectangle_int_t rect;
cairo_status_t status;
- extents.is_bounded = _cairo_surface_get_extents (surface, &rect);
- assert (extents.is_bounded || clip);
+ if (!_cairo_surface_get_extents (surface, &rect))
+ ASSERT_NOT_REACHED;
status = _cairo_composite_rectangles_init_for_stroke (&extents,
rect.width,
@@ -1151,8 +1151,8 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface,
cairo_rectangle_int_t rect;
cairo_status_t status;
- extents.is_bounded = _cairo_surface_get_extents (surface, &rect);
- assert (extents.is_bounded || clip);
+ if (!_cairo_surface_get_extents (surface, &rect))
+ ASSERT_NOT_REACHED;
status = _cairo_composite_rectangles_init_for_fill (&extents,
rect.width,
@@ -1319,8 +1319,8 @@ _cairo_surface_fallback_show_glyphs (cairo_surface_t *surface,
cairo_rectangle_int_t rect;
cairo_status_t status;
- extents.is_bounded = _cairo_surface_get_extents (surface, &rect);
- assert (extents.is_bounded || clip);
+ if (!_cairo_surface_get_extents (surface, &rect))
+ ASSERT_NOT_REACHED;
status = _cairo_composite_rectangles_init_for_glyphs (&extents,
rect.width,
More information about the cairo-commit
mailing list