Add API to set a function to be called when the image is destroyed.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 13 Jun 2009 13:32:59 +0000 (09:32 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 13 Jun 2009 14:20:43 +0000 (10:20 -0400)
pixman/pixman-image.c
pixman/pixman-private.h
pixman/pixman.h

index 9b4b73d..e95cff2 100644 (file)
@@ -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
index ae51447..4a5de59 100644 (file)
@@ -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
index 29c054a..a954d2c 100644 (file)
@@ -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,