diff options
author | Andrea Canciani <ranma42@gmail.com> | 2012-01-11 17:17:29 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2012-05-26 16:07:00 +0200 |
commit | 13b7364836e14b811bbeb3ba0849e6d6c0fb1dd3 (patch) | |
tree | f1d23a82bfa9d7ef0c4bc4251e767c0579aef50e /src | |
parent | 37c5c2dbe55f64ee84ab248eb0072d5d7c5145cc (diff) |
surface: Use the internal map/unmap
In many places Cairo maps/unmaps surfaces to perform operations on the
raw image, but it doesn't care about the format being invalid. All of
these are appropriate users of _cairo_surface_map_to_image().
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-fallback-compositor.c | 56 | ||||
-rw-r--r-- | src/cairo-gl-operand.c | 8 | ||||
-rw-r--r-- | src/cairo-surface-observer.c | 6 | ||||
-rw-r--r-- | src/cairo-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-xlib-source.c | 16 | ||||
-rw-r--r-- | src/cairoint.h | 2 |
6 files changed, 46 insertions, 44 deletions
diff --git a/src/cairo-fallback-compositor.c b/src/cairo-fallback-compositor.c index efc8a79a..3f6199fe 100644 --- a/src/cairo-fallback-compositor.c +++ b/src/cairo-fallback-compositor.c @@ -42,6 +42,7 @@ #include "cairoint.h" #include "cairo-compositor-private.h" +#include "cairo-image-surface-private.h" #include "cairo-surface-offset-private.h" /* high-level compositor interface */ @@ -50,41 +51,43 @@ static cairo_int_status_t _cairo_fallback_compositor_paint (const cairo_compositor_t *_compositor, cairo_composite_rectangles_t *extents) { - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - image = cairo_surface_map_to_image (extents->surface, &extents->unbounded); - status = _cairo_surface_offset_paint (image, + + image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded); + + status = _cairo_surface_offset_paint (&image->base, extents->unbounded.x, extents->unbounded.y, extents->op, &extents->source_pattern.base, extents->clip); - cairo_surface_unmap_image (extents->surface, image); - return status; + return _cairo_surface_unmap_image (extents->surface, image); } static cairo_int_status_t _cairo_fallback_compositor_mask (const cairo_compositor_t *_compositor, cairo_composite_rectangles_t *extents) { - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - image = cairo_surface_map_to_image (extents->surface, &extents->unbounded); - status = _cairo_surface_offset_mask (image, + + image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded); + + status = _cairo_surface_offset_mask (&image->base, extents->unbounded.x, extents->unbounded.y, extents->op, &extents->source_pattern.base, &extents->mask_pattern.base, extents->clip); - cairo_surface_unmap_image (extents->surface, image); - return status; + return _cairo_surface_unmap_image (extents->surface, image); } static cairo_int_status_t @@ -97,12 +100,14 @@ _cairo_fallback_compositor_stroke (const cairo_compositor_t *_compositor, double tolerance, cairo_antialias_t antialias) { - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - image = cairo_surface_map_to_image (extents->surface, &extents->unbounded); - status = _cairo_surface_offset_stroke (image, + + image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded); + + status = _cairo_surface_offset_stroke (&image->base, extents->unbounded.x, extents->unbounded.y, extents->op, @@ -112,9 +117,8 @@ _cairo_fallback_compositor_stroke (const cairo_compositor_t *_compositor, tolerance, antialias, extents->clip); - cairo_surface_unmap_image (extents->surface, image); - return status; + return _cairo_surface_unmap_image (extents->surface, image); } static cairo_int_status_t @@ -125,12 +129,14 @@ _cairo_fallback_compositor_fill (const cairo_compositor_t *_compositor, double tolerance, cairo_antialias_t antialias) { - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - image = cairo_surface_map_to_image (extents->surface, &extents->unbounded); - status = _cairo_surface_offset_fill (image, + + image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded); + + status = _cairo_surface_offset_fill (&image->base, extents->unbounded.x, extents->unbounded.y, extents->op, @@ -138,9 +144,8 @@ _cairo_fallback_compositor_fill (const cairo_compositor_t *_compositor, path, fill_rule, tolerance, antialias, extents->clip); - cairo_surface_unmap_image (extents->surface, image); - return status; + return _cairo_surface_unmap_image (extents->surface, image); } static cairo_int_status_t @@ -151,21 +156,22 @@ _cairo_fallback_compositor_glyphs (const cairo_compositor_t *_compositor, int num_glyphs, cairo_bool_t overlap) { - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - image = cairo_surface_map_to_image (extents->surface, &extents->unbounded); - status = _cairo_surface_offset_glyphs (image, + + image = _cairo_surface_map_to_image (extents->surface, &extents->unbounded); + + status = _cairo_surface_offset_glyphs (&image->base, extents->unbounded.x, extents->unbounded.y, extents->op, &extents->source_pattern.base, scaled_font, glyphs, num_glyphs, extents->clip); - cairo_surface_unmap_image (extents->surface, image); - return status; + return _cairo_surface_unmap_image (extents->surface, image); } const cairo_compositor_t _cairo_fallback_compositor = { diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c index bbb501e0..d3df95b5 100644 --- a/src/cairo-gl-operand.c +++ b/src/cairo-gl-operand.c @@ -292,7 +292,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, cairo_status_t status; cairo_gl_surface_t *surface; cairo_gl_context_t *ctx; - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_bool_t src_is_gl_surface = FALSE; cairo_rectangle_int_t map_extents; @@ -311,7 +311,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, extents->width, extents->height); map_extents = *extents; map_extents.x = map_extents.y = 0; - image = cairo_surface_map_to_image (&surface->base, &map_extents); + image = _cairo_surface_map_to_image (&surface->base, &map_extents); /* If the pattern is a GL surface, it belongs to some other GL context, so we need to release this device while we paint it to the image. */ @@ -321,7 +321,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, goto fail; } - status = _cairo_surface_offset_paint (image, extents->x, extents->y, + status = _cairo_surface_offset_paint (&image->base, extents->x, extents->y, CAIRO_OPERATOR_SOURCE, _src, NULL); if (src_is_gl_surface) { @@ -330,7 +330,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, goto fail; } - cairo_surface_unmap_image (&surface->base, image); + status = _cairo_surface_unmap_image (&surface->base, image); status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) goto fail; diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c index 125f96bc..83fd1f80 100644 --- a/src/cairo-surface-observer.c +++ b/src/cairo-surface-observer.c @@ -662,9 +662,9 @@ sync (cairo_surface_t *target, int x, int y) extents.width = 1; extents.height = 1; - cairo_surface_unmap_image (target, - cairo_surface_map_to_image (target, - &extents)); + _cairo_surface_unmap_image (target, + _cairo_surface_map_to_image (target, + &extents)); } static void diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 4aa3ddb3..0e5484c8 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -808,7 +808,6 @@ cairo_surface_map_to_image (cairo_surface_t *surface, return imagesurf; } -slim_hidden_def (cairo_surface_map_to_image); /** * cairo_surface_unmap_image: @@ -864,7 +863,6 @@ error: cairo_surface_finish (image); cairo_surface_destroy (image); } -slim_hidden_def (cairo_surface_unmap_image); cairo_surface_t * _cairo_surface_create_similar_solid (cairo_surface_t *other, diff --git a/src/cairo-xlib-source.c b/src/cairo-xlib-source.c index dec76222..ac0fdf8b 100644 --- a/src/cairo-xlib-source.c +++ b/src/cairo-xlib-source.c @@ -259,7 +259,7 @@ render_pattern (cairo_xlib_surface_t *dst, { Display *dpy = dst->display->display; cairo_xlib_surface_t *src; - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_status_t status; cairo_rectangle_int_t map_extents; @@ -276,11 +276,11 @@ render_pattern (cairo_xlib_surface_t *dst, map_extents = *extents; map_extents.x = map_extents.y = 0; - image = cairo_surface_map_to_image (&src->base, &map_extents); - status = _cairo_surface_offset_paint (image, extents->x, extents->y, + image = _cairo_surface_map_to_image (&src->base, &map_extents); + status = _cairo_surface_offset_paint (&image->base, extents->x, extents->y, CAIRO_OPERATOR_SOURCE, pattern, NULL); - cairo_surface_unmap_image (&src->base, image); + status = _cairo_surface_unmap_image (&src->base, image); if (unlikely (status)) { cairo_surface_destroy (&src->base); return _cairo_surface_create_in_error (status); @@ -913,7 +913,7 @@ surface_source (cairo_xlib_surface_t *dst, int *src_x, int *src_y) { cairo_xlib_surface_t *src; - cairo_surface_t *image; + cairo_image_surface_t *image; cairo_surface_pattern_t local_pattern; cairo_status_t status; cairo_rectangle_int_t upload, limit, map_extents; @@ -946,12 +946,12 @@ surface_source (cairo_xlib_surface_t *dst, map_extents = upload; map_extents.x = map_extents.y = 0; - image = cairo_surface_map_to_image (&src->base, &map_extents); - status = _cairo_surface_paint (image, + image = _cairo_surface_map_to_image (&src->base, &map_extents); + status = _cairo_surface_paint (&image->base, CAIRO_OPERATOR_SOURCE, &local_pattern.base, NULL); - cairo_surface_unmap_image (&src->base, image); + status = _cairo_surface_unmap_image (&src->base, image); _cairo_pattern_fini (&local_pattern.base); if (unlikely (status)) { diff --git a/src/cairoint.h b/src/cairoint.h index 5b3d653f..2c9f2dd7 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1922,7 +1922,6 @@ slim_hidden_proto (cairo_surface_get_font_options); slim_hidden_proto (cairo_surface_get_mime_data); slim_hidden_proto (cairo_surface_get_type); slim_hidden_proto (cairo_surface_has_show_text_glyphs); -slim_hidden_proto (cairo_surface_map_to_image); slim_hidden_proto (cairo_surface_mark_dirty); slim_hidden_proto (cairo_surface_mark_dirty_rectangle); slim_hidden_proto_no_warn (cairo_surface_reference); @@ -1932,7 +1931,6 @@ slim_hidden_proto (cairo_surface_set_mime_data); slim_hidden_proto (cairo_surface_show_page); slim_hidden_proto (cairo_surface_status); slim_hidden_proto (cairo_surface_supports_mime_type); -slim_hidden_proto (cairo_surface_unmap_image); slim_hidden_proto (cairo_text_cluster_allocate); slim_hidden_proto (cairo_text_cluster_free); slim_hidden_proto (cairo_toy_font_face_create); |