[Pixman] [PATCH 09/11] Add _pixman_implementation_iter_init() and use instead of _src/_dest_init()
Søren Sandmann Pedersen
soren.sandmann at gmail.com
Wed May 22 06:45:18 PDT 2013
A new field, 'iter_info', is added to the implementation struct, and
all the implementations store a pointer to their iterator tables in
it. A new function, _pixman_implementation_iter_init(), is then added
that searches those tables, and the new function is called in
pixman-general.c and pixman-image.c instead of the old
_pixman_implementation_src_init() and _pixman_implementation_dest_init().
---
pixman/pixman-fast-path.c | 1 +
pixman/pixman-general.c | 12 ++++----
pixman/pixman-image.c | 2 +-
pixman/pixman-implementation.c | 63 ++++++++++++++++++++++++++++++++++++++++++
pixman/pixman-mmx.c | 1 +
pixman/pixman-noop.c | 1 +
pixman/pixman-private.h | 13 +++++++++
pixman/pixman-sse2.c | 1 +
8 files changed, 88 insertions(+), 6 deletions(-)
diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 047675c..d5f707f 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -2336,6 +2336,7 @@ _pixman_implementation_create_fast_path (pixman_implementation_t *fallback)
imp->fill = fast_path_fill;
imp->src_iter_init = fast_src_iter_init;
imp->dest_iter_init = fast_dest_iter_init;
+ imp->iter_info = fast_iters;
return imp;
}
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 91e33c4..c469a81 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -196,9 +196,10 @@ general_composite_rect (pixman_implementation_t *imp,
/* src iter */
src_iter_flags = width_flag | op_flags[op].src | ITER_SRC;
- _pixman_implementation_src_iter_init (imp->toplevel, &src_iter, src_image,
- src_x, src_y, width, height,
- src_buffer, src_iter_flags, info->src_flags);
+ _pixman_implementation_iter_init (imp->toplevel, &src_iter, src_image,
+ src_x, src_y, width, height,
+ src_buffer, src_iter_flags,
+ info->src_flags);
/* mask iter */
if ((src_iter_flags & (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) ==
@@ -216,14 +217,14 @@ general_composite_rect (pixman_implementation_t *imp,
mask_image->common.component_alpha &&
PIXMAN_FORMAT_RGB (mask_image->bits.format);
- _pixman_implementation_src_iter_init (
+ _pixman_implementation_iter_init (
imp->toplevel, &mask_iter,
mask_image, mask_x, mask_y, width, height, mask_buffer,
ITER_SRC | width_flag | (component_alpha? 0 : ITER_IGNORE_RGB),
info->mask_flags);
/* dest iter */
- _pixman_implementation_dest_iter_init (
+ _pixman_implementation_iter_init (
imp->toplevel, &dest_iter, dest_image, dest_x, dest_y, width, height,
dest_buffer, ITER_DEST | width_flag | op_flags[op].dst, info->dest_flags);
@@ -263,6 +264,7 @@ _pixman_implementation_create_general (void)
imp->src_iter_init = general_src_iter_init;
imp->dest_iter_init = general_dest_iter_init;
+ imp->iter_info = general_iters;
return imp;
}
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 78c8610..4f9c2f9 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -920,7 +920,7 @@ _pixman_image_get_solid (pixman_implementation_t *imp,
pixman_iter_t iter;
otherwise:
- _pixman_implementation_src_iter_init (
+ _pixman_implementation_iter_init (
imp, &iter, image, 0, 0, 1, 1,
(uint8_t *)&result,
ITER_NARROW | ITER_SRC, image->common.flags);
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index cfb82bb..4bdc836 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -285,6 +285,69 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
return FALSE;
}
+static uint32_t *
+get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
+{
+ return NULL;
+}
+
+void
+_pixman_implementation_iter_init (pixman_implementation_t *imp,
+ pixman_iter_t *iter,
+ pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ int height,
+ uint8_t *buffer,
+ iter_flags_t iter_flags,
+ uint32_t image_flags)
+{
+ pixman_format_code_t format;
+
+ iter->image = image;
+ iter->buffer = (uint32_t *)buffer;
+ iter->x = x;
+ iter->y = y;
+ iter->width = width;
+ iter->height = height;
+ iter->iter_flags = iter_flags;
+ iter->image_flags = image_flags;
+
+ if (!iter->image)
+ {
+ iter->get_scanline = get_scanline_null;
+ return;
+ }
+
+ format = iter->image->common.extended_format_code;
+
+ while (imp)
+ {
+ if (imp->iter_info)
+ {
+ const pixman_iter_info_t *info;
+
+ for (info = imp->iter_info; info->format != PIXMAN_null; ++info)
+ {
+ if ((info->format == PIXMAN_any || info->format == format) &&
+ (info->image_flags & image_flags) == info->image_flags &&
+ (info->iter_flags & iter_flags) == info->iter_flags)
+ {
+ iter->get_scanline = info->get_scanline;
+ iter->write_back = info->write_back;
+
+ if (info->initializer)
+ info->initializer (iter, info);
+ return;
+ }
+ }
+ }
+
+ imp = imp->fallback;
+ }
+}
+
pixman_bool_t
_pixman_implementation_src_iter_init (pixman_implementation_t *imp,
pixman_iter_t *iter,
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index 02ec998..c3d81e0 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -4103,6 +4103,7 @@ _pixman_implementation_create_mmx (pixman_implementation_t *fallback)
imp->blt = mmx_blt;
imp->fill = mmx_fill;
+ imp->iter_info = mmx_iters;
imp->src_iter_init = mmx_src_iter_init;
return imp;
diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c
index d01665e..68b3bc6 100644
--- a/pixman/pixman-noop.c
+++ b/pixman/pixman-noop.c
@@ -205,6 +205,7 @@ _pixman_implementation_create_noop (pixman_implementation_t *fallback)
imp->src_iter_init = noop_src_iter_init;
imp->dest_iter_init = noop_dest_iter_init;
+ imp->iter_info = noop_iters;
return imp;
}
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 0365901..6859c4a 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -497,6 +497,7 @@ struct pixman_implementation_t
pixman_implementation_t * toplevel;
pixman_implementation_t * fallback;
const pixman_fast_path_t * fast_paths;
+ const pixman_iter_info_t * iter_info;
pixman_blt_func_t blt;
pixman_fill_func_t fill;
@@ -562,6 +563,18 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
int height,
uint32_t filler);
+void
+_pixman_implementation_iter_init (pixman_implementation_t *imp,
+ pixman_iter_t *iter,
+ pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ int height,
+ uint8_t *buffer,
+ iter_flags_t flags,
+ uint32_t image_flags);
+
pixman_bool_t
_pixman_implementation_src_iter_init (pixman_implementation_t *imp,
pixman_iter_t *iter,
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index 344cc46..1f357e1 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -6449,6 +6449,7 @@ _pixman_implementation_create_sse2 (pixman_implementation_t *fallback)
imp->blt = sse2_blt;
imp->fill = sse2_fill;
+ imp->iter_info = sse2_iters;
imp->src_iter_init = sse2_src_iter_init;
return imp;
--
1.7.11.7
More information about the Pixman
mailing list