summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-09-15 13:20:52 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-09-19 12:22:58 -0400
commitee6af72dadaf9eb049bfeb35dc9ff57c3902403a (patch)
tree9ab9c61824769179501ede1f79d41eb7efc4d1c1
parentc710d0fae2a9dc7d20913e5e39a1bb53f7c942db (diff)
Move delegation of src/dest iter init into pixman-implementation.c
Instead of relying on each implementation to delegate when an iterator can't be initialized, change the type of iterator initializers to boolean and make pixman-implementation.c do the delegation whenever an iterator initializer returns FALSE.
-rw-r--r--pixman/pixman-general.c10
-rw-r--r--pixman/pixman-implementation.c42
-rw-r--r--pixman/pixman-mmx.c6
-rw-r--r--pixman/pixman-noop.c14
-rw-r--r--pixman/pixman-private.h8
-rw-r--r--pixman/pixman-sse2.c6
6 files changed, 49 insertions, 37 deletions
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 6c6bda0d..42a84a0b 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -37,7 +37,7 @@
#include <string.h>
#include "pixman-private.h"
-static void
+static pixman_bool_t
general_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
{
pixman_image_t *image = iter->image;
@@ -54,18 +54,24 @@ general_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
_pixman_bits_image_src_iter_init (image, iter);
else
_pixman_log_error (FUNC, "Pixman bug: unknown image type\n");
+
+ return TRUE;
}
-static void
+static pixman_bool_t
general_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
{
if (iter->image->type == BITS)
{
_pixman_bits_image_dest_iter_init (iter->image, iter);
+
+ return TRUE;
}
else
{
_pixman_log_error (FUNC, "Trying to write to a non-writable image");
+
+ return FALSE;
}
}
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index 5607f9db..18da162d 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -27,20 +27,6 @@
#include <stdlib.h>
#include "pixman-private.h"
-static void
-delegate_src_iter_init (pixman_implementation_t *imp,
- pixman_iter_t * iter)
-{
- imp->delegate->src_iter_init (imp->delegate, iter);
-}
-
-static void
-delegate_dest_iter_init (pixman_implementation_t *imp,
- pixman_iter_t * iter)
-{
- imp->delegate->dest_iter_init (imp->delegate, iter);
-}
-
pixman_implementation_t *
_pixman_implementation_create (pixman_implementation_t *delegate,
const pixman_fast_path_t *fast_paths)
@@ -63,8 +49,8 @@ _pixman_implementation_create (pixman_implementation_t *delegate,
*/
imp->blt = NULL;
imp->fill = NULL;
- imp->src_iter_init = delegate_src_iter_init;
- imp->dest_iter_init = delegate_dest_iter_init;
+ imp->src_iter_init = NULL;
+ imp->dest_iter_init = NULL;
imp->fast_paths = fast_paths;
@@ -173,7 +159,7 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
return FALSE;
}
-void
+pixman_bool_t
_pixman_implementation_src_iter_init (pixman_implementation_t *imp,
pixman_iter_t *iter,
pixman_image_t *image,
@@ -194,10 +180,18 @@ _pixman_implementation_src_iter_init (pixman_implementation_t *imp,
iter->iter_flags = iter_flags;
iter->image_flags = image_flags;
- (*imp->src_iter_init) (imp, iter);
+ while (imp)
+ {
+ if (imp->src_iter_init && (*imp->src_iter_init) (imp, iter))
+ return TRUE;
+
+ imp = imp->delegate;
+ }
+
+ return FALSE;
}
-void
+pixman_bool_t
_pixman_implementation_dest_iter_init (pixman_implementation_t *imp,
pixman_iter_t *iter,
pixman_image_t *image,
@@ -218,7 +212,15 @@ _pixman_implementation_dest_iter_init (pixman_implementation_t *imp,
iter->iter_flags = iter_flags;
iter->image_flags = image_flags;
- (*imp->dest_iter_init) (imp, iter);
+ while (imp)
+ {
+ if (imp->dest_iter_init && (*imp->dest_iter_init) (imp, iter))
+ return TRUE;
+
+ imp = imp->delegate;
+ }
+
+ return FALSE;
}
pixman_bool_t
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index a5a56f91..fccba9d6 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -3915,7 +3915,7 @@ static const fetcher_info_t fetchers[] =
{ PIXMAN_null }
};
-static void
+static pixman_bool_t
mmx_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
{
pixman_image_t *image = iter->image;
@@ -3940,12 +3940,12 @@ mmx_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
iter->stride = s;
iter->get_scanline = f->get_scanline;
- return;
+ return TRUE;
}
}
}
- imp->delegate->src_iter_init (imp->delegate, iter);
+ return FALSE;
}
static const pixman_fast_path_t mmx_fast_paths[] =
diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c
index 7b017e8e..7b9759ff 100644
--- a/pixman/pixman-noop.c
+++ b/pixman/pixman-noop.c
@@ -59,7 +59,7 @@ get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
return NULL;
}
-static void
+static pixman_bool_t
noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
{
pixman_image_t *image = iter->image;
@@ -117,11 +117,13 @@ noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
}
else
{
- (* imp->delegate->src_iter_init) (imp->delegate, iter);
+ return FALSE;
}
+
+ return TRUE;
}
-static void
+static pixman_bool_t
noop_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
{
pixman_image_t *image = iter->image;
@@ -138,10 +140,12 @@ noop_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
iter->get_scanline = _pixman_iter_get_scanline_noop;
iter->write_back = dest_write_back_direct;
+
+ return TRUE;
}
else
{
- (* imp->delegate->dest_iter_init) (imp->delegate, iter);
+ return FALSE;
}
}
@@ -156,7 +160,7 @@ _pixman_implementation_create_noop (pixman_implementation_t *fallback)
{
pixman_implementation_t *imp =
_pixman_implementation_create (fallback, noop_fast_paths);
-
+
imp->src_iter_init = noop_src_iter_init;
imp->dest_iter_init = noop_dest_iter_init;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index dbfa8295..fe5f7c63 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -445,8 +445,8 @@ typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp,
int width,
int height,
uint32_t xor);
-typedef void (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
- pixman_iter_t *iter);
+typedef pixman_bool_t (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
+ pixman_iter_t *iter);
void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
@@ -521,7 +521,7 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
int height,
uint32_t xor);
-void
+pixman_bool_t
_pixman_implementation_src_iter_init (pixman_implementation_t *imp,
pixman_iter_t *iter,
pixman_image_t *image,
@@ -533,7 +533,7 @@ _pixman_implementation_src_iter_init (pixman_implementation_t *imp,
iter_flags_t flags,
uint32_t image_flags);
-void
+pixman_bool_t
_pixman_implementation_dest_iter_init (pixman_implementation_t *imp,
pixman_iter_t *iter,
pixman_image_t *image,
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index 428db733..e273a951 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -6024,7 +6024,7 @@ static const fetcher_info_t fetchers[] =
{ PIXMAN_null }
};
-static void
+static pixman_bool_t
sse2_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
{
pixman_image_t *image = iter->image;
@@ -6049,12 +6049,12 @@ sse2_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter)
iter->stride = s;
iter->get_scanline = f->get_scanline;
- return;
+ return TRUE;
}
}
}
- imp->delegate->src_iter_init (imp->delegate, iter);
+ return FALSE;
}
#if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)