From 68ec1244cdd4aa2703739a19c7c3917231b7b889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Sat, 13 Jun 2009 09:32:59 -0400 Subject: [PATCH] Add API to set a function to be called when the image is destroyed. --- pixman/pixman-image.c | 15 +++++++++++++++ pixman/pixman-private.h | 3 +++ pixman/pixman.h | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 9b4b73d..e95cff2 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -113,6 +113,8 @@ _pixman_image_allocate (void) common->write_func = NULL; common->classify = NULL; common->client_clip = FALSE; + common->destroy_func = NULL; + common->destroy_data = NULL; } return image; @@ -191,6 +193,9 @@ pixman_image_unref (pixman_image_t *image) if (common->ref_count == 0) { + if (image->common.destroy_func) + image->common.destroy_func (image, image->common.destroy_data); + pixman_region32_fini (&common->clip_region); if (common->transform) @@ -228,6 +233,16 @@ pixman_image_unref (pixman_image_t *image) return FALSE; } +PIXMAN_EXPORT void +pixman_image_set_destroy_function (pixman_image_t *image, + pixman_image_destroy_func_t func, + void *data) +{ + image->common.destroy_func = func; + image->common.destroy_data = data; +} + + /* Constructors */ void diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index ae51447..4a5de59 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -316,6 +316,9 @@ struct image_common property_changed_func_t property_changed; scanFetchProc get_scanline_32; scanFetchProc get_scanline_64; + + pixman_image_destroy_func_t destroy_func; + void * destroy_data; }; struct source_image diff --git a/pixman/pixman.h b/pixman/pixman.h index 29c054a..a954d2c 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -597,6 +597,8 @@ typedef struct pixman_gradient_stop pixman_gradient_stop_t; typedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size); typedef void (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size); +typedef void (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data); + struct pixman_gradient_stop { pixman_fixed_t x; pixman_color_t color; @@ -748,6 +750,9 @@ pixman_image_t *pixman_image_create_bits (pixman_format_code_t pixman_image_t *pixman_image_ref (pixman_image_t *image); pixman_bool_t pixman_image_unref (pixman_image_t *image); +void pixman_image_set_destroy_function (pixman_image_t *image, + pixman_image_destroy_func_t function, + void *data); /* Set properties */ pixman_bool_t pixman_image_set_clip_region (pixman_image_t *image, -- 2.7.4