2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* FUNCTIONS *****************************************************************/
29 IntGdiSetEmptyRect(PRECT Rect
)
31 Rect
->left
= Rect
->right
= Rect
->top
= Rect
->bottom
= 0;
35 NtGdiSetEmptyRect(PRECT UnsafeRect
)
38 NTSTATUS Status
= STATUS_SUCCESS
;
40 IntGdiSetEmptyRect(&Rect
);
44 ProbeForWrite(UnsafeRect
,
51 Status
= _SEH_GetExceptionCode();
55 if (! NT_SUCCESS(Status
))
57 SetLastNtError(Status
);
65 IntGdiIsEmptyRect(const RECT
* Rect
)
67 return(Rect
->left
>= Rect
->right
|| Rect
->top
>= Rect
->bottom
);
71 NtGdiIsEmptyRect(const RECT
* UnsafeRect
)
74 NTSTATUS Status
= STATUS_SUCCESS
;
78 ProbeForRead(UnsafeRect
,
85 Status
= _SEH_GetExceptionCode();
88 if (! NT_SUCCESS(Status
))
90 SetLastNtError(Status
);
94 return IntGdiIsEmptyRect(&Rect
);
98 IntGdiOffsetRect(LPRECT Rect
, INT x
, INT y
)
107 NtGdiOffsetRect(LPRECT UnsafeRect
, INT x
, INT y
)
110 NTSTATUS Status
= STATUS_SUCCESS
;
114 ProbeForRead(UnsafeRect
,
121 Status
= _SEH_GetExceptionCode();
124 if (! NT_SUCCESS(Status
))
126 SetLastNtError(Status
);
130 IntGdiOffsetRect(&Rect
, x
, y
);
134 ProbeForWrite(UnsafeRect
,
141 Status
= _SEH_GetExceptionCode();
144 if (! NT_SUCCESS(Status
))
146 SetLastNtError(Status
);
154 IntGdiUnionRect(PRECT Dest
, const RECT
* Src1
, const RECT
* Src2
)
156 if (IntGdiIsEmptyRect(Src1
))
158 if (IntGdiIsEmptyRect(Src2
))
160 IntGdiSetEmptyRect(Dest
);
170 if (IntGdiIsEmptyRect(Src2
))
176 Dest
->left
= min(Src1
->left
, Src2
->left
);
177 Dest
->top
= min(Src1
->top
, Src2
->top
);
178 Dest
->right
= max(Src1
->right
, Src2
->right
);
179 Dest
->bottom
= max(Src1
->bottom
, Src2
->bottom
);
187 NtGdiUnionRect(PRECT UnsafeDest
, const RECT
* UnsafeSrc1
, const RECT
* UnsafeSrc2
)
189 RECT Dest
, Src1
= {0}, Src2
= {0};
190 NTSTATUS Status
= STATUS_SUCCESS
;
195 ProbeForRead(UnsafeSrc1
,
198 ProbeForRead(UnsafeSrc2
,
206 Status
= _SEH_GetExceptionCode();
209 if (! NT_SUCCESS(Status
))
211 SetLastNtError(Status
);
215 Ret
= IntGdiUnionRect(&Dest
, &Src1
, &Src2
);
221 ProbeForWrite(UnsafeDest
,
228 Status
= _SEH_GetExceptionCode();
231 if (! NT_SUCCESS(Status
))
233 SetLastNtError(Status
);
242 IntGdiSetRect(PRECT Rect
, INT left
, INT top
, INT right
, INT bottom
)
247 Rect
->bottom
= bottom
;
251 NtGdiSetRect(PRECT UnsafeRect
, INT left
, INT top
, INT right
, INT bottom
)
254 NTSTATUS Status
= STATUS_SUCCESS
;
256 IntGdiSetRect(&Rect
, left
, top
, right
, bottom
);
260 ProbeForWrite(UnsafeRect
,
267 Status
= _SEH_GetExceptionCode();
270 if (! NT_SUCCESS(Status
))
272 SetLastNtError(Status
);
280 IntGdiIntersectRect(PRECT Dest
, const RECT
* Src1
, const RECT
* Src2
)
282 if (IntGdiIsEmptyRect(Src1
) || IntGdiIsEmptyRect(Src2
) ||
283 Src1
->left
>= Src2
->right
|| Src2
->left
>= Src1
->right
||
284 Src1
->top
>= Src2
->bottom
|| Src2
->top
>= Src1
->bottom
)
286 IntGdiSetEmptyRect(Dest
);
290 Dest
->left
= max(Src1
->left
, Src2
->left
);
291 Dest
->right
= min(Src1
->right
, Src2
->right
);
292 Dest
->top
= max(Src1
->top
, Src2
->top
);
293 Dest
->bottom
= min(Src1
->bottom
, Src2
->bottom
);
299 NtGdiIntersectRect(PRECT UnsafeDest
, const RECT
* UnsafeSrc1
, const RECT
* UnsafeSrc2
)
301 RECT Dest
, Src1
, Src2
= {0};
302 NTSTATUS Status
= STATUS_SUCCESS
;
307 ProbeForRead(UnsafeSrc1
,
310 ProbeForRead(UnsafeSrc2
,
318 Status
= _SEH_GetExceptionCode();
321 if (! NT_SUCCESS(Status
))
323 SetLastNtError(Status
);
327 Ret
= IntGdiIntersectRect(&Dest
, &Src2
, &Src2
);
333 ProbeForWrite(UnsafeDest
,
340 Status
= _SEH_GetExceptionCode();
343 if (! NT_SUCCESS(Status
))
345 SetLastNtError(Status
);