Sync with trunk head (part 1 of 2)
[reactos.git] / subsystems / win32 / win32k / objects / rect.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /* $Id$ */
20
21 #include <win32k.h>
22
23 #define NDEBUG
24 #include <debug.h>
25
26 /* FUNCTIONS *****************************************************************/
27
28 BOOL
29 FASTCALL
30 RECTL_bUnionRect(RECTL *prclDst, const RECTL *prcl1, const RECTL *prcl2)
31 {
32 if (RECTL_bIsEmptyRect(prcl1))
33 {
34 if (RECTL_bIsEmptyRect(prcl2))
35 {
36 RECTL_vSetEmptyRect(prclDst);
37 return FALSE;
38 }
39 else
40 {
41 *prclDst = *prcl2;
42 }
43 }
44 else
45 {
46 if (RECTL_bIsEmptyRect(prcl2))
47 {
48 *prclDst = *prcl1;
49 }
50 else
51 {
52 prclDst->left = min(prcl1->left, prcl2->left);
53 prclDst->top = min(prcl1->top, prcl2->top);
54 prclDst->right = max(prcl1->right, prcl2->right);
55 prclDst->bottom = max(prcl1->bottom, prcl2->bottom);
56 }
57 }
58
59 return TRUE;
60 }
61
62
63 BOOL
64 FASTCALL
65 RECTL_bIntersectRect(RECTL* prclDst, const RECTL* prcl1, const RECTL* prcl2)
66 {
67 prclDst->left = max(prcl1->left, prcl2->left);
68 prclDst->right = min(prcl1->right, prcl2->right);
69
70 if (prclDst->left < prclDst->right)
71 {
72 prclDst->top = max(prcl1->top, prcl2->top);
73 prclDst->bottom = min(prcl1->bottom, prcl2->bottom);
74
75 if (prclDst->top < prclDst->bottom)
76 {
77 return TRUE;
78 }
79 }
80
81 RECTL_vSetEmptyRect(prclDst);
82
83 return FALSE;
84 }
85
86 VOID
87 FASTCALL
88 RECTL_vMakeWellOrdered(RECTL *prcl)
89 {
90 LONG lTmp;
91 if (prcl->left > prcl->right)
92 {
93 lTmp = prcl->left;
94 prcl->left = prcl->right;
95 prcl->right = lTmp;
96 }
97 if (prcl->top > prcl->bottom)
98 {
99 lTmp = prcl->top;
100 prcl->top = prcl->bottom;
101 prcl->bottom = lTmp;
102 }
103 }
104
105
106 /* EOF */