diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-08-01 13:38:45 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-10-31 03:24:08 -0400 |
commit | dcd861ac23e0d91afee649ceb04af876397bc396 (patch) | |
tree | 7a3fb194fbabbf51ae12ee4a1c6cc67c0cd80a8c | |
parent | a48197432e5a7c9452ca8b5a46c4c2e6a1deb2f5 (diff) |
Move all the pixel accessors to their own struct
A pointer to this struct is stored in the bits image instead of six
separate functions pointers. The struct pointer is maintained by the
general implementation in the validate_image() method.
-rw-r--r-- | pixman/pixman-access.c | 84 | ||||
-rw-r--r-- | pixman/pixman-general-bits.c | 38 | ||||
-rw-r--r-- | pixman/pixman-private.h | 23 |
3 files changed, 84 insertions, 61 deletions
diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c index f1ce0ba4..0abf8cbf 100644 --- a/pixman/pixman-access.c +++ b/pixman/pixman-access.c @@ -2732,7 +2732,7 @@ store_scanline_generic_64 (bits_image_t * image, */ pixman_contract (argb8_pixels, (uint64_t *)values, width); - image->store_scanline_32 (image, x, y, width, argb8_pixels); + image->general_accessors->store_scanline_32 (image, x, y, width, argb8_pixels); free (argb8_pixels); } @@ -2753,7 +2753,7 @@ fetch_scanline_generic_64 (pixman_image_t *image, /* Fetch the pixels into the first half of buffer and then expand them in * place. */ - image->bits.fetch_scanline_32 (image, x, y, width, buffer, NULL); + image->bits.general_accessors->fetch_scanline_32 (image, x, y, width, buffer, NULL); format = image->bits.format; if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR || @@ -2776,7 +2776,7 @@ fetch_pixel_generic_64 (bits_image_t *image, int offset, int line) { - uint32_t pixel32 = image->fetch_pixel_32 (image, offset, line); + uint32_t pixel32 = image->general_accessors->fetch_pixel_32 (image, offset, line); uint64_t result; pixman_format_code_t format; @@ -2808,7 +2808,7 @@ fetch_pixel_generic_lossy_32 (bits_image_t *image, int offset, int line) { - uint64_t pixel64 = image->fetch_pixel_64 (image, offset, line); + uint64_t pixel64 = image->general_accessors->fetch_pixel_64 (image, offset, line); uint32_t result; pixman_contract (&result, &pixel64, 1); @@ -2819,21 +2819,19 @@ fetch_pixel_generic_lossy_32 (bits_image_t *image, typedef struct { pixman_format_code_t format; - fetch_scanline_t fetch_scanline_32; - fetch_scanline_t fetch_scanline_64; - fetch_pixel_32_t fetch_pixel_32; - fetch_pixel_64_t fetch_pixel_64; - store_scanline_t store_scanline_32; - store_scanline_t store_scanline_64; + + general_accessors_t general_accessors; } format_info_t; #define FORMAT_INFO(format) \ { \ PIXMAN_ ## format, \ + { \ fetch_scanline_ ## format, \ - fetch_scanline_generic_64, \ - fetch_pixel_ ## format, fetch_pixel_generic_64, \ - store_scanline_ ## format, store_scanline_generic_64 \ + fetch_scanline_generic_64, \ + fetch_pixel_ ## format, fetch_pixel_generic_64, \ + store_scanline_ ## format, store_scanline_generic_64 \ + } \ } static const format_info_t accessors[] = @@ -2909,35 +2907,47 @@ static const format_info_t accessors[] = /* Wide formats */ { PIXMAN_a2r10g10b10, - NULL, fetch_scanline_a2r10g10b10, - fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10, - NULL, store_scanline_a2r10g10b10 }, + { NULL, fetch_scanline_a2r10g10b10, + fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10, + NULL, store_scanline_a2r10g10b10 + } + }, { PIXMAN_x2r10g10b10, - NULL, fetch_scanline_x2r10g10b10, - fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10, - NULL, store_scanline_x2r10g10b10 }, + { NULL, fetch_scanline_x2r10g10b10, + fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10, + NULL, store_scanline_x2r10g10b10 + }, + }, { PIXMAN_a2b10g10r10, - NULL, fetch_scanline_a2b10g10r10, - fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10, - NULL, store_scanline_a2b10g10r10 }, + { NULL, fetch_scanline_a2b10g10r10, + fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10, + NULL, store_scanline_a2b10g10r10 + }, + }, { PIXMAN_x2b10g10r10, - NULL, fetch_scanline_x2b10g10r10, - fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10, - NULL, store_scanline_x2b10g10r10 }, + { NULL, fetch_scanline_x2b10g10r10, + fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10, + NULL, store_scanline_x2b10g10r10 + }, + }, /* YUV formats */ { PIXMAN_yuy2, - fetch_scanline_yuy2, fetch_scanline_generic_64, - fetch_pixel_yuy2, fetch_pixel_generic_64, - NULL, NULL }, + { fetch_scanline_yuy2, fetch_scanline_generic_64, + fetch_pixel_yuy2, fetch_pixel_generic_64, + NULL, NULL + }, + }, { PIXMAN_yv12, - fetch_scanline_yv12, fetch_scanline_generic_64, - fetch_pixel_yv12, fetch_pixel_generic_64, - NULL, NULL }, + { fetch_scanline_yv12, fetch_scanline_generic_64, + fetch_pixel_yv12, fetch_pixel_generic_64, + NULL, NULL + }, + }, { PIXMAN_null }, }; @@ -2946,21 +2956,15 @@ static void setup_accessors (bits_image_t *image) { const format_info_t *info = accessors; - + while (info->format != PIXMAN_null) { if (info->format == image->format) { - image->fetch_scanline_32 = info->fetch_scanline_32; - image->fetch_scanline_64 = info->fetch_scanline_64; - image->fetch_pixel_32 = info->fetch_pixel_32; - image->fetch_pixel_64 = info->fetch_pixel_64; - image->store_scanline_32 = info->store_scanline_32; - image->store_scanline_64 = info->store_scanline_64; - + image->general_accessors = &(info->general_accessors); return; } - + info++; } } diff --git a/pixman/pixman-general-bits.c b/pixman/pixman-general-bits.c index 8333d961..5696bea7 100644 --- a/pixman/pixman-general-bits.c +++ b/pixman/pixman-general-bits.c @@ -43,14 +43,14 @@ _pixman_image_store_scanline_32 (bits_image_t * image, int width, const uint32_t *buffer) { - image->store_scanline_32 (image, x, y, width, buffer); + image->general_accessors->store_scanline_32 (image, x, y, width, buffer); if (image->common.alpha_map) { x -= image->common.alpha_origin_x; y -= image->common.alpha_origin_y; - image->common.alpha_map->store_scanline_32 ( + image->common.alpha_map->general_accessors->store_scanline_32 ( image->common.alpha_map, x, y, width, buffer); } } @@ -62,14 +62,14 @@ _pixman_image_store_scanline_64 (bits_image_t * image, int width, const uint32_t *buffer) { - image->store_scanline_64 (image, x, y, width, buffer); + image->general_accessors->store_scanline_64 (image, x, y, width, buffer); if (image->common.alpha_map) { x -= image->common.alpha_origin_x; y -= image->common.alpha_origin_y; - image->common.alpha_map->store_scanline_64 ( + image->common.alpha_map->general_accessors->store_scanline_64 ( image->common.alpha_map, x, y, width, buffer); } } @@ -86,7 +86,7 @@ fetch_pixel_no_alpha (bits_image_t *image, return 0; } - return image->fetch_pixel_32 (image, x, y); + return image->general_accessors->fetch_pixel_32 (image, x, y); } typedef uint32_t (* get_pixel_t) (bits_image_t *image, @@ -655,7 +655,7 @@ fetch_pixel_general (bits_image_t *image, int x, int y, pixman_bool_t check_boun return 0; } - pixel = image->fetch_pixel_32 (image, x, y); + pixel = image->general_accessors->fetch_pixel_32 (image, x, y); if (image->common.alpha_map) { @@ -671,7 +671,7 @@ fetch_pixel_general (bits_image_t *image, int x, int y, pixman_bool_t check_boun } else { - pixel_a = image->common.alpha_map->fetch_pixel_32 ( + pixel_a = image->common.alpha_map->general_accessors->fetch_pixel_32 ( image->common.alpha_map, x, y); pixel_a = ALPHA_8 (pixel_a); @@ -975,7 +975,7 @@ bits_image_fetch_solid_32 (pixman_image_t * image, uint32_t color; uint32_t *end; - color = image->bits.fetch_pixel_32 (&image->bits, 0, 0); + color = image->bits.general_accessors->fetch_pixel_32 (&image->bits, 0, 0); end = buffer + width; while (buffer < end) @@ -994,7 +994,7 @@ bits_image_fetch_solid_64 (pixman_image_t * image, uint64_t *buffer = (uint64_t *)b; uint64_t *end; - color = image->bits.fetch_pixel_64 (&image->bits, 0, 0); + color = image->bits.general_accessors->fetch_pixel_64 (&image->bits, 0, 0); end = buffer + width; while (buffer < end) @@ -1033,9 +1033,15 @@ bits_image_fetch_untransformed_repeat_none (bits_image_t *image, w = MIN (width, image->width - x); if (wide) - image->fetch_scanline_64 ((pixman_image_t *)image, x, y, w, buffer, NULL); + { + image->general_accessors->fetch_scanline_64 ( + (pixman_image_t *)image, x, y, w, buffer, NULL); + } else - image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL); + { + image->general_accessors->fetch_scanline_32 ( + (pixman_image_t *)image, x, y, w, buffer, NULL); + } width -= w; buffer += w * (wide? 2 : 1); @@ -1071,9 +1077,15 @@ bits_image_fetch_untransformed_repeat_normal (bits_image_t *image, w = MIN (width, image->width - x); if (wide) - image->fetch_scanline_64 ((pixman_image_t *)image, x, y, w, buffer, NULL); + { + image->general_accessors->fetch_scanline_64 ( + (pixman_image_t *)image, x, y, w, buffer, NULL); + } else - image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL); + { + image->general_accessors->fetch_scanline_32 ( + (pixman_image_t *)image, x, y, w, buffer, NULL); + } buffer += w * (wide? 2 : 1); x += w; diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 3950ea43..bda4dd8d 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -158,6 +158,8 @@ struct conical_gradient double angle; }; +typedef struct general_accessors_t general_accessors_t; + struct bits_image { image_common_t common; @@ -169,17 +171,12 @@ struct bits_image uint32_t * free_me; int rowstride; /* in number of uint32_t's */ - fetch_scanline_t fetch_scanline_32; - fetch_pixel_32_t fetch_pixel_32; - store_scanline_t store_scanline_32; - - fetch_scanline_t fetch_scanline_64; - fetch_pixel_64_t fetch_pixel_64; - store_scanline_t store_scanline_64; - /* Used for indirect access to the bits */ pixman_read_memory_func_t read_func; pixman_write_memory_func_t write_func; + + /* This pointer is maintained by the general implementation */ + const general_accessors_t *general_accessors; }; union pixman_image @@ -495,6 +492,16 @@ _pixman_implementation_fill (pixman_implementation_t *imp, uint32_t xor); /* Specific implementations */ +struct general_accessors_t +{ + fetch_scanline_t fetch_scanline_32; + fetch_scanline_t fetch_scanline_64; + fetch_pixel_32_t fetch_pixel_32; + fetch_pixel_64_t fetch_pixel_64; + store_scanline_t store_scanline_32; + store_scanline_t store_scanline_64; +}; + pixman_implementation_t * _pixman_implementation_create_general (void); |