Alexandre Julliard : gdi32: Add a helper function to order the points of a rectangle.
Alexandre Julliard
julliard at winehq.org
Fri Dec 14 14:10:00 CST 2012
Module: wine
Branch: master
Commit: 456b4c876e6e272ea85ee54e5b41daf6e68157be
URL: http://source.winehq.org/git/wine.git/?a=commit;h=456b4c876e6e272ea85ee54e5b41daf6e68157be
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Dec 14 16:55:56 2012 +0100
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 bb4ec81..f9ed4c0 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 34520f5..33e603c 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 84febeb..edd4bf6 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 cafd203..caa4ff6 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 )))
{
More information about the wine-cvs
mailing list