mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-23 19:10:44 +02:00
[ps] Free images after emitting patterns.
Ensure that the temporary images are freed after we finish with the pattern. Note that we are using 3 members of the surface for temporary storage whilst emitting patterns, this should be reviewed.
This commit is contained in:
parent
e6102dbe02
commit
d20e5fc2d9
2 changed files with 19 additions and 2 deletions
|
|
@ -67,9 +67,12 @@ typedef struct cairo_ps_surface {
|
|||
double height;
|
||||
int bbox_x1, bbox_y1, bbox_x2, bbox_y2;
|
||||
cairo_matrix_t cairo_to_ps;
|
||||
|
||||
/* XXX These 3 are used as temporary storage whilst emitting patterns */
|
||||
cairo_image_surface_t *image;
|
||||
cairo_image_surface_t *acquired_image;
|
||||
void *image_extra;
|
||||
|
||||
cairo_bool_t use_string_datasource;
|
||||
|
||||
cairo_bool_t current_pattern_is_solid_color;
|
||||
|
|
|
|||
|
|
@ -2333,6 +2333,9 @@ _cairo_ps_surface_acquire_surface (cairo_ps_surface_t *surface,
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
surface->acquired_image = NULL;
|
||||
surface->image = NULL;
|
||||
|
||||
if (_cairo_surface_is_meta (pattern->surface)) {
|
||||
cairo_surface_t *meta_surface = pattern->surface;
|
||||
cairo_rectangle_int_t pattern_extents;
|
||||
|
|
@ -2384,8 +2387,12 @@ _cairo_ps_surface_acquire_surface (cairo_ps_surface_t *surface,
|
|||
rect.width,
|
||||
rect.height);
|
||||
_cairo_pattern_fini (&pad_pattern.base);
|
||||
if (unlikely (status))
|
||||
if (unlikely (status)) {
|
||||
if (pad_image != &surface->acquired_image->base)
|
||||
cairo_surface_destroy (pad_image);
|
||||
|
||||
goto BAIL;
|
||||
}
|
||||
}
|
||||
|
||||
surface->image = (cairo_image_surface_t *) pad_image;
|
||||
|
|
@ -2436,10 +2443,17 @@ static void
|
|||
_cairo_ps_surface_release_surface (cairo_ps_surface_t *surface,
|
||||
cairo_surface_pattern_t *pattern)
|
||||
{
|
||||
if (!_cairo_surface_is_meta (pattern->surface))
|
||||
if (surface->image != &surface->acquired_image->base)
|
||||
cairo_surface_destroy (surface->image);
|
||||
|
||||
if (! _cairo_surface_is_meta (pattern->surface)) {
|
||||
_cairo_surface_release_source_image (pattern->surface,
|
||||
surface->acquired_image,
|
||||
surface->image_extra);
|
||||
}
|
||||
|
||||
surface->acquired_image = NULL;
|
||||
surface->image = NULL;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue