[Pixman] [PATCH 2/3] Add support for iter finalizers
Søren Sandmann
sandmann at cs.au.dk
Sat Aug 3 11:36:38 PDT 2013
From: Søren Sandmann Pedersen <ssp at redhat.com>
Iterators may sometimes need to allocate auxillary memory. In order to
be able to free this memory, optional iterator finalizers are
required.
---
pixman/pixman-general.c | 7 +++++++
pixman/pixman-image.c | 3 +++
pixman/pixman-implementation.c | 1 +
pixman/pixman-private.h | 2 ++
4 files changed, 13 insertions(+)
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 4da5da5..6310bff 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -208,6 +208,13 @@ general_composite_rect (pixman_implementation_t *imp,
dest_iter.write_back (&dest_iter);
}
+ if (src_iter.fini)
+ src_iter.fini (&src_iter);
+ if (mask_iter.fini)
+ mask_iter.fini (&mask_iter);
+ if (dest_iter.fini)
+ dest_iter.fini (&dest_iter);
+
if (scanline_buffer != (uint8_t *) stack_scanline_buffer)
free (scanline_buffer);
}
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 4f9c2f9..1ff1a49 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -926,6 +926,9 @@ _pixman_image_get_solid (pixman_implementation_t *imp,
ITER_NARROW | ITER_SRC, image->common.flags);
result = *iter.get_scanline (&iter, NULL);
+
+ if (iter.fini)
+ iter.fini (&iter);
}
/* If necessary, convert RGB <--> BGR. */
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index 160847a..5884054 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -313,6 +313,7 @@ _pixman_implementation_iter_init (pixman_implementation_t *imp,
iter->height = height;
iter->iter_flags = iter_flags;
iter->image_flags = image_flags;
+ iter->fini = NULL;
if (!iter->image)
{
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index af4a0b6..9646605 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -209,6 +209,7 @@ union pixman_image
typedef struct pixman_iter_t pixman_iter_t;
typedef uint32_t *(* pixman_iter_get_scanline_t) (pixman_iter_t *iter, const uint32_t *mask);
typedef void (* pixman_iter_write_back_t) (pixman_iter_t *iter);
+typedef void (* pixman_iter_fini_t) (pixman_iter_t *iter);
typedef enum
{
@@ -255,6 +256,7 @@ struct pixman_iter_t
/* These function pointers are initialized by the implementation */
pixman_iter_get_scanline_t get_scanline;
pixman_iter_write_back_t write_back;
+ pixman_iter_fini_t fini;
/* These fields are scratch data that implementations can use */
void * data;
--
1.7.11.7
More information about the Pixman
mailing list