mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 19:00:22 +01:00
surface: Make backend-specific map/unmap functions symmetric
Map allocates a surface. Symmetrically, unmap should destroy it.
This commit is contained in:
parent
df7829e2cc
commit
d6fb8d2134
11 changed files with 48 additions and 47 deletions
|
|
@ -1170,11 +1170,18 @@ static cairo_int_status_t
|
|||
_cairo_gl_surface_unmap_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image)
|
||||
{
|
||||
return _cairo_gl_surface_draw_image (abstract_surface, image,
|
||||
0, 0,
|
||||
image->width, image->height,
|
||||
image->base.device_transform_inverse.x0,
|
||||
image->base.device_transform_inverse.y0);
|
||||
cairo_int_status_t status;
|
||||
|
||||
status = _cairo_gl_surface_draw_image (abstract_surface, image,
|
||||
0, 0,
|
||||
image->width, image->height,
|
||||
image->base.device_transform_inverse.x0,
|
||||
image->base.device_transform_inverse.y0);
|
||||
|
||||
cairo_surface_finish (&image->base);
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
|
|
|
|||
|
|
@ -821,6 +821,9 @@ cairo_int_status_t
|
|||
_cairo_image_surface_unmap_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_surface_finish (&image->base);
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -596,6 +596,7 @@ _cairo_os2_surface_map_to_image (void *abstract_surface,
|
|||
surface->pixel_array_lend_count++;
|
||||
DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
|
||||
|
||||
/* XXX: BROKEN! */
|
||||
*image_out = _cairo_surface_create_for_rectangle_int (surface->image_surface,
|
||||
extents);
|
||||
|
||||
|
|
|
|||
|
|
@ -112,8 +112,7 @@ _cairo_quartz_image_surface_map_to_image (void *asurface,
|
|||
const cairo_rectangle_int_t *extents)
|
||||
{
|
||||
cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface;
|
||||
|
||||
return cairo_surface_map_to_image (&surface->imageSurface->base, extents);
|
||||
return _cairo_surface_map_to_image (&surface->imageSurface->base, extents);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
@ -121,9 +120,7 @@ _cairo_quartz_image_surface_unmap_image (void *asurface,
|
|||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface;
|
||||
|
||||
cairo_surface_unmap_image (&surface->imageSurface->base, &image->base);
|
||||
return cairo_surface_status (&surface->imageSurface->base);
|
||||
return _cairo_surface_unmap_image (&surface->imageSurface->base, image);
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
|
|
|
|||
|
|
@ -1567,6 +1567,7 @@ _cairo_quartz_surface_map_to_image (void *abstract_surface,
|
|||
return _cairo_surface_create_in_error (status);
|
||||
|
||||
/* Is this legitimate? shouldn't it return an image surface? */
|
||||
/* XXX: BROKEN! */
|
||||
|
||||
subsurface = _cairo_surface_create_for_rectangle_int (&image->base, extents);
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
|
|
|||
|
|
@ -479,11 +479,7 @@ _cairo_surface_observer_map_to_image (void *abstract_surface,
|
|||
const cairo_rectangle_int_t *extents)
|
||||
{
|
||||
cairo_surface_observer_t *surface = abstract_surface;
|
||||
|
||||
if (surface->target->backend->map_to_image == NULL)
|
||||
return NULL;
|
||||
|
||||
return surface->target->backend->map_to_image (surface->target, extents);
|
||||
return _cairo_surface_map_to_image (surface->target, extents);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
@ -491,11 +487,7 @@ _cairo_surface_observer_unmap_image (void *abstract_surface,
|
|||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_surface_observer_t *surface = abstract_surface;
|
||||
|
||||
if (surface->target->backend->unmap_image == NULL)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
return surface->target->backend->unmap_image (surface->target, image);
|
||||
return _cairo_surface_unmap_image (surface->target, image);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -91,16 +91,12 @@ _cairo_surface_subsurface_map_to_image (void *abstract_surface,
|
|||
cairo_surface_subsurface_t *surface = abstract_surface;
|
||||
cairo_rectangle_int_t target_extents;
|
||||
|
||||
if (surface->target->backend->map_to_image == NULL)
|
||||
return NULL;
|
||||
|
||||
target_extents.x = extents->x + surface->extents.x;
|
||||
target_extents.y = extents->y + surface->extents.y;
|
||||
target_extents.width = extents->width;
|
||||
target_extents.height = extents->height;
|
||||
|
||||
return surface->target->backend->map_to_image (surface->target,
|
||||
&target_extents);
|
||||
return _cairo_surface_map_to_image (surface->target, &target_extents);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
@ -108,11 +104,7 @@ _cairo_surface_subsurface_unmap_image (void *abstract_surface,
|
|||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_surface_subsurface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->target->backend->unmap_image == NULL)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
return surface->target->backend->unmap_image (surface->target, image);
|
||||
return _cairo_surface_unmap_image (surface->target, image);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
|
|||
|
|
@ -694,7 +694,7 @@ _cairo_surface_unmap_image (cairo_surface_t *surface,
|
|||
{
|
||||
status = surface->backend->unmap_image (surface, image);
|
||||
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
goto destroy;
|
||||
return status;
|
||||
}
|
||||
|
||||
_cairo_pattern_init_for_surface (&pattern, &image->base);
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ _cairo_xcb_surface_map_to_image (void *abstract_surface,
|
|||
cairo_status_t status;
|
||||
|
||||
if (surface->fallback)
|
||||
return surface->fallback->base.backend->map_to_image (&surface->fallback->base, extents);
|
||||
return _cairo_surface_map_to_image (&surface->fallback->base, extents);
|
||||
|
||||
image = _get_image (surface, TRUE,
|
||||
extents->x, extents->y,
|
||||
|
|
@ -799,10 +799,17 @@ _cairo_xcb_surface_unmap (void *abstract_surface,
|
|||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_xcb_surface_t *surface = abstract_surface;
|
||||
cairo_int_status_t status;
|
||||
|
||||
if (surface->fallback)
|
||||
return surface->fallback->base.backend->unmap_image (&surface->fallback->base, image);
|
||||
return _put_image (abstract_surface, image);
|
||||
return _cairo_surface_unmap_image (&surface->fallback->base, image);
|
||||
|
||||
status = _put_image (abstract_surface, image);
|
||||
|
||||
cairo_surface_finish (&image->base);
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
|
|
|
|||
|
|
@ -1294,11 +1294,18 @@ static cairo_int_status_t
|
|||
_cairo_xlib_surface_unmap_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image)
|
||||
{
|
||||
return _cairo_xlib_surface_draw_image (abstract_surface, image,
|
||||
0, 0,
|
||||
image->width, image->height,
|
||||
image->base.device_transform_inverse.x0,
|
||||
image->base.device_transform_inverse.y0);
|
||||
cairo_int_status_t status;
|
||||
|
||||
status = _cairo_xlib_surface_draw_image (abstract_surface, image,
|
||||
0, 0,
|
||||
image->width, image->height,
|
||||
image->base.device_transform_inverse.x0,
|
||||
image->base.device_transform_inverse.y0);
|
||||
|
||||
cairo_surface_finish (&image->base);
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ _cairo_xlib_xcb_surface_map_to_image (void *abstract_surface,
|
|||
const cairo_rectangle_int_t *extents)
|
||||
{
|
||||
cairo_xlib_xcb_surface_t *surface = abstract_surface;
|
||||
return cairo_surface_map_to_image (&surface->xcb->base, extents);
|
||||
return _cairo_surface_map_to_image (&surface->xcb->base, extents);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
@ -129,13 +129,7 @@ _cairo_xlib_xcb_surface_unmap (void *abstract_surface,
|
|||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_xlib_xcb_surface_t *surface = abstract_surface;
|
||||
|
||||
/* cairo_surface_unmap_image destroys the surface, so get a new reference
|
||||
* for it to destroy.
|
||||
*/
|
||||
cairo_surface_reference (&image->base);
|
||||
cairo_surface_unmap_image (&surface->xcb->base, &image->base);
|
||||
return cairo_surface_status (&surface->xcb->base);
|
||||
return _cairo_surface_unmap_image (&surface->xcb->base, image);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue