From: Søren Sandmann Date: Mon, 9 Jun 2008 02:20:44 +0000 (-0400) Subject: Use 32 bit regions internally X-Git-Tag: pixman-0.11.2~1^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=703f82cd02f5224632b4b7f7f3f072067fa4f76d;p=platform%2Fupstream%2Fpixman.git Use 32 bit regions internally --- diff --git a/pixman/pixman-compute-region.c b/pixman/pixman-compute-region.c index 6743304..859f02e 100644 --- a/pixman/pixman-compute-region.c +++ b/pixman/pixman-compute-region.c @@ -32,16 +32,16 @@ #define BOUND(v) (int16_t) ((v) < INT16_MIN ? INT16_MIN : (v) > INT16_MAX ? INT16_MAX : (v)) static inline pixman_bool_t -miClipPictureReg (pixman_region16_t * pRegion, - pixman_region16_t * pClip, +miClipPictureReg (pixman_region32_t * pRegion, + pixman_region32_t * pClip, int dx, int dy) { - if (pixman_region_n_rects(pRegion) == 1 && - pixman_region_n_rects(pClip) == 1) + if (pixman_region32_n_rects(pRegion) == 1 && + pixman_region32_n_rects(pClip) == 1) { - pixman_box16_t * pRbox = pixman_region_rectangles(pRegion, NULL); - pixman_box16_t * pCbox = pixman_region_rectangles(pClip, NULL); + pixman_box32_t * pRbox = pixman_region32_rectangles(pRegion, NULL); + pixman_box32_t * pCbox = pixman_region32_rectangles(pClip, NULL); int v; if (pRbox->x1 < (v = pCbox->x1 + dx)) @@ -55,26 +55,26 @@ miClipPictureReg (pixman_region16_t * pRegion, if (pRbox->x1 >= pRbox->x2 || pRbox->y1 >= pRbox->y2) { - pixman_region_init (pRegion); + pixman_region32_init (pRegion); } } - else if (!pixman_region_not_empty (pClip)) + else if (!pixman_region32_not_empty (pClip)) return FALSE; else { if (dx || dy) - pixman_region_translate (pRegion, -dx, -dy); - if (!pixman_region_intersect (pRegion, pRegion, pClip)) + pixman_region32_translate (pRegion, -dx, -dy); + if (!pixman_region32_intersect (pRegion, pRegion, pClip)) return FALSE; if (dx || dy) - pixman_region_translate(pRegion, dx, dy); + pixman_region32_translate(pRegion, dx, dy); } - return pixman_region_not_empty(pRegion); + return pixman_region32_not_empty(pRegion); } static inline pixman_bool_t -miClipPictureSrc (pixman_region16_t * pRegion, +miClipPictureSrc (pixman_region32_t * pRegion, pixman_image_t * pPicture, int dx, int dy) @@ -98,13 +98,13 @@ miClipPictureSrc (pixman_region16_t * pRegion, */ if (pPicture->common.has_client_clip) { - pixman_region_translate ( pRegion, dx, dy); + pixman_region32_translate ( pRegion, dx, dy); - if (!pixman_region_intersect (pRegion, pRegion, - (pixman_region16_t *) pPicture->common.src_clip)) + if (!pixman_region32_intersect (pRegion, pRegion, + pPicture->common.src_clip)) return FALSE; - pixman_region_translate ( pRegion, -dx, -dy); + pixman_region32_translate ( pRegion, -dx, -dy); } return TRUE; @@ -123,19 +123,19 @@ miClipPictureSrc (pixman_region16_t * pRegion, * an allocation failure, but rendering ignores those anyways. */ -PIXMAN_EXPORT pixman_bool_t -pixman_compute_composite_region (pixman_region16_t * pRegion, - pixman_image_t * pSrc, - pixman_image_t * pMask, - pixman_image_t * pDst, - int16_t xSrc, - int16_t ySrc, - int16_t xMask, - int16_t yMask, - int16_t xDst, - int16_t yDst, - uint16_t width, - uint16_t height) +static pixman_bool_t +pixman_compute_composite_region32 (pixman_region32_t * pRegion, + pixman_image_t * pSrc, + pixman_image_t * pMask, + pixman_image_t * pDst, + int16_t xSrc, + int16_t ySrc, + int16_t xMask, + int16_t yMask, + int16_t xDst, + int16_t yDst, + uint16_t width, + uint16_t height) { int v; @@ -150,13 +150,13 @@ pixman_compute_composite_region (pixman_region16_t * pRegion, if (pRegion->extents.x1 >= pRegion->extents.x2 || pRegion->extents.y1 >= pRegion->extents.y2) { - pixman_region_init (pRegion); + pixman_region32_init (pRegion); return FALSE; } /* clip against dst */ if (!miClipPictureReg (pRegion, &pDst->common.clip_region, 0, 0)) { - pixman_region_fini (pRegion); + pixman_region32_fini (pRegion); return FALSE; } if (pDst->common.alpha_map) @@ -165,14 +165,14 @@ pixman_compute_composite_region (pixman_region16_t * pRegion, -pDst->common.alpha_origin.x, -pDst->common.alpha_origin.y)) { - pixman_region_fini (pRegion); + pixman_region32_fini (pRegion); return FALSE; } } /* clip against src */ if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc)) { - pixman_region_fini (pRegion); + pixman_region32_fini (pRegion); return FALSE; } if (pSrc->common.alpha_map) @@ -181,7 +181,7 @@ pixman_compute_composite_region (pixman_region16_t * pRegion, xDst - (xSrc + pSrc->common.alpha_origin.x), yDst - (ySrc + pSrc->common.alpha_origin.y))) { - pixman_region_fini (pRegion); + pixman_region32_fini (pRegion); return FALSE; } } @@ -190,7 +190,7 @@ pixman_compute_composite_region (pixman_region16_t * pRegion, { if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask)) { - pixman_region_fini (pRegion); + pixman_region32_fini (pRegion); return FALSE; } if (pMask->common.alpha_map) @@ -199,7 +199,7 @@ pixman_compute_composite_region (pixman_region16_t * pRegion, xDst - (xMask + pMask->common.alpha_origin.x), yDst - (yMask + pMask->common.alpha_origin.y))) { - pixman_region_fini (pRegion); + pixman_region32_fini (pRegion); return FALSE; } } @@ -207,3 +207,33 @@ pixman_compute_composite_region (pixman_region16_t * pRegion, return TRUE; } + +PIXMAN_EXPORT pixman_bool_t +pixman_compute_composite_region (pixman_region16_t * pRegion, + pixman_image_t * pSrc, + pixman_image_t * pMask, + pixman_image_t * pDst, + int16_t xSrc, + int16_t ySrc, + int16_t xMask, + int16_t yMask, + int16_t xDst, + int16_t yDst, + uint16_t width, + uint16_t height) +{ + pixman_region32_t r32; + pixman_bool_t retval; + + pixman_region32_init (&r32); + + if (!pixman_region32_copy_from_region16 (&r32, pRegion)) + return FALSE; + + retval = pixman_compute_composite_region32 (&r32, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); + + pixman_region32_fini (&r32); + return retval; +} diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 6616aa9..61b3fc0 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -81,8 +81,8 @@ allocate_image (void) { image_common_t *common = &image->common; - pixman_region_init (&common->full_region); - pixman_region_init (&common->clip_region); + pixman_region32_init (&common->full_region); + pixman_region32_init (&common->clip_region); common->src_clip = &common->full_region; common->has_client_clip = FALSE; common->transform = NULL; @@ -119,8 +119,8 @@ pixman_image_unref (pixman_image_t *image) if (common->ref_count == 0) { - pixman_region_fini (&common->clip_region); - pixman_region_fini (&common->full_region); + pixman_region32_fini (&common->clip_region); + pixman_region32_fini (&common->full_region); if (common->transform) free (common->transform); @@ -323,16 +323,16 @@ create_bits (pixman_format_code_t format, static void reset_clip_region (pixman_image_t *image) { - pixman_region_fini (&image->common.clip_region); + pixman_region32_fini (&image->common.clip_region); if (image->type == BITS) { - pixman_region_init_rect (&image->common.clip_region, 0, 0, - image->bits.width, image->bits.height); + pixman_region32_init_rect (&image->common.clip_region, 0, 0, + image->bits.width, image->bits.height); } else { - pixman_region_init (&image->common.clip_region); + pixman_region32_init (&image->common.clip_region); } } @@ -378,9 +378,9 @@ pixman_image_create_bits (pixman_format_code_t format, */ image->bits.indexed = NULL; - pixman_region_fini (&image->common.full_region); - pixman_region_init_rect (&image->common.full_region, 0, 0, - image->bits.width, image->bits.height); + pixman_region32_fini (&image->common.full_region); + pixman_region32_init_rect (&image->common.full_region, 0, 0, + image->bits.width, image->bits.height); reset_clip_region (image); return image; @@ -394,7 +394,7 @@ pixman_image_set_clip_region (pixman_image_t *image, if (region) { - return pixman_region_copy (&common->clip_region, region); + return pixman_region32_copy_from_region16 (&common->clip_region, region); } else { @@ -679,23 +679,23 @@ pixman_image_fill_rectangles (pixman_op_t op, { for (i = 0; i < n_rects; ++i) { - pixman_region16_t fill_region; + pixman_region32_t fill_region; int n_boxes, j; - pixman_box16_t *boxes; + pixman_box32_t *boxes; - pixman_region_init_rect (&fill_region, rects[i].x, rects[i].y, rects[i].width, rects[i].height); - pixman_region_intersect (&fill_region, &fill_region, &dest->common.clip_region); + pixman_region32_init_rect (&fill_region, rects[i].x, rects[i].y, rects[i].width, rects[i].height); + pixman_region32_intersect (&fill_region, &fill_region, &dest->common.clip_region); - boxes = pixman_region_rectangles (&fill_region, &n_boxes); + boxes = pixman_region32_rectangles (&fill_region, &n_boxes); for (j = 0; j < n_boxes; ++j) { - const pixman_box16_t *box = &(boxes[j]); + const pixman_box32_t *box = &(boxes[j]); pixman_fill (dest->bits.bits, dest->bits.rowstride, PIXMAN_FORMAT_BPP (dest->bits.format), box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1, pixel); } - pixman_region_fini (&fill_region); + pixman_region32_fini (&fill_region); } return TRUE; } diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 82a0d3c..7f46ccd 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -262,9 +262,9 @@ struct image_common { image_type_t type; int32_t ref_count; - pixman_region16_t full_region; - pixman_region16_t clip_region; - pixman_region16_t *src_clip; + pixman_region32_t full_region; + pixman_region32_t clip_region; + pixman_region32_t *src_clip; pixman_bool_t has_client_clip; pixman_transform_t *transform; pixman_repeat_t repeat; diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c index 2ba5a70..c37ec52 100644 --- a/pixman/pixman-region.c +++ b/pixman/pixman-region.c @@ -305,7 +305,7 @@ PREFIX(_init) (region_type_t *region) PIXMAN_EXPORT void PREFIX(_init_rect) (region_type_t *region, - int x, int y, unsigned int width, unsigned int height) + int x, int y, unsigned int width, unsigned int height) { region->extents.x1 = x; region->extents.y1 = y; @@ -335,12 +335,6 @@ PREFIX(_n_rects) (region_type_t *region) } PIXMAN_EXPORT box_type_t * -PREFIX(_rects) (region_type_t *region) -{ - return PIXREGION_RECTS (region); -} - -PIXMAN_EXPORT box_type_t * PREFIX(_rectangles) (region_type_t *region, int *n_rects) { @@ -2205,7 +2199,7 @@ PREFIX(_selfcheck) (reg) PIXMAN_EXPORT pixman_bool_t PREFIX(_init_rects) (region_type_t *region, - box_type_t *boxes, int count) + box_type_t *boxes, int count) { int overlap; diff --git a/pixman/pixman-transformed.c b/pixman/pixman-transformed.c index 569fcae..cff1ba2 100644 --- a/pixman/pixman-transformed.c +++ b/pixman/pixman-transformed.c @@ -39,28 +39,28 @@ /* * Fetch from region strategies */ -typedef FASTCALL uint32_t (*fetchFromRegionProc)(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box16_t *box); +typedef FASTCALL uint32_t (*fetchFromRegionProc)(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box32_t *box); static inline uint32_t -fbFetchFromNoRegion(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box16_t *box) +fbFetchFromNoRegion(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box32_t *box) { return fetch (pict, x, y); } static uint32_t -fbFetchFromNRectangles(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box16_t *box) +fbFetchFromNRectangles(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box32_t *box) { - pixman_box16_t box2; - if (pixman_region_contains_point (pict->common.src_clip, x, y, &box2)) + pixman_box32_t box2; + if (pixman_region32_contains_point (pict->common.src_clip, x, y, &box2)) return fbFetchFromNoRegion(pict, x, y, buffer, fetch, box); else return 0; } static uint32_t -fbFetchFromOneRectangle(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box16_t *box) +fbFetchFromOneRectangle(bits_image_t *pict, int x, int y, uint32_t *buffer, fetchPixelProc32 fetch, pixman_box32_t *box) { - pixman_box16_t box2 = *box; + pixman_box32_t box2 = *box; return ((x < box2.x1) | (x >= box2.x2) | (y < box2.y1) | (y >= box2.y2)) ? 0 : fbFetchFromNoRegion(pict, x, y, buffer, fetch, box); } @@ -71,7 +71,7 @@ fbFetchFromOneRectangle(bits_image_t *pict, int x, int y, uint32_t *buffer, fetc static void fbFetchTransformed_Nearest_Normal(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t* box = NULL; + pixman_box32_t* box = NULL; fetchPixelProc32 fetch; fetchFromRegionProc fetchFromRegion; int x, y, i; @@ -79,7 +79,7 @@ fbFetchTransformed_Nearest_Normal(bits_image_t * pict, int width, uint32_t *buff /* initialize the two function pointers */ fetch = ACCESS(pixman_fetchPixelProcForPicture32)(pict); - if(pixman_region_n_rects (pict->common.src_clip) == 1) + if(pixman_region32_n_rects (pict->common.src_clip) == 1) fetchFromRegion = fbFetchFromNoRegion; else fetchFromRegion = fbFetchFromNRectangles; @@ -117,7 +117,7 @@ fbFetchTransformed_Nearest_Normal(bits_image_t * pict, int width, uint32_t *buff static void fbFetchTransformed_Nearest_Pad(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t *box = NULL; + pixman_box32_t *box = NULL; fetchPixelProc32 fetch; fetchFromRegionProc fetchFromRegion; int x, y, i; @@ -125,7 +125,7 @@ fbFetchTransformed_Nearest_Pad(bits_image_t * pict, int width, uint32_t *buffer, /* initialize the two function pointers */ fetch = ACCESS(pixman_fetchPixelProcForPicture32)(pict); - if(pixman_region_n_rects (pict->common.src_clip) == 1) + if(pixman_region32_n_rects (pict->common.src_clip) == 1) fetchFromRegion = fbFetchFromNoRegion; else fetchFromRegion = fbFetchFromNRectangles; @@ -164,7 +164,7 @@ fbFetchTransformed_Nearest_Pad(bits_image_t * pict, int width, uint32_t *buffer, static void fbFetchTransformed_Nearest_General(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t *box = NULL; + pixman_box32_t *box = NULL; fetchPixelProc32 fetch; fetchFromRegionProc fetchFromRegion; int x, y, i; @@ -172,7 +172,7 @@ fbFetchTransformed_Nearest_General(bits_image_t * pict, int width, uint32_t *buf /* initialize the two function pointers */ fetch = ACCESS(pixman_fetchPixelProcForPicture32)(pict); - if(pixman_region_n_rects (pict->common.src_clip) == 1) + if(pixman_region32_n_rects (pict->common.src_clip) == 1) { box = &(pict->common.src_clip->extents); fetchFromRegion = fbFetchFromOneRectangle; @@ -207,7 +207,7 @@ fbFetchTransformed_Nearest_General(bits_image_t * pict, int width, uint32_t *buf static void fbFetchTransformed_Bilinear_Normal(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t *box = NULL; + pixman_box32_t *box = NULL; fetchPixelProc32 fetch; fetchFromRegionProc fetchFromRegion; int i; @@ -215,7 +215,7 @@ fbFetchTransformed_Bilinear_Normal(bits_image_t * pict, int width, uint32_t *buf /* initialize the two function pointers */ fetch = ACCESS(pixman_fetchPixelProcForPicture32)(pict); - if(pixman_region_n_rects (pict->common.src_clip) == 1) + if(pixman_region32_n_rects (pict->common.src_clip) == 1) fetchFromRegion = fbFetchFromNoRegion; else fetchFromRegion = fbFetchFromNRectangles; @@ -284,7 +284,7 @@ fbFetchTransformed_Bilinear_Normal(bits_image_t * pict, int width, uint32_t *buf static void fbFetchTransformed_Bilinear_Pad(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t *box = NULL; + pixman_box32_t *box = NULL; fetchPixelProc32 fetch; fetchFromRegionProc fetchFromRegion; int i; @@ -292,7 +292,7 @@ fbFetchTransformed_Bilinear_Pad(bits_image_t * pict, int width, uint32_t *buffer /* initialize the two function pointers */ fetch = ACCESS(pixman_fetchPixelProcForPicture32)(pict); - if(pixman_region_n_rects (pict->common.src_clip) == 1) + if(pixman_region32_n_rects (pict->common.src_clip) == 1) fetchFromRegion = fbFetchFromNoRegion; else fetchFromRegion = fbFetchFromNRectangles; @@ -361,7 +361,7 @@ fbFetchTransformed_Bilinear_Pad(bits_image_t * pict, int width, uint32_t *buffer static void fbFetchTransformed_Bilinear_General(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t *box = NULL; + pixman_box32_t *box = NULL; fetchPixelProc32 fetch; fetchFromRegionProc fetchFromRegion; int i; @@ -369,7 +369,7 @@ fbFetchTransformed_Bilinear_General(bits_image_t * pict, int width, uint32_t *bu /* initialize the two function pointers */ fetch = ACCESS(pixman_fetchPixelProcForPicture32)(pict); - if(pixman_region_n_rects (pict->common.src_clip) == 1) + if(pixman_region32_n_rects (pict->common.src_clip) == 1) { box = &(pict->common.src_clip->extents); fetchFromRegion = fbFetchFromOneRectangle; @@ -440,7 +440,7 @@ fbFetchTransformed_Bilinear_General(bits_image_t * pict, int width, uint32_t *bu static void fbFetchTransformed_Convolution(bits_image_t * pict, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits, pixman_bool_t affine, pixman_vector_t v, pixman_vector_t unit) { - pixman_box16_t dummy; + pixman_box32_t dummy; fetchPixelProc32 fetch; int i; @@ -502,7 +502,7 @@ fbFetchTransformed_Convolution(bits_image_t * pict, int width, uint32_t *buffer, default: tx = x; } - if (pixman_region_contains_point (pict->common.src_clip, tx, ty, &dummy)) { + if (pixman_region32_contains_point (pict->common.src_clip, tx, ty, &dummy)) { uint32_t c = fetch(pict, tx, ty); srtot += Red(c) * *p; diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c index a165467..28dacaf 100644 --- a/pixman/pixman-trap.c +++ b/pixman/pixman-trap.c @@ -116,11 +116,11 @@ dump_image (pixman_image_t *image, } PIXMAN_EXPORT void -pixman_add_trapezoids (pixman_image_t *image, - int16_t x_off, - int y_off, - int ntraps, - const pixman_trapezoid_t *traps) +pixman_add_trapezoids (pixman_image_t *image, + int16_t x_off, + int y_off, + int ntraps, + const pixman_trapezoid_t *traps) { int i; diff --git a/pixman/pixman.h b/pixman/pixman.h index bfe702b..cf9d771 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -278,6 +278,9 @@ void pixman_region_init_rect (pixman_region16_t int y, unsigned int width, unsigned int height); +pixman_bool_t pixman_region_init_rects (pixman_region16_t *region, + pixman_box16_t *boxes, + int count); void pixman_region_init_with_extents (pixman_region16_t *region, pixman_box16_t *extents); void pixman_region_fini (pixman_region16_t *region); @@ -323,9 +326,6 @@ pixman_bool_t pixman_region_equal (pixman_region16_t pixman_bool_t pixman_region_selfcheck (pixman_region16_t *region); void pixman_region_reset (pixman_region16_t *region, pixman_box16_t *box); -pixman_bool_t pixman_region_init_rects (pixman_region16_t *region, - pixman_box16_t *boxes, - int count); /* * 32 bit regions @@ -365,6 +365,9 @@ void pixman_region32_init_rect (pixman_region32_t *r int y, unsigned int width, unsigned int height); +pixman_bool_t pixman_region32_init_rects (pixman_region32_t *region, + pixman_box32_t *boxes, + int count); void pixman_region32_init_with_extents (pixman_region32_t *region, pixman_box32_t *extents); void pixman_region32_fini (pixman_region32_t *region); @@ -410,9 +413,6 @@ pixman_bool_t pixman_region32_equal (pixman_region32_t *r pixman_bool_t pixman_region32_selfcheck (pixman_region32_t *region); void pixman_region32_reset (pixman_region32_t *region, pixman_box32_t *box); -pixman_bool_t pixman_region32_init_rects (pixman_region32_t *region, - pixman_box32_t *boxes, - int count); /* Copy / Fill / Misc */