diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-12-10 13:26:53 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-01-18 12:42:26 -0500 |
commit | 51a5e949f394560b057911d46aab768f8e07bd54 (patch) | |
tree | 4f05e654a39fed4f17c573126fdf0aa475599f1a | |
parent | 6503c6edccbc6b08ea8efe398da3265126efa896 (diff) |
Virtualize iterator initialization
Make src_iter_init() and dest_iter_init() virtual methods in the
implementation struct. This allows individual implementations to plug
in their own CPU specific scanline fetchers.
-rw-r--r-- | pixman/pixman-general.c | 52 | ||||
-rw-r--r-- | pixman/pixman-implementation.c | 76 | ||||
-rw-r--r-- | pixman/pixman-private.h | 35 |
3 files changed, 131 insertions, 32 deletions
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c index 4b837fac..e2f1dc3f 100644 --- a/pixman/pixman-general.c +++ b/pixman/pixman-general.c @@ -39,18 +39,12 @@ #include "pixman-combine32.h" #include "pixman-private.h" -static uint32_t * -src_get_scanline_null (pixman_iter_t *iter, const uint32_t *mask) -{ - return NULL; -} - static void -src_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) +general_src_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) { iter->image = image; iter->x = x; @@ -58,11 +52,7 @@ src_iter_init (pixman_implementation_t *imp, iter->width = width; iter->buffer = (uint32_t *)buffer; - if (!image) - { - iter->get_scanline = src_get_scanline_null; - } - else if (image->type == SOLID) + if (image->type == SOLID) { _pixman_solid_fill_iter_init ( image, iter, x, y, width, height, buffer, flags); @@ -94,11 +84,11 @@ src_iter_init (pixman_implementation_t *imp, } static void -dest_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) +general_dest_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) { iter->image = image; iter->x = x; @@ -169,17 +159,17 @@ general_composite_rect (pixman_implementation_t *imp, mask_buffer = src_buffer + width * Bpp; dest_buffer = mask_buffer + width * Bpp; - src_iter_init (imp->toplevel, &src_iter, src, - src_x, src_y, width, height, - src_buffer, narrow); + _pixman_implementation_src_iter_init (imp->toplevel, &src_iter, src, + src_x, src_y, width, height, + src_buffer, narrow); - src_iter_init (imp->toplevel, &mask_iter, mask, - mask_x, mask_y, width, height, - mask_buffer, narrow); + _pixman_implementation_src_iter_init (imp->toplevel, &mask_iter, mask, + mask_x, mask_y, width, height, + mask_buffer, narrow); - dest_iter_init (imp->toplevel, &dest_iter, dest, - dest_x, dest_y, width, height, - dest_buffer, narrow); + _pixman_implementation_dest_iter_init (imp->toplevel, &dest_iter, dest, + dest_x, dest_y, width, height, + dest_buffer, narrow); component_alpha = mask && @@ -272,6 +262,8 @@ _pixman_implementation_create_general (void) imp->blt = general_blt; imp->fill = general_fill; + imp->src_iter_init = general_src_iter_init; + imp->dest_iter_init = general_dest_iter_init; return imp; } diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c index bc3749ef..e6334326 100644 --- a/pixman/pixman-implementation.c +++ b/pixman/pixman-implementation.c @@ -111,6 +111,36 @@ delegate_fill (pixman_implementation_t *imp, imp->delegate, bits, stride, bpp, x, y, width, height, xor); } +static void +delegate_src_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) +{ + _pixman_implementation_src_iter_init ( + imp->delegate, iter, image, x, y, width, height, buffer, flags); +} + +static void +delegate_dest_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) +{ + _pixman_implementation_dest_iter_init ( + imp->delegate, iter, image, x, y, width, height, buffer, flags); +} + pixman_implementation_t * _pixman_implementation_create (pixman_implementation_t *delegate, const pixman_fast_path_t *fast_paths) @@ -133,6 +163,8 @@ _pixman_implementation_create (pixman_implementation_t *delegate, */ imp->blt = delegate_blt; imp->fill = delegate_fill; + imp->src_iter_init = delegate_src_iter_init; + imp->dest_iter_init = delegate_dest_iter_init; for (i = 0; i < PIXMAN_N_OPERATORS; ++i) { @@ -143,7 +175,7 @@ _pixman_implementation_create (pixman_implementation_t *delegate, } imp->fast_paths = fast_paths; - + return imp; } @@ -225,3 +257,45 @@ _pixman_implementation_fill (pixman_implementation_t *imp, return (*imp->fill) (imp, bits, stride, bpp, x, y, width, height, xor); } +static uint32_t * +get_scanline_null (pixman_iter_t *iter, const uint32_t *mask) +{ + return NULL; +} + +void +_pixman_implementation_src_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) +{ + if (!image) + { + iter->get_scanline = get_scanline_null; + } + else + { + (*imp->src_iter_init) ( + imp, iter, image, x, y, width, height, buffer, flags); + } +} + +void +_pixman_implementation_dest_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) +{ + (*imp->dest_iter_init) ( + imp, iter, image, x, y, width, height, buffer, flags); +} diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index d42c1146..158c41d7 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -431,6 +431,15 @@ 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, + pixman_image_t *image, + int x, + int y, + int width, + int height, + uint8_t *buffer, + iter_flags_t flags); void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp); void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp); @@ -452,9 +461,11 @@ struct pixman_implementation_t pixman_implementation_t * toplevel; pixman_implementation_t * delegate; const pixman_fast_path_t * fast_paths; - + pixman_blt_func_t blt; pixman_fill_func_t fill; + pixman_iter_init_func_t src_iter_init; + pixman_iter_init_func_t dest_iter_init; pixman_combine_32_func_t combine_32[PIXMAN_N_OPERATORS]; pixman_combine_32_func_t combine_32_ca[PIXMAN_N_OPERATORS]; @@ -521,6 +532,28 @@ _pixman_implementation_fill (pixman_implementation_t *imp, int height, uint32_t xor); +void +_pixman_implementation_src_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); + +void +_pixman_implementation_dest_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); + /* Specific implementations */ pixman_implementation_t * _pixman_implementation_create_general (void); |