diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index c595a60f8d1..a2a7698036f 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -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) diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index b3d027aca38..6a600a4a315 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -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;