gdi32: Add a helper to retrieve the bounding rectangle.

oldstable
Huw Davies 2011-10-11 12:49:53 +01:00 committed by Alexandre Julliard
parent 125529fabe
commit a7b5d86655
2 changed files with 26 additions and 10 deletions

View File

@ -65,12 +65,10 @@ static BOOL get_vis_rectangles( DC *dc_dst, struct bitblt_coords *dst,
dst->height = rect.bottom - rect.top;
if (dst->layout & LAYOUT_RTL && dst->layout & LAYOUT_BITMAPORIENTATIONPRESERVED)
{
swap_ints( &rect.left, &rect.right );
dst->x = rect.left;
dst->width = rect.right - rect.left;
dst->x += dst->width;
dst->width = -dst->width;
}
if (rect.left > rect.right) { swap_ints( &rect.left, &rect.right ); rect.left++; rect.right++; }
if (rect.top > rect.bottom) { swap_ints( &rect.top, &rect.bottom ); rect.top++; rect.bottom++; }
get_bounding_rect( &rect, dst->x, dst->y, dst->width, dst->height );
if (get_clip_box( dc_dst, &clip ))
intersect_rect( &dst->visrect, &rect, &clip );
@ -92,12 +90,10 @@ static BOOL get_vis_rectangles( DC *dc_dst, struct bitblt_coords *dst,
src->height = rect.bottom - rect.top;
if (src->layout & LAYOUT_RTL && src->layout & LAYOUT_BITMAPORIENTATIONPRESERVED)
{
swap_ints( &rect.left, &rect.right );
src->x = rect.left;
src->width = rect.right - rect.left;
src->x += src->width;
src->width = -src->width;
}
if (rect.left > rect.right) { swap_ints( &rect.left, &rect.right ); rect.left++; rect.right++; }
if (rect.top > rect.bottom) { swap_ints( &rect.top, &rect.bottom ); rect.top++; rect.bottom++; }
get_bounding_rect( &rect, src->x, src->y, src->width, src->height );
/* source is not clipped */
if (dc_src->header.type == OBJ_MEMDC)

View File

@ -469,6 +469,26 @@ static inline void offset_rect( RECT *rect, int offset_x, int offset_y )
rect->bottom += offset_y;
}
static inline void get_bounding_rect( RECT *rect, int x, int y, int width, int height )
{
rect->left = x;
rect->right = x + width;
rect->top = y;
rect->bottom = y + height;
if (rect->left > rect->right)
{
int tmp = rect->left;
rect->left = rect->right + 1;
rect->right = tmp + 1;
}
if (rect->top > rect->bottom)
{
int tmp = rect->top;
rect->top = rect->bottom + 1;
rect->bottom = tmp + 1;
}
}
static inline int get_bitmap_stride( int width, int bpp )
{
return ((width * bpp + 15) >> 3) & ~1;