gdi32: Add a helper to retrieve the bounding rectangle.

This commit is contained in:
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; dst->height = rect.bottom - rect.top;
if (dst->layout & LAYOUT_RTL && dst->layout & LAYOUT_BITMAPORIENTATIONPRESERVED) if (dst->layout & LAYOUT_RTL && dst->layout & LAYOUT_BITMAPORIENTATIONPRESERVED)
{ {
swap_ints( &rect.left, &rect.right ); dst->x += dst->width;
dst->x = rect.left; dst->width = -dst->width;
dst->width = rect.right - rect.left;
} }
if (rect.left > rect.right) { swap_ints( &rect.left, &rect.right ); rect.left++; rect.right++; } get_bounding_rect( &rect, dst->x, dst->y, dst->width, dst->height );
if (rect.top > rect.bottom) { swap_ints( &rect.top, &rect.bottom ); rect.top++; rect.bottom++; }
if (get_clip_box( dc_dst, &clip )) if (get_clip_box( dc_dst, &clip ))
intersect_rect( &dst->visrect, &rect, &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; src->height = rect.bottom - rect.top;
if (src->layout & LAYOUT_RTL && src->layout & LAYOUT_BITMAPORIENTATIONPRESERVED) if (src->layout & LAYOUT_RTL && src->layout & LAYOUT_BITMAPORIENTATIONPRESERVED)
{ {
swap_ints( &rect.left, &rect.right ); src->x += src->width;
src->x = rect.left; src->width = -src->width;
src->width = rect.right - rect.left;
} }
if (rect.left > rect.right) { swap_ints( &rect.left, &rect.right ); rect.left++; rect.right++; } get_bounding_rect( &rect, src->x, src->y, src->width, src->height );
if (rect.top > rect.bottom) { swap_ints( &rect.top, &rect.bottom ); rect.top++; rect.bottom++; }
/* source is not clipped */ /* source is not clipped */
if (dc_src->header.type == OBJ_MEMDC) 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; 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 ) static inline int get_bitmap_stride( int width, int bpp )
{ {
return ((width * bpp + 15) >> 3) & ~1; return ((width * bpp + 15) >> 3) & ~1;