mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 14:58:06 +02:00
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().
This commit is contained in:
parent
37c5c2dbe5
commit
13b7364836
6 changed files with 46 additions and 44 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue