[cairo] [patch] surface: set image->parent = NULL
Henry (Yu) Song - SISA
hsong at sisa.samsung.com
Wed Jan 30 12:13:19 PST 2013
Please discard previous submitted patch, this patch is better. Please review
>From 3ec142e09018dc6a58f16c325fe77091e6d086c3 Mon Sep 17 00:00:00 2001
From: Henry Song <henry.song at samsung.com>
Date: Wed, 30 Jan 2013 08:29:06 -0800
Subject: [PATCH 1/2] surface: increase reference count for parent of cloned
image
If an image surface is created as result of
_cairo_image_surface_clone_subimage() during either
private call _cairo_surface_map_to_image() or
public call cairo_surface_map_to_image(),
we need to increase reference count of its parent to account for
parent's reference count descrease when image is destroyed
---
src/cairo-surface.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index ffffef8..de16d86 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -639,6 +639,10 @@ _cairo_surface_map_to_image (cairo_surface_t *surface,
if (image == NULL)
image = _cairo_image_surface_clone_subimage (surface, extents);
+ /* add a reference count to parent if it exists */
+ if (image->parent)
+ cairo_surface_reference (image->parent);
+
return image;
}
@@ -791,6 +795,10 @@ cairo_surface_map_to_image (cairo_surface_t *surface,
if (image->format == CAIRO_FORMAT_INVALID) {
cairo_surface_destroy (&image->base);
image = _cairo_image_surface_clone_subimage (surface, extents);
+
+ /* if parent exists, add reference count */
+ if (image->parent)
+ cairo_surface_reference (image->parent);
}
return &image->base;
--
1.7.9.5
________________________________________
From: cairo-bounces+hsong=sisa.samsung.com at cairographics.org [cairo-bounces+hsong=sisa.samsung.com at cairographics.org] on behalf of Henry (Yu) Song - SISA [hsong at sisa.samsung.com]
Sent: Wednesday, January 30, 2013 8:31 AM
To: cairo at cairographics.org
Subject: [cairo] [patch] surface: set image->parent = NULL
>From 5d9a4aeaccc6497105ae4ad1347bc08165cff92f Mon Sep 17 00:00:00 2001
From: Henry Song <henry.song at samsung.com>
Date: Wed, 30 Jan 2013 08:29:06 -0800
Subject: [PATCH] surface: for image->parent = NULL in
cairo_surface_map_to_image()
This ensures parent's reference count will get decreased during
cairo_surface_unmap_image()
---
More information about the cairo
mailing list