From: Søren Sandmann Pedersen Date: Sun, 3 May 2009 02:46:20 +0000 (-0400) Subject: Set up scanline getters for bits images X-Git-Tag: 1.0_branch~1165 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7f113200e285c003b9225de83d8fe83492717ee;p=profile%2Fivi%2Fpixman.git Set up scanline getters for bits images --- diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index 9b0f224..1437406 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -24,10 +24,98 @@ #include #include "pixman-private.h" + +#define READ_ACCESS(f) ((image->common.read_func)? f##_accessors : f) + +static void +fbFetchSolid(bits_image_t * image, + int x, int y, int width, + uint32_t *buffer, + uint32_t *mask, uint32_t maskBits) +{ + uint32_t color; + uint32_t *end; + fetchPixelProc32 fetch = + READ_ACCESS(pixman_fetchPixelProcForPicture32)(image); + + color = fetch(image, 0, 0); + + end = buffer + width; + while (buffer < end) + *(buffer++) = color; +} + +static void +fbFetchSolid64(bits_image_t * image, + int x, int y, int width, + uint64_t *buffer, void *unused, uint32_t unused2) +{ + uint64_t color; + uint64_t *end; + fetchPixelProc64 fetch = + READ_ACCESS(pixman_fetchPixelProcForPicture64)(image); + + color = fetch(image, 0, 0); + + end = buffer + width; + while (buffer < end) + *(buffer++) = color; +} + +static void +fbFetch(bits_image_t * image, + int x, int y, int width, + uint32_t *buffer, uint32_t *mask, uint32_t maskBits) +{ + fetchProc32 fetch = READ_ACCESS(pixman_fetchProcForPicture32)(image); + + fetch(image, x, y, width, buffer); +} + +static void +fbFetch64(bits_image_t * image, + int x, int y, int width, + uint64_t *buffer, void *unused, uint32_t unused2) +{ + fetchProc64 fetch = READ_ACCESS(pixman_fetchProcForPicture64)(image); + + fetch(image, x, y, width, buffer); +} + static void bits_image_property_changed (pixman_image_t *image) { + bits_image_t *bits = (bits_image_t *)image; + if (bits->common.alpha_map) + { + image->common.get_scanline_64 = + (scanFetchProc)READ_ACCESS(fbFetchExternalAlpha64); + image->common.get_scanline_32 = + (scanFetchProc)READ_ACCESS(fbFetchExternalAlpha); + } + else if ((bits->common.repeat != PIXMAN_REPEAT_NONE) && + bits->width == 1 && + bits->height == 1) + { + image->common.get_scanline_64 = (scanFetchProc)fbFetchSolid64; + image->common.get_scanline_32 = (scanFetchProc)fbFetchSolid; + } + else if (!bits->common.transform && + bits->common.filter != PIXMAN_FILTER_CONVOLUTION && + bits->common.repeat != PIXMAN_REPEAT_PAD && + bits->common.repeat != PIXMAN_REPEAT_REFLECT) + { + image->common.get_scanline_64 = (scanFetchProc)fbFetch64; + image->common.get_scanline_32 = (scanFetchProc)fbFetch; + } + else + { + image->common.get_scanline_64 = + (scanFetchProc)READ_ACCESS(fbFetchTransformed64); + image->common.get_scanline_32 = + (scanFetchProc)READ_ACCESS(fbFetchTransformed); + } } static uint32_t * @@ -39,37 +127,37 @@ create_bits (pixman_format_code_t format, int stride; int buf_size; int bpp; - + /* what follows is a long-winded way, avoiding any possibility of integer * overflows, of saying: * stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t); */ - + bpp = PIXMAN_FORMAT_BPP (format); if (pixman_multiply_overflows_int (width, bpp)) return NULL; - + stride = width * bpp; if (pixman_addition_overflows_int (stride, FB_MASK)) return NULL; - + stride += FB_MASK; stride >>= FB_SHIFT; - + #if FB_SHIFT < 2 if (pixman_multiply_overflows_int (stride, sizeof (uint32_t))) return NULL; #endif stride *= sizeof (uint32_t); - + if (pixman_multiply_overflows_int (height, stride)) return NULL; - + buf_size = height * stride; - + if (rowstride_bytes) *rowstride_bytes = stride; - + return calloc (buf_size, 1); } @@ -82,21 +170,21 @@ pixman_image_create_bits (pixman_format_code_t format, { pixman_image_t *image; uint32_t *free_me = NULL; - + /* must be a whole number of uint32_t's */ return_val_if_fail (bits == NULL || (rowstride_bytes % sizeof (uint32_t)) == 0, NULL); - + if (!bits && width && height) { free_me = bits = create_bits (format, width, height, &rowstride_bytes); if (!bits) return NULL; } - + image = _pixman_image_allocate(); - + if (!image) { if (free_me) free (free_me); @@ -109,21 +197,21 @@ pixman_image_create_bits (pixman_format_code_t format, image->bits.height = height; image->bits.bits = bits; image->bits.free_me = free_me; - + image->bits.rowstride = rowstride_bytes / (int) sizeof (uint32_t); /* we store it in number - * of uint32_t's - */ + * of uint32_t's + */ image->bits.indexed = NULL; - + pixman_region32_fini (&image->common.full_region); pixman_region32_init_rect (&image->common.full_region, 0, 0, image->bits.width, image->bits.height); - + image->common.property_changed = bits_image_property_changed; bits_image_property_changed (image); _pixman_image_reset_clip_region (image); - + return image; } diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 859cb0d..dd21718 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -98,91 +98,10 @@ _pixman_image_classify (pixman_image_t *image, return SOURCE_IMAGE_CLASS_UNKNOWN; } -#define READ_ACCESS(f) ((image->common.read_func)? f##_accessors : f) - -static void fbFetchSolid(bits_image_t * image, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits) -{ - uint32_t color; - uint32_t *end; - fetchPixelProc32 fetch = READ_ACCESS(pixman_fetchPixelProcForPicture32)(image); - - color = fetch(image, 0, 0); - - end = buffer + width; - while (buffer < end) - *(buffer++) = color; -} - -static void fbFetchSolid64(bits_image_t * image, int x, int y, int width, uint64_t *buffer, void *unused, uint32_t unused2) -{ - uint64_t color; - uint64_t *end; - fetchPixelProc64 fetch = READ_ACCESS(pixman_fetchPixelProcForPicture64)(image); - - color = fetch(image, 0, 0); - - end = buffer + width; - while (buffer < end) - *(buffer++) = color; -} - -static void fbFetch(bits_image_t * image, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits) -{ - fetchProc32 fetch = READ_ACCESS(pixman_fetchProcForPicture32)(image); - - fetch(image, x, y, width, buffer); -} - -static void fbFetch64(bits_image_t * image, int x, int y, int width, uint64_t *buffer, void *unused, uint32_t unused2) -{ - fetchProc64 fetch = READ_ACCESS(pixman_fetchProcForPicture64)(image); - - fetch(image, x, y, width, buffer); -} - -static void -set_fetchers (pixman_image_t *image) -{ - if (!IS_SOURCE_IMAGE (image)) - { - bits_image_t *bits = (bits_image_t *)image; - - if (bits->common.alpha_map) - { - image->common.get_scanline_64 = - (scanFetchProc)READ_ACCESS(fbFetchExternalAlpha64); - image->common.get_scanline_32 = - (scanFetchProc)READ_ACCESS(fbFetchExternalAlpha); - } - else if ((bits->common.repeat != PIXMAN_REPEAT_NONE) && - bits->width == 1 && - bits->height == 1) - { - image->common.get_scanline_64 = (scanFetchProc)fbFetchSolid64; - image->common.get_scanline_32 = (scanFetchProc)fbFetchSolid; - } - else if (!bits->common.transform && - bits->common.filter != PIXMAN_FILTER_CONVOLUTION && - bits->common.repeat != PIXMAN_REPEAT_PAD && - bits->common.repeat != PIXMAN_REPEAT_REFLECT) - { - image->common.get_scanline_64 = (scanFetchProc)fbFetch64; - image->common.get_scanline_32 = (scanFetchProc)fbFetch; - } - else - { - image->common.get_scanline_64 = (scanFetchProc)READ_ACCESS(fbFetchTransformed64); - image->common.get_scanline_32 = (scanFetchProc)READ_ACCESS(fbFetchTransformed); - } - } -} - scanFetchProc _pixman_image_get_fetcher (pixman_image_t *image, int wide) { - set_fetchers (image); - assert (image->common.get_scanline_64); assert (image->common.get_scanline_32);