xref: /reactos/win32ss/gdi/ntgdi/rect.c (revision 65ce1461)
1 /*
2  * PROJECT:         ReactOS win32 kernel mode subsystem
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * FILE:            subsystems/win32/win32k/objects/rect.c
5  * PURPOSE:         Rect functions
6  * PROGRAMMER:      Timo Kreuzer
7  */
8 
9 #include <win32k.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 /* FUNCTIONS *****************************************************************/
15 
16 BOOL
17 FASTCALL
18 RECTL_bUnionRect(RECTL *prclDst, const RECTL *prcl1, const RECTL *prcl2)
19 {
20     if (RECTL_bIsEmptyRect(prcl1))
21     {
22         if (RECTL_bIsEmptyRect(prcl2))
23 	    {
24 	        RECTL_vSetEmptyRect(prclDst);
25 	        return FALSE;
26 	    }
27         else
28 	    {
29 	        *prclDst = *prcl2;
30 	    }
31     }
32     else
33     {
34         if (RECTL_bIsEmptyRect(prcl2))
35 	    {
36 	        *prclDst = *prcl1;
37 	    }
38         else
39 	    {
40 	        prclDst->left = min(prcl1->left, prcl2->left);
41 	        prclDst->top = min(prcl1->top, prcl2->top);
42 	        prclDst->right = max(prcl1->right, prcl2->right);
43 	        prclDst->bottom = max(prcl1->bottom, prcl2->bottom);
44 	    }
45     }
46 
47     return TRUE;
48 }
49 
50 
51 BOOL
52 FASTCALL
53 RECTL_bIntersectRect(RECTL* prclDst, const RECTL* prcl1, const RECTL* prcl2)
54 {
55     prclDst->left  = max(prcl1->left, prcl2->left);
56     prclDst->right = min(prcl1->right, prcl2->right);
57 
58     if (prclDst->left < prclDst->right)
59     {
60         prclDst->top    = max(prcl1->top, prcl2->top);
61         prclDst->bottom = min(prcl1->bottom, prcl2->bottom);
62 
63         if (prclDst->top < prclDst->bottom)
64         {
65             return TRUE;
66         }
67     }
68 
69     RECTL_vSetEmptyRect(prclDst);
70 
71     return FALSE;
72 }
73 
74 VOID
75 FASTCALL
76 RECTL_vMakeWellOrdered(RECTL *prcl)
77 {
78     LONG lTmp;
79     if (prcl->left > prcl->right)
80     {
81         lTmp = prcl->left;
82         prcl->left = prcl->right;
83         prcl->right = lTmp;
84     }
85     if (prcl->top > prcl->bottom)
86     {
87         lTmp = prcl->top;
88         prcl->top = prcl->bottom;
89         prcl->bottom = lTmp;
90     }
91 }
92 
93 VOID
94 FASTCALL
95 RECTL_vInflateRect(RECTL *rect, INT dx, INT dy)
96 {
97     rect->left -= dx;
98     rect->top -= dy;
99     rect->right += dx;
100     rect->bottom += dy;
101 }
102 
103 /* EOF */
104