From 456b4c876e6e272ea85ee54e5b41daf6e68157be Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 14 Dec 2012 16:55:56 +0100 Subject: [PATCH] gdi32: Add a helper function to order the points of a rectangle. --- dlls/gdi32/dibdrv/graphics.c | 13 +------------ dlls/gdi32/font.c | 4 +--- dlls/gdi32/gdi_private.h | 16 ++++++++++++++++ dlls/gdi32/region.c | 16 ++-------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index bb4ec81db29..f9ed4c00dd3 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -108,18 +108,7 @@ static RECT get_device_rect( HDC hdc, int left, int top, int right, int bottom, rect.right--; } LPtoDP( hdc, (POINT *)&rect, 2 ); - if (rect.left > rect.right) - { - int tmp = rect.left; - rect.left = rect.right; - rect.right = tmp; - } - if (rect.top > rect.bottom) - { - int tmp = rect.top; - rect.top = rect.bottom; - rect.bottom = tmp; - } + order_rect( &rect ); return rect; } diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 34520f597cd..33e603c95da 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -2181,9 +2181,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, } LPtoDP(hdc, (POINT*)&rc, 2); - - if(rc.left > rc.right) {INT tmp = rc.left; rc.left = rc.right; rc.right = tmp;} - if(rc.top > rc.bottom) {INT tmp = rc.top; rc.top = rc.bottom; rc.bottom = tmp;} + order_rect( &rc ); } if (lprect && (flags & ETO_OPAQUE)) diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 84febeb1ffd..edd4bf6e6d8 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -439,6 +439,22 @@ static inline void offset_rect( RECT *rect, int offset_x, int offset_y ) rect->bottom += offset_y; } +static inline void order_rect( RECT *rect ) +{ + if (rect->left > rect->right) + { + int tmp = rect->left; + rect->left = rect->right; + rect->right = tmp; + } + if (rect->top > rect->bottom) + { + int tmp = rect->top; + rect->top = rect->bottom; + rect->bottom = tmp; + } +} + static inline void get_bounding_rect( RECT *rect, int x, int y, int width, int height ) { rect->left = x; diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c index cafd2030066..caa4ff6ea62 100644 --- a/dlls/gdi32/region.c +++ b/dlls/gdi32/region.c @@ -1114,20 +1114,8 @@ BOOL WINAPI RectInRegion( HRGN hrgn, const RECT *rect ) /* swap the coordinates to make right >= left and bottom >= top */ /* (region building rectangles are normalized the same way) */ - if( rect->top > rect->bottom) { - rc.top = rect->bottom; - rc.bottom = rect->top; - } else { - rc.top = rect->top; - rc.bottom = rect->bottom; - } - if( rect->right < rect->left) { - rc.right = rect->left; - rc.left = rect->right; - } else { - rc.right = rect->right; - rc.left = rect->left; - } + rc = *rect; + order_rect( &rc ); if ((obj = GDI_GetObjPtr( hrgn, OBJ_REGION ))) {