ReactOS  0.4.15-dev-440-g5f37b68
region.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for region.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MIN_COORD   (INT_MIN/16)
 
#define MAX_COORD   (INT_MAX/16)
 
#define INRECT(r, x, y)
 

Functions

static VOID FASTCALL SortRects (PRECT pRect, INT nCount)
 
BOOL FASTCALL DeleteRegion (_In_ HRGN hrgn)
 
INT FASTCALL MirrorRgnByWidth (_In_ HRGN hrgn, _In_ INT Width, _Out_opt_ HRGN *phrgn)
 
INT WINAPI MirrorRgnDC (_In_ HDC hdc, _In_ HRGN hrgn, _Out_opt_ HRGN *phrn)
 
FORCEINLINE ULONG IntSetNullRgn (_Inout_ PRGN_ATTR prgnattr)
 
FORCEINLINE ULONG IntSetRectRgn (_Inout_ PRGN_ATTR prgnattr, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
 
INT WINAPI CombineRgn (_In_ HRGN hrgnDest, _In_ HRGN hrgnSrc1, _In_ HRGN hrgnSrc2, _In_ INT iCombineMode)
 
HRGN WINAPI CreateEllipticRgnIndirect (const RECT *prc)
 
HRGN WINAPI CreatePolygonRgn (const POINT *lppt, int cPoints, int fnPolyFillMode)
 
HRGN WINAPI CreatePolyPolygonRgn (const POINT *lppt, const INT *lpPolyCounts, int nCount, int fnPolyFillMode)
 
HRGN WINAPI CreateRectRgn (int x1, int y1, int x2, int y2)
 
HRGN WINAPI CreateRectRgnIndirect (const RECT *prc)
 
INT WINAPI ExcludeClipRect (_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
 
HRGN WINAPI ExtCreateRegion (CONST XFORM *lpXform, DWORD nCount, CONST RGNDATA *lpRgnData)
 
INT WINAPI ExtSelectClipRgn (_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iMode)
 
int WINAPI GetClipRgn (HDC hdc, HRGN hrgn)
 
int WINAPI GetMetaRgn (HDC hdc, HRGN hrgn)
 
DWORD WINAPI GetRegionData (HRGN hrgn, DWORD nCount, LPRGNDATA lpRgnData)
 
INT WINAPI GetRgnBox (HRGN hrgn, LPRECT prcOut)
 
INT WINAPI IntersectClipRect (_In_ HDC hdc, _In_ INT nLeft, _In_ INT nTop, _In_ INT nRight, _In_ INT nBottom)
 
BOOL WINAPI MirrorRgn (HWND hwnd, HRGN hrgn)
 
INT WINAPI OffsetClipRgn (HDC hdc, INT nXOffset, INT nYOffset)
 
INT WINAPI OffsetRgn (HRGN hrgn, int nXOffset, int nYOffset)
 
BOOL WINAPI PtInRegion (IN HRGN hrgn, int x, int y)
 
BOOL WINAPI RectInRegion (HRGN hrgn, LPCRECT prcl)
 
int WINAPI SelectClipRgn (_In_ HDC hdc, _In_ HRGN hrgn)
 
BOOL WINAPI SetRectRgn (_In_ HRGN hrgn, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
 
int WINAPI SetMetaRgn (HDC hDC)
 

Macro Definition Documentation

◆ INRECT

#define INRECT (   r,
  x,
  y 
)
Value:
( ( ((r).right > x)) && \
( ((r).left <= x)) && \
( ((r).bottom > y)) && \
( ((r).top <= y)) )
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint bottom
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Definition at line 14 of file region.c.

◆ MAX_COORD

#define MAX_COORD   (INT_MAX/16)

Definition at line 12 of file region.c.

◆ MIN_COORD

#define MIN_COORD   (INT_MIN/16)

Definition at line 11 of file region.c.

◆ NDEBUG

#define NDEBUG

Definition at line 3 of file region.c.

Function Documentation

◆ CombineRgn()

INT WINAPI CombineRgn ( _In_ HRGN  hrgnDest,
_In_ HRGN  hrgnSrc1,
_In_ HRGN  hrgnSrc2,
_In_ INT  iCombineMode 
)

Definition at line 195 of file region.c.

200 {
201  PRGN_ATTR prngattrDest = NULL;
202  PRGN_ATTR prngattrSrc1 = NULL;
203  PRGN_ATTR prngattrSrc2 = NULL;
204  RECT rcTemp;
205 
206  /* Get the region attribute for dest and source 1 */
207  prngattrDest = GdiGetRgnAttr(hrgnDest);
208  prngattrSrc1 = GdiGetRgnAttr(hrgnSrc1);
209 
210  /* If that failed or if the source 1 region is complex, go to win32k */
211  if ((prngattrDest == NULL) || (prngattrSrc1 == NULL) ||
212  (prngattrSrc1->iComplexity > SIMPLEREGION))
213  {
214  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
215  }
216 
217  /* Handle RGN_COPY first, it needs only hrgnSrc1 */
218  if (iCombineMode == RGN_COPY)
219  {
220  /* Check if the source region is a NULLREGION */
221  if (prngattrSrc1->iComplexity == NULLREGION)
222  {
223  /* The dest region is a NULLREGION, too */
224  return IntSetNullRgn(prngattrDest);
225  }
226 
227  /* We already know that the source region cannot be complex, so
228  create a rect region from the bounds of the source rect */
229  return IntSetRectRgn(prngattrDest,
230  prngattrSrc1->Rect.left,
231  prngattrSrc1->Rect.top,
232  prngattrSrc1->Rect.right,
233  prngattrSrc1->Rect.bottom);
234  }
235 
236  /* For all other operations we need hrgnSrc2 */
237  prngattrSrc2 = GdiGetRgnAttr(hrgnSrc2);
238 
239  /* If we got no attribute or the region is complex, go to win32k */
240  if ((prngattrSrc2 == NULL) || (prngattrSrc2->iComplexity > SIMPLEREGION))
241  {
242  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
243  }
244 
245  /* Handle RGN_AND */
246  if (iCombineMode == RGN_AND)
247  {
248  /* Check if either of the regions is a NULLREGION */
249  if ((prngattrSrc1->iComplexity == NULLREGION) ||
250  (prngattrSrc2->iComplexity == NULLREGION))
251  {
252  /* Result is also a NULLREGION */
253  return IntSetNullRgn(prngattrDest);
254  }
255 
256  /* Get the intersection of the 2 rects */
257  if (!IntersectRect(&rcTemp, &prngattrSrc1->Rect, &prngattrSrc2->Rect))
258  {
259  /* The rects do not intersect, result is a NULLREGION */
260  return IntSetNullRgn(prngattrDest);
261  }
262 
263  /* Use the intersection of the rects */
264  return IntSetRectRgn(prngattrDest,
265  rcTemp.left,
266  rcTemp.top,
267  rcTemp.right,
268  rcTemp.bottom);
269  }
270 
271  /* Handle RGN_DIFF */
272  if (iCombineMode == RGN_DIFF)
273  {
274  /* Check if source 1 is a NULLREGION */
275  if (prngattrSrc1->iComplexity == NULLREGION)
276  {
277  /* The result is a NULLREGION as well */
278  return IntSetNullRgn(prngattrDest);
279  }
280 
281  /* Get the intersection of the 2 rects */
282  if ((prngattrSrc2->iComplexity == NULLREGION) ||
283  !IntersectRect(&rcTemp, &prngattrSrc1->Rect, &prngattrSrc2->Rect))
284  {
285  /* The rects do not intersect, dest equals source 1 */
286  return IntSetRectRgn(prngattrDest,
287  prngattrSrc1->Rect.left,
288  prngattrSrc1->Rect.top,
289  prngattrSrc1->Rect.right,
290  prngattrSrc1->Rect.bottom);
291  }
292 
293  /* We need to check is whether we can subtract the rects. For that
294  we call SubtractRect, which will give us the bounding box of the
295  subtraction. The function returns FALSE if the resulting rect is
296  empty */
297  if (!SubtractRect(&rcTemp, &prngattrSrc1->Rect, &rcTemp))
298  {
299  /* The result is a NULLREGION */
300  return IntSetNullRgn(prngattrDest);
301  }
302 
303  /* Now check if the result of SubtractRect matches the source 1 rect.
304  Since we already know that the rects intersect, the result can
305  only match the source 1 rect, if it could not be "cut" on either
306  side, but the overlapping was on a corner, so the new bounding box
307  equals the previous rect */
308  if (!EqualRect(&rcTemp, &prngattrSrc1->Rect))
309  {
310  /* We got a properly subtracted rect, so use it. */
311  return IntSetRectRgn(prngattrDest,
312  rcTemp.left,
313  rcTemp.top,
314  rcTemp.right,
315  rcTemp.bottom);
316  }
317 
318  /* The result would be a complex region, go to win32k */
319  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
320  }
321 
322  /* Handle OR and XOR */
323  if ((iCombineMode == RGN_OR) || (iCombineMode == RGN_XOR))
324  {
325  /* Check if source 1 is a NULLREGION */
326  if (prngattrSrc1->iComplexity == NULLREGION)
327  {
328  /* Check if source 2 is also a NULLREGION */
329  if (prngattrSrc2->iComplexity == NULLREGION)
330  {
331  /* Both are NULLREGIONs, result is also a NULLREGION */
332  return IntSetNullRgn(prngattrDest);
333  }
334 
335  /* The result is equal to source 2 */
336  return IntSetRectRgn(prngattrDest,
337  prngattrSrc2->Rect.left,
338  prngattrSrc2->Rect.top,
339  prngattrSrc2->Rect.right,
340  prngattrSrc2->Rect.bottom );
341  }
342 
343  /* Check if only source 2 is a NULLREGION */
344  if (prngattrSrc2->iComplexity == NULLREGION)
345  {
346  /* The result is equal to source 1 */
347  return IntSetRectRgn(prngattrDest,
348  prngattrSrc1->Rect.left,
349  prngattrSrc1->Rect.top,
350  prngattrSrc1->Rect.right,
351  prngattrSrc1->Rect.bottom);
352  }
353 
354  /* Do the rects have the same x extent */
355  if ((prngattrSrc1->Rect.left == prngattrSrc2->Rect.left) &&
356  (prngattrSrc1->Rect.right == prngattrSrc2->Rect.right))
357  {
358  /* Do the rects also have the same y extent */
359  if ((prngattrSrc1->Rect.top == prngattrSrc2->Rect.top) &&
360  (prngattrSrc1->Rect.bottom == prngattrSrc2->Rect.bottom))
361  {
362  /* Rects are equal, if this is RGN_OR, the result is source 1 */
363  if (iCombineMode == RGN_OR)
364  {
365  /* The result is equal to source 1 */
366  return IntSetRectRgn(prngattrDest,
367  prngattrSrc1->Rect.left,
368  prngattrSrc1->Rect.top,
369  prngattrSrc1->Rect.right,
370  prngattrSrc1->Rect.bottom );
371  }
372  else
373  {
374  /* XORing with itself yields an empty region */
375  return IntSetNullRgn(prngattrDest);
376  }
377  }
378 
379  /* Check if the rects are disjoint */
380  if ((prngattrSrc2->Rect.bottom < prngattrSrc1->Rect.top) ||
381  (prngattrSrc2->Rect.top > prngattrSrc1->Rect.bottom))
382  {
383  /* The result would be a complex region, go to win32k */
384  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
385  }
386 
387  /* Check if this is OR */
388  if (iCombineMode == RGN_OR)
389  {
390  /* Use the maximum extent of both rects combined */
391  return IntSetRectRgn(prngattrDest,
392  prngattrSrc1->Rect.left,
393  min(prngattrSrc1->Rect.top, prngattrSrc2->Rect.top),
394  prngattrSrc1->Rect.right,
395  max(prngattrSrc1->Rect.bottom, prngattrSrc2->Rect.bottom));
396  }
397 
398  /* Check if the rects are adjacent */
399  if (prngattrSrc2->Rect.bottom == prngattrSrc1->Rect.top)
400  {
401  /* The result is the combined rects */
402  return IntSetRectRgn(prngattrDest,
403  prngattrSrc1->Rect.left,
404  prngattrSrc2->Rect.top,
405  prngattrSrc1->Rect.right,
406  prngattrSrc1->Rect.bottom );
407  }
408  else if (prngattrSrc2->Rect.top == prngattrSrc1->Rect.bottom)
409  {
410  /* The result is the combined rects */
411  return IntSetRectRgn(prngattrDest,
412  prngattrSrc1->Rect.left,
413  prngattrSrc1->Rect.top,
414  prngattrSrc1->Rect.right,
415  prngattrSrc2->Rect.bottom );
416  }
417 
418  /* When we are here, this is RGN_XOR and the rects overlap */
419  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
420  }
421 
422  /* Do the rects have the same y extent */
423  if ((prngattrSrc1->Rect.top == prngattrSrc2->Rect.top) &&
424  (prngattrSrc1->Rect.bottom == prngattrSrc2->Rect.bottom))
425  {
426  /* Check if the rects are disjoint */
427  if ((prngattrSrc2->Rect.right < prngattrSrc1->Rect.left) ||
428  (prngattrSrc2->Rect.left > prngattrSrc1->Rect.right))
429  {
430  /* The result would be a complex region, go to win32k */
431  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
432  }
433 
434  /* Check if this is OR */
435  if (iCombineMode == RGN_OR)
436  {
437  /* Use the maximum extent of both rects combined */
438  return IntSetRectRgn(prngattrDest,
439  min(prngattrSrc1->Rect.left, prngattrSrc2->Rect.left),
440  prngattrSrc1->Rect.top,
441  max(prngattrSrc1->Rect.right, prngattrSrc2->Rect.right),
442  prngattrSrc1->Rect.bottom);
443  }
444 
445  /* Check if the rects are adjacent */
446  if (prngattrSrc2->Rect.right == prngattrSrc1->Rect.left)
447  {
448  /* The result is the combined rects */
449  return IntSetRectRgn(prngattrDest,
450  prngattrSrc2->Rect.left,
451  prngattrSrc1->Rect.top,
452  prngattrSrc1->Rect.right,
453  prngattrSrc1->Rect.bottom );
454  }
455  else if (prngattrSrc2->Rect.left == prngattrSrc1->Rect.right)
456  {
457  /* The result is the combined rects */
458  return IntSetRectRgn(prngattrDest,
459  prngattrSrc1->Rect.left,
460  prngattrSrc1->Rect.top,
461  prngattrSrc2->Rect.right,
462  prngattrSrc1->Rect.bottom );
463  }
464 
465  /* When we are here, this is RGN_XOR and the rects overlap */
466  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
467  }
468 
469  /* Last case: RGN_OR and one rect is completely within the other */
470  if (iCombineMode == RGN_OR)
471  {
472  /* Check if rect 1 can contain rect 2 */
473  if (prngattrSrc1->Rect.left <= prngattrSrc2->Rect.left)
474  {
475  /* rect 1 might be the outer one, check of that is true */
476  if ((prngattrSrc1->Rect.right >= prngattrSrc2->Rect.right) &&
477  (prngattrSrc1->Rect.top <= prngattrSrc2->Rect.top) &&
478  (prngattrSrc1->Rect.bottom >= prngattrSrc2->Rect.bottom))
479  {
480  /* Rect 1 contains rect 2, use it */
481  return IntSetRectRgn(prngattrDest,
482  prngattrSrc1->Rect.left,
483  prngattrSrc1->Rect.top,
484  prngattrSrc1->Rect.right,
485  prngattrSrc1->Rect.bottom );
486  }
487  }
488  else
489  {
490  /* rect 2 might be the outer one, check of that is true */
491  if ((prngattrSrc2->Rect.right >= prngattrSrc1->Rect.right) &&
492  (prngattrSrc2->Rect.top <= prngattrSrc1->Rect.top) &&
493  (prngattrSrc2->Rect.bottom >= prngattrSrc1->Rect.bottom))
494  {
495  /* Rect 2 contains rect 1, use it */
496  return IntSetRectRgn(prngattrDest,
497  prngattrSrc2->Rect.left,
498  prngattrSrc2->Rect.top,
499  prngattrSrc2->Rect.right,
500  prngattrSrc2->Rect.bottom );
501  }
502  }
503  }
504 
505  /* We couldn't handle the operation, go to win32k */
506  return NtGdiCombineRgn(hrgnDest, hrgnSrc1, hrgnSrc2, iCombineMode);
507  }
508 
509  DPRINT1("Invalid iCombineMode %d\n", iCombineMode);
511  return ERROR;
512 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define max(a, b)
Definition: svc.c:63
BOOL WINAPI SubtractRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define ERROR(name)
Definition: error_private.h:53
_In_ HANDLE _In_ HANDLE hrgnSrc2
Definition: winddi.h:4295
#define NULLREGION
Definition: wingdi.h:360
LONG top
Definition: windef.h:307
long bottom
Definition: polytest.cpp:53
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define RGN_AND
Definition: wingdi.h:355
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
long right
Definition: polytest.cpp:53
#define RGN_XOR
Definition: wingdi.h:359
_In_ HANDLE hrgnSrc1
Definition: winddi.h:4295
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:416
#define RGN_OR
Definition: wingdi.h:358
FORCEINLINE ULONG IntSetRectRgn(_Inout_ PRGN_ATTR prgnattr, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: region.c:168
long left
Definition: polytest.cpp:53
#define SetLastError(x)
Definition: compat.h:418
ULONG iComplexity
Definition: ntgdihdl.h:270
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define RGN_COPY
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE ULONG IntSetNullRgn(_Inout_ PRGN_ATTR prgnattr)
Definition: region.c:157
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define RGN_DIFF
Definition: wingdi.h:357
INT APIENTRY NtGdiCombineRgn(IN HRGN hrgnDst, IN HRGN hrgnSrc1, IN HRGN hrgnSrc2, IN INT iMode)
Definition: region.c:3531
#define min(a, b)
Definition: monoChain.cc:55
#define DPRINT1
Definition: precomp.h:8
RECTL Rect
Definition: ntgdihdl.h:271
LONG bottom
Definition: windef.h:309

Referenced by get_region_hrgn(), and MirrorRgnByWidth().

◆ CreateEllipticRgnIndirect()

HRGN WINAPI CreateEllipticRgnIndirect ( const RECT prc)

Definition at line 520 of file region.c.

523 {
524  /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
526 
527 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
_Out_ LPRECT prc
Definition: ntgdi.h:1658
HRGN APIENTRY NtGdiCreateEllipticRgn(INT Left, INT Top, INT Right, INT Bottom)
Definition: region.c:3590

◆ CreatePolygonRgn()

HRGN WINAPI CreatePolygonRgn ( const POINT lppt,
int  cPoints,
int  fnPolyFillMode 
)

Definition at line 534 of file region.c.

535 {
536  return (HRGN) NtGdiPolyPolyDraw( (HDC)UlongToHandle(fnPolyFillMode), (PPOINT) lppt, (PULONG) &cPoints, 1, GdiPolyPolyRgn);
537 }
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI ULONG_PTR APIENTRY NtGdiPolyPolyDraw(_In_ HDC hdc, _In_ PPOINT ppt, _In_reads_(ccpt) PULONG pcpt, _In_ ULONG ccpt, _In_ INT iFunc)
#define UlongToHandle(ul)
Definition: basetsd.h:97
unsigned int * PULONG
Definition: retypes.h:1

◆ CreatePolyPolygonRgn()

HRGN WINAPI CreatePolyPolygonRgn ( const POINT lppt,
const INT lpPolyCounts,
int  nCount,
int  fnPolyFillMode 
)

Definition at line 544 of file region.c.

548 {
549  return (HRGN) NtGdiPolyPolyDraw( (HDC)UlongToHandle(fnPolyFillMode), (PPOINT) lppt, (PULONG) lpPolyCounts, (ULONG) nCount, GdiPolyPolyRgn );
550 }
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI ULONG_PTR APIENTRY NtGdiPolyPolyDraw(_In_ HDC hdc, _In_ PPOINT ppt, _In_reads_(ccpt) PULONG pcpt, _In_ ULONG ccpt, _In_ INT iFunc)
#define UlongToHandle(ul)
Definition: basetsd.h:97
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

◆ CreateRectRgn()

HRGN WINAPI CreateRectRgn ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 557 of file region.c.

558 {
559  PRGN_ATTR pRgn_Attr;
560  HRGN hrgn = NULL;
561  int tmp;
562 
563  /* Normalize points, REGION_SetRectRgn does this too. */
564  if ( x1 > x2 )
565  {
566  tmp = x1;
567  x1 = x2;
568  x2 = tmp;
569  }
570 
571  if ( y1 > y2 )
572  {
573  tmp = y1;
574  y1 = y2;
575  y2 = tmp;
576  }
577  /* Check outside 28 bit limit for universal set bound box. REGION_SetRectRgn doesn't do this! */
578  if ( x1 < MIN_COORD ||
579  y1 < MIN_COORD ||
580  x2 > MAX_COORD ||
581  y2 > MAX_COORD )
582  {
584  return NULL;
585  }
586 
588  if (hrgn)
589  {
590  DPRINT1("PEB Handle Cache Test return hrgn %p, should be NULL!\n",hrgn);
591  hrgn = NULL;
592  }
593 
594  if (!hrgn)
595  hrgn = NtGdiCreateRectRgn(0, 0, 1, 1);
596 
597  if (!hrgn)
598  return hrgn;
599 
600  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)) )
601  {
602  DPRINT1("No Attr for Region handle!!!\n");
604  return NULL;
605  }
606 
607  pRgn_Attr->AttrFlags = ATTR_RGN_VALID;
608 
609  IntSetRectRgn( pRgn_Attr, x1, y1, x2, y2 );
610 
611  return hrgn;
612 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3706
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
HRGN APIENTRY NtGdiCreateRectRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:3605
#define MAX_COORD
Definition: region.c:12
#define ATTR_RGN_VALID
Definition: ntgdihdl.h:210
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE ULONG IntSetRectRgn(_Inout_ PRGN_ATTR prgnattr, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: region.c:168
ULONG AttrFlags
Definition: ntgdihdl.h:269
#define SetLastError(x)
Definition: compat.h:418
static HRGN hrgn
Definition: win.c:55
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3706
HGDIOBJ FASTCALL hGetPEBHandle(HANDLECACHETYPE, COLORREF)
Definition: misc.c:880
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
#define DPRINT1
Definition: precomp.h:8
BOOL FASTCALL DeleteRegion(_In_ HRGN hrgn)
Definition: region.c:64
#define MIN_COORD
Definition: region.c:11

Referenced by CreateRectRgnIndirect(), ExtCreateRegion(), get_path_hrgn(), get_region_hrgn(), and test_fromhrgn().

◆ CreateRectRgnIndirect()

HRGN WINAPI CreateRectRgnIndirect ( const RECT prc)

Definition at line 619 of file region.c.

622 {
623  /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
624  return CreateRectRgn(prc->left, prc->top, prc->right, prc->bottom);
625 
626 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HRGN WINAPI CreateRectRgn(int x1, int y1, int x2, int y2)
Definition: region.c:557
LONG bottom
Definition: windef.h:309
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ DeleteRegion()

BOOL FASTCALL DeleteRegion ( _In_ HRGN  hrgn)

Definition at line 64 of file region.c.

66 {
67  PRGN_ATTR Rgn_Attr = GdiGetRgnAttr(hrgn);
68 
69  if ( Rgn_Attr )
70  {
71  PGDIBSOBJECT pgO;
72 
74  if (pgO)
75  {
76  pgO->hgdiobj = hrgn;
77  return TRUE;
78  }
79  }
80  return NtGdiDeleteObjectApp(hrgn);
81 }
#define TRUE
Definition: types.h:120
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
smooth NULL
Definition: ftsmooth.c:416
HGDIOBJ hgdiobj
Definition: ntgdityp.h:560
static HRGN hrgn
Definition: win.c:55
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)
FORCEINLINE PVOID GdiAllocBatchCommand(HDC hdc, USHORT Cmd)
Definition: gdi32p.h:381

Referenced by CreateRectRgn().

◆ ExcludeClipRect()

INT WINAPI ExcludeClipRect ( _In_ HDC  hdc,
_In_ INT  xLeft,
_In_ INT  yTop,
_In_ INT  xRight,
_In_ INT  yBottom 
)

Definition at line 633 of file region.c.

639 {
640  HANDLE_METADC(INT, ExcludeClipRect, ERROR, hdc, xLeft, yTop, xRight, yBottom);
641 
642  return NtGdiExcludeClipRect(hdc, xLeft, yTop, xRight, yBottom);
643 }
#define ERROR(name)
Definition: error_private.h:53
__kernel_entry W32KAPI INT APIENTRY NtGdiExcludeClipRect(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: cliprgn.c:438
int32_t INT
Definition: typedefs.h:57
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
INT WINAPI ExcludeClipRect(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: region.c:633
HDC hdc
Definition: main.c:9

◆ ExtCreateRegion()

HRGN WINAPI ExtCreateRegion ( CONST XFORM lpXform,
DWORD  nCount,
CONST RGNDATA lpRgnData 
)

Definition at line 650 of file region.c.

655 {
656  if (lpRgnData)
657  {
658  if ((!lpXform) && (lpRgnData->rdh.nCount == 1))
659  {
660  PRECT pRect = (PRECT)&lpRgnData->Buffer[0];
661  return CreateRectRgn(pRect->left, pRect->top, pRect->right, pRect->bottom);
662  }
663  return NtGdiExtCreateRegion((LPXFORM) lpXform, nCount,(LPRGNDATA) lpRgnData);
664  }
666  return NULL;
667 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HRGN APIENTRY NtGdiExtCreateRegion(OPTIONAL LPXFORM Xform, DWORD Count, LPRGNDATA RgnData)
Definition: region.c:3824
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:418
HRGN WINAPI CreateRectRgn(int x1, int y1, int x2, int y2)
Definition: region.c:557
LONG bottom
Definition: windef.h:309
struct tagRECT * PRECT

Referenced by MirrorRgnByWidth().

◆ ExtSelectClipRgn()

INT WINAPI ExtSelectClipRgn ( _In_ HDC  hdc,
_In_ HRGN  hrgn,
_In_ INT  iMode 
)

Definition at line 674 of file region.c.

678 {
679  INT Ret;
680  HRGN NewRgn = NULL;
681 
683 
684 #if 0
685  if ( hrgn )
686  {
687  if ( GetLayout(hdc) & LAYOUT_RTL )
688  {
689  if ( MirrorRgnDC(hdc, hrgn, &NewRgn) )
690  {
691  if ( NewRgn ) hrgn = NewRgn;
692  }
693  }
694  }
695 #endif
696  /* Batch handles RGN_COPY only! */
697  if (iMode == RGN_COPY)
698  {
699  PDC_ATTR pdcattr;
700  PRGN_ATTR pRgn_Attr = NULL;
701 
702  /* Get the DC attribute */
703  pdcattr = GdiGetDcAttr(hdc);
704  if ( pdcattr )
705  {
707 
708  /* hrgn can be NULL unless the RGN_COPY mode is specified. */
709  if (hrgn) pRgn_Attr = GdiGetRgnAttr(hrgn);
710 
711  if ( !(pdcattr->ulDirty_ & DC_DIBSECTION) &&
712  !(pEntry->Flags & GDI_ENTRY_VALIDATE_VIS) )
713  {
714  if (!hrgn || (hrgn && pRgn_Attr && pRgn_Attr->iComplexity <= SIMPLEREGION) )
715  {
717  if (pgO)
718  {
719  pgO->fnMode = iMode;
720 
721  if ( hrgn && pRgn_Attr )
722  {
723  Ret = pRgn_Attr->iComplexity;
724  // Note from ntgdi/dcstate.c : "The VisRectRegion field needs to be set to a valid state."
725  if ( pdcattr->VisRectRegion.Rect.left >= pRgn_Attr->Rect.right ||
726  pdcattr->VisRectRegion.Rect.top >= pRgn_Attr->Rect.bottom ||
727  pdcattr->VisRectRegion.Rect.right <= pRgn_Attr->Rect.left ||
728  pdcattr->VisRectRegion.Rect.bottom <= pRgn_Attr->Rect.top )
729  Ret = NULLREGION;
730 
731  // Pass the rect since this region will go away.
732  pgO->rcl = pRgn_Attr->Rect;
733  }
734  else
735  {
736  Ret = pdcattr->VisRectRegion.iComplexity;
737  pgO->fnMode |= GDIBS_NORECT; // Set no hrgn mode.
738  }
739  if ( NewRgn ) DeleteObject(NewRgn);
740  return Ret;
741  }
742  }
743  }
744  }
745  }
747 
748  if ( NewRgn ) DeleteObject(NewRgn);
749 
750  return Ret;
751 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
#define LAYOUT_RTL
Definition: wingdi.h:1370
_In_ ULONG iMode
Definition: winddi.h:3520
__kernel_entry W32KAPI INT APIENTRY NtGdiExtSelectClipRgn(_In_ HDC hdc, _In_opt_ HRGN hrgn, _In_ INT iMode)
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define DC_DIBSECTION
Definition: ntgdihdl.h:159
#define NULLREGION
Definition: wingdi.h:360
long bottom
Definition: polytest.cpp:53
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int32_t INT
Definition: typedefs.h:57
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:416
long left
Definition: polytest.cpp:53
ULONG ulDirty_
Definition: ntgdihdl.h:298
#define GdiHandleTable
Definition: win32nt.h:35
#define GDIBS_NORECT
Definition: ntgdityp.h:507
HDC hdc
Definition: main.c:9
RGN_ATTR VisRectRegion
Definition: ntgdihdl.h:354
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:270
#define RGN_COPY
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:361
Definition: gdi.h:1
UCHAR Flags
Definition: ntgdihdl.h:225
INT WINAPI MirrorRgnDC(_In_ HDC hdc, _In_ HRGN hrgn, _Out_opt_ HRGN *phrn)
Definition: region.c:141
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
#define GDI_ENTRY_VALIDATE_VIS
Definition: ntgdihdl.h:40
INT WINAPI ExtSelectClipRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iMode)
Definition: region.c:674
RECTL Rect
Definition: ntgdihdl.h:271
FORCEINLINE PVOID GdiAllocBatchCommand(HDC hdc, USHORT Cmd)
Definition: gdi32p.h:381

Referenced by SelectClipRgn().

◆ GetClipRgn()

int WINAPI GetClipRgn ( HDC  hdc,
HRGN  hrgn 
)

Definition at line 758 of file region.c.

762 {
763  INT Ret;
764 
765  /* Check if DC handle is valid */
766  if (!GdiGetDcAttr(hdc))
767  {
768  /* Last error code differs from what NtGdiGetRandomRgn returns */
770  return -1;
771  }
772 
774 
775 // if (Ret)
776 // {
777 // if(GetLayout(hdc) & LAYOUT_RTL) MirrorRgnDC(hdc,(HRGN)Ret, NULL);
778 // }
779  return Ret;
780 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
int32_t INT
Definition: typedefs.h:57
#define CLIPRGN
Definition: precomp.h:18
#define SetLastError(x)
Definition: compat.h:418
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
__kernel_entry W32KAPI INT APIENTRY NtGdiGetRandomRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iRgn)

◆ GetMetaRgn()

int WINAPI GetMetaRgn ( HDC  hdc,
HRGN  hrgn 
)

Definition at line 787 of file region.c.

789 {
790  return NtGdiGetRandomRgn(hdc, hrgn, METARGN);
791 }
#define METARGN
Definition: GetRandomRgn.c:11
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
__kernel_entry W32KAPI INT APIENTRY NtGdiGetRandomRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iRgn)

◆ GetRegionData()

DWORD WINAPI GetRegionData ( HRGN  hrgn,
DWORD  nCount,
LPRGNDATA  lpRgnData 
)

Definition at line 799 of file region.c.

802 {
803  if (!lpRgnData)
804  {
805  nCount = 0;
806  }
807 
808  return NtGdiGetRegionData(hrgn,nCount,lpRgnData);
809 }
static HRGN hrgn
Definition: win.c:55

Referenced by GdipCreateRegionHrgn(), get_region_scans_data(), MirrorRgnByWidth(), and verify_region().

◆ GetRgnBox()

INT WINAPI GetRgnBox ( HRGN  hrgn,
LPRECT  prcOut 
)

Definition at line 817 of file region.c.

819 {
820  PRGN_ATTR Rgn_Attr;
821 
822  if (!(Rgn_Attr = GdiGetRgnAttr(hrgn)))
823  return NtGdiGetRgnBox(hrgn, prcOut);
824 
825  if (Rgn_Attr->iComplexity == NULLREGION)
826  {
827  prcOut->left = 0;
828  prcOut->top = 0;
829  prcOut->right = 0;
830  prcOut->bottom = 0;
831  }
832  else
833  {
834  if (Rgn_Attr->iComplexity != SIMPLEREGION)
835  return NtGdiGetRgnBox(hrgn, prcOut);
836  /* WARNING! prcOut is never checked newbies! */
837  RtlCopyMemory( prcOut, &Rgn_Attr->Rect, sizeof(RECT));
838  }
839  return Rgn_Attr->iComplexity;
840 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define NULLREGION
Definition: wingdi.h:360
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
_Out_ LPRECT prcOut
Definition: ntgdi.h:2801
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
INT APIENTRY NtGdiGetRgnBox(HRGN hRgn, PRECTL pRect)
Definition: region.c:3939
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:270
#define SIMPLEREGION
Definition: wingdi.h:361
RECTL Rect
Definition: ntgdihdl.h:271
LONG bottom
Definition: windef.h:309

Referenced by GdipGetRegionBounds(), and test_gethrgn().

◆ IntersectClipRect()

INT WINAPI IntersectClipRect ( _In_ HDC  hdc,
_In_ INT  nLeft,
_In_ INT  nTop,
_In_ INT  nRight,
_In_ INT  nBottom 
)

Definition at line 847 of file region.c.

853 {
854  HANDLE_METADC(INT, IntersectClipRect, ERROR, hdc, nLeft, nTop, nRight, nBottom);
855  return NtGdiIntersectClipRect(hdc, nLeft, nTop, nRight, nBottom);
856 }
__kernel_entry W32KAPI INT APIENTRY NtGdiIntersectClipRect(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: cliprgn.c:486
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:57
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
HDC hdc
Definition: main.c:9
INT WINAPI IntersectClipRect(_In_ HDC hdc, _In_ INT nLeft, _In_ INT nTop, _In_ INT nRight, _In_ INT nBottom)
Definition: region.c:847

◆ IntSetNullRgn()

FORCEINLINE ULONG IntSetNullRgn ( _Inout_ PRGN_ATTR  prgnattr)

Definition at line 157 of file region.c.

159 {
160  prgnattr->iComplexity = NULLREGION;
161  prgnattr->AttrFlags |= ATTR_RGN_DIRTY;
162  prgnattr->Rect.left = prgnattr->Rect.top = prgnattr->Rect.right = prgnattr->Rect.bottom = 0;
163  return NULLREGION;
164 }
#define NULLREGION
Definition: wingdi.h:360
#define ATTR_RGN_DIRTY
Definition: ntgdihdl.h:211

Referenced by CombineRgn(), IntSetRectRgn(), and SetRectRgn().

◆ IntSetRectRgn()

FORCEINLINE ULONG IntSetRectRgn ( _Inout_ PRGN_ATTR  prgnattr,
_In_ INT  xLeft,
_In_ INT  yTop,
_In_ INT  xRight,
_In_ INT  yBottom 
)

Definition at line 168 of file region.c.

174 {
175  ASSERT(xLeft <= xRight);
176  ASSERT(yTop <= yBottom);
177 
178  if ((xLeft == xRight) || (yTop == yBottom))
179  return IntSetNullRgn(prgnattr);
180 
181  prgnattr->iComplexity = SIMPLEREGION;
182  prgnattr->Rect.left = xLeft;
183  prgnattr->Rect.top = yTop;
184  prgnattr->Rect.right = xRight;
185  prgnattr->Rect.bottom = yBottom;
186  prgnattr->AttrFlags |= ATTR_RGN_DIRTY;
187  return SIMPLEREGION;
188 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ATTR_RGN_DIRTY
Definition: ntgdihdl.h:211
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE ULONG IntSetNullRgn(_Inout_ PRGN_ATTR prgnattr)
Definition: region.c:157

Referenced by CombineRgn(), and CreateRectRgn().

◆ MirrorRgn()

BOOL WINAPI MirrorRgn ( HWND  hwnd,
HRGN  hrgn 
)

Definition at line 863 of file region.c.

864 {
865  INT l;
866  RECT Rect;
868  l = Rect.right - Rect.left;
869  Rect.right -= Rect.left;
870  return MirrorRgnByWidth(hrgn, l, NULL);
871 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
int32_t INT
Definition: typedefs.h:57
INT FASTCALL MirrorRgnByWidth(_In_ HRGN hrgn, _In_ INT Width, _Out_opt_ HRGN *phrgn)
Definition: region.c:85
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
static HRGN hrgn
Definition: win.c:55
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
struct Rect Rect

Referenced by GetWindowRgn().

◆ MirrorRgnByWidth()

INT FASTCALL MirrorRgnByWidth ( _In_ HRGN  hrgn,
_In_ INT  Width,
_Out_opt_ HRGN *  phrgn 
)

Definition at line 85 of file region.c.

89 {
90  INT cRgnDSize, Ret = 0;
91  PRGNDATA pRgnData;
92 
93  cRgnDSize = NtGdiGetRegionData(hrgn, 0, NULL);
94 
95  if (cRgnDSize)
96  {
97  pRgnData = HeapAlloc(GetProcessHeap(), 0, cRgnDSize * sizeof(LONG));
98  if (pRgnData)
99  {
100  if ( GetRegionData(hrgn, cRgnDSize, pRgnData) )
101  {
102  HRGN hRgnex;
103  UINT i;
104  INT SaveL = pRgnData->rdh.rcBound.left;
105  pRgnData->rdh.rcBound.left = Width - pRgnData->rdh.rcBound.right;
106  pRgnData->rdh.rcBound.right = Width - SaveL;
107  if (pRgnData->rdh.nCount > 0)
108  {
109  PRECT pRect = (PRECT)&pRgnData->Buffer;
110  for (i = 0; i < pRgnData->rdh.nCount; i++)
111  {
112  SaveL = pRect[i].left;
113  pRect[i].left = Width - pRect[i].right;
114  pRect[i].right = Width - SaveL;
115  }
116  }
117  SortRects((PRECT)&pRgnData->Buffer, pRgnData->rdh.nCount);
118  hRgnex = ExtCreateRegion(NULL, cRgnDSize , pRgnData);
119  if (hRgnex)
120  {
121  if (phrgn)
122  {
123  *phrgn = hRgnex;
124  }
125  else
126  {
127  CombineRgn(hrgn, hRgnex, 0, RGN_COPY);
128  DeleteObject(hRgnex);
129  }
130  Ret = 1;
131  }
132  }
133  HeapFree( GetProcessHeap(), 0, pRgnData);
134  }
135  }
136  return Ret;
137 }
HRGN WINAPI ExtCreateRegion(CONST XFORM *lpXform, DWORD nCount, CONST RGNDATA *lpRgnData)
Definition: region.c:650
char Buffer[1]
Definition: axextend.idl:400
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
static VOID FASTCALL SortRects(PRECT pRect, INT nCount)
Definition: region.c:23
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define for
Definition: utility.h:88
static HRGN hrgn
Definition: win.c:55
#define RGN_COPY
Definition: wingdi.h:356
DWORD WINAPI GetRegionData(HRGN hrgn, DWORD nCount, LPRGNDATA lpRgnData)
Definition: region.c:799
unsigned int UINT
Definition: ndis.h:50
RGNDATAHEADER rdh
Definition: axextend.idl:399
struct tagRECT * PRECT
INT WINAPI CombineRgn(_In_ HRGN hrgnDest, _In_ HRGN hrgnSrc1, _In_ HRGN hrgnSrc2, _In_ INT iCombineMode)
Definition: region.c:195
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by MirrorRgn(), and MirrorRgnDC().

◆ MirrorRgnDC()

INT WINAPI MirrorRgnDC ( _In_ HDC  hdc,
_In_ HRGN  hrgn,
_Out_opt_ HRGN *  phrn 
)

Definition at line 141 of file region.c.

145 {
146  if (!GdiValidateHandle((HGDIOBJ) hdc) ||
148  return 0;
149 
151 }
INT FASTCALL MirrorRgnByWidth(_In_ HRGN hrgn, _In_ INT Width, _Out_opt_ HRGN *phrgn)
Definition: region.c:85
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
__kernel_entry W32KAPI LONG APIENTRY NtGdiGetDeviceWidth(_In_ HDC hdc)
BOOL WINAPI GdiValidateHandle(HGDIOBJ)
Definition: misc.c:712

Referenced by ExtSelectClipRgn().

◆ OffsetClipRgn()

INT WINAPI OffsetClipRgn ( HDC  hdc,
INT  nXOffset,
INT  nYOffset 
)

Definition at line 878 of file region.c.

882 {
883  HANDLE_METADC(INT, OffsetClipRgn, ERROR, hdc, nXOffset, nYOffset);
884  return NtGdiOffsetClipRgn(hdc, nXOffset, nYOffset);
885 }
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:57
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
HDC hdc
Definition: main.c:9
INT WINAPI OffsetClipRgn(HDC hdc, INT nXOffset, INT nYOffset)
Definition: region.c:878
__kernel_entry W32KAPI INT APIENTRY NtGdiOffsetClipRgn(_In_ HDC hdc, _In_ INT x, _In_ INT y)
Definition: cliprgn.c:537

◆ OffsetRgn()

INT WINAPI OffsetRgn ( HRGN  hrgn,
int  nXOffset,
int  nYOffset 
)

Definition at line 893 of file region.c.

896 {
897  PRGN_ATTR pRgn_Attr;
898  RECTL rc;
899 
900  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)))
901  return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset);
902 
903  if ( pRgn_Attr->iComplexity == NULLREGION)
904  return pRgn_Attr->iComplexity;
905 
906  if ( pRgn_Attr->iComplexity != SIMPLEREGION)
907  return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset);
908 
909  rc = pRgn_Attr->Rect;
910 
911  if (rc.left < rc.right)
912  {
913  if (rc.top < rc.bottom)
914  {
915  rc.left += nXOffset;
916  rc.top += nYOffset;
917  rc.right += nXOffset;
918  rc.bottom += nYOffset;
919 
920  /* Make sure the offset is within the legal range */
921  if ( (rc.left & MIN_COORD && ((rc.left & MIN_COORD) != MIN_COORD)) ||
922  (rc.top & MIN_COORD && ((rc.top & MIN_COORD) != MIN_COORD)) ||
923  (rc.right & MIN_COORD && ((rc.right & MIN_COORD) != MIN_COORD)) ||
924  (rc.bottom & MIN_COORD && ((rc.bottom & MIN_COORD) != MIN_COORD)) )
925  {
926  DPRINT("OffsetRgn ERROR\n");
927  return ERROR;
928  }
929 
930  pRgn_Attr->Rect = rc;
931  pRgn_Attr->AttrFlags |= ATTR_RGN_DIRTY;
932  }
933  }
934  return pRgn_Attr->iComplexity;
935 }
#define ERROR(name)
Definition: error_private.h:53
#define NULLREGION
Definition: wingdi.h:360
long bottom
Definition: polytest.cpp:53
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
void DPRINT(...)
Definition: polytest.cpp:61
ULONG AttrFlags
Definition: ntgdihdl.h:269
long left
Definition: polytest.cpp:53
#define ATTR_RGN_DIRTY
Definition: ntgdihdl.h:211
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:270
#define SIMPLEREGION
Definition: wingdi.h:361
INT APIENTRY NtGdiOffsetRgn(_In_ HRGN hrgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:3981
RECTL Rect
Definition: ntgdihdl.h:271
#define MIN_COORD
Definition: region.c:11

◆ PtInRegion()

BOOL WINAPI PtInRegion ( IN HRGN  hrgn,
int  x,
int  y 
)

Definition at line 942 of file region.c.

945 {
946  PRGN_ATTR pRgn_Attr;
947 
948  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)))
949  return NtGdiPtInRegion(hrgn,x,y);
950 
951  if ( pRgn_Attr->iComplexity == NULLREGION)
952  return FALSE;
953 
954  if ( pRgn_Attr->iComplexity != SIMPLEREGION)
955  return NtGdiPtInRegion(hrgn,x,y);
956 
957  return INRECT( pRgn_Attr->Rect, x, y);
958 }
#define NULLREGION
Definition: wingdi.h:360
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:270
#define SIMPLEREGION
Definition: wingdi.h:361
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
RECTL Rect
Definition: ntgdihdl.h:271
#define INRECT(r, x, y)
Definition: region.c:14
BOOL APIENTRY NtGdiPtInRegion(_In_ HRGN hrgn, _In_ INT x, _In_ INT y)
Definition: region.c:4016

Referenced by GdipIsVisibleRegionPoint().

◆ RectInRegion()

BOOL WINAPI RectInRegion ( HRGN  hrgn,
LPCRECT  prcl 
)

Definition at line 965 of file region.c.

967 {
968  PRGN_ATTR pRgn_Attr;
969  RECTL rc;
970 
971  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)))
972  return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
973 
974  if ( pRgn_Attr->iComplexity == NULLREGION)
975  return FALSE;
976 
977  if ( pRgn_Attr->iComplexity != SIMPLEREGION)
978  return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
979 
980  /* swap the coordinates to make right >= left and bottom >= top */
981  /* (region building rectangles are normalized the same way) */
982  if ( prcl->top > prcl->bottom)
983  {
984  rc.top = prcl->bottom;
985  rc.bottom = prcl->top;
986  }
987  else
988  {
989  rc.top = prcl->top;
990  rc.bottom = prcl->bottom;
991  }
992  if ( prcl->right < prcl->left)
993  {
994  rc.right = prcl->left;
995  rc.left = prcl->right;
996  }
997  else
998  {
999  rc.right = prcl->right;
1000  rc.left = prcl->left;
1001  }
1002 
1003  if ( ( pRgn_Attr->Rect.left >= rc.right ) ||
1004  ( pRgn_Attr->Rect.right <= rc.left ) ||
1005  ( pRgn_Attr->Rect.top >= rc.bottom ) ||
1006  ( pRgn_Attr->Rect.bottom <= rc.top ) )
1007  {
1008  return FALSE;
1009  }
1010 
1011  return TRUE;
1012 }
#define TRUE
Definition: types.h:120
#define NULLREGION
Definition: wingdi.h:360
long bottom
Definition: polytest.cpp:53
__kernel_entry BOOL APIENTRY NtGdiRectInRegion(_In_ HRGN hrgn, _Inout_ LPRECT prclUnsafe)
Definition: region.c:4043
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:270
#define SIMPLEREGION
Definition: wingdi.h:361
RECTL Rect
Definition: ntgdihdl.h:271
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3529

Referenced by GdipIsVisibleRegionRect().

◆ SelectClipRgn()

int WINAPI SelectClipRgn ( _In_ HDC  hdc,
_In_ HRGN  hrgn 
)

Definition at line 1019 of file region.c.

1022 {
1023  return ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
1024 }
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
#define RGN_COPY
Definition: wingdi.h:356
INT WINAPI ExtSelectClipRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iMode)
Definition: region.c:674

◆ SetMetaRgn()

int WINAPI SetMetaRgn ( HDC  hDC)

Definition at line 1087 of file region.c.

1088 {
1090  return NtGdiSetMetaRgn(hDC);
1091 #if 0
1092  PLDC pLDC = GdiGetLDC(hDC);
1094  {
1095  if (pLDC->iType == LDC_EMFLDC || EMFDRV_SetMetaRgn(hDC))
1096  {
1097  return NtGdiSetMetaRgn(hDC);
1098  }
1099  else
1101  }
1102 #endif
1103  return ERROR;
1104 }
#define ERROR(name)
Definition: error_private.h:53
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
__kernel_entry W32KAPI INT APIENTRY NtGdiSetMetaRgn(_In_ HDC hdc)
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
PLDC FASTCALL GdiGetLDC(HDC hDC)
Definition: misc.c:785
#define SetLastError(x)
Definition: compat.h:418
#define GDI_OBJECT_TYPE_METADC
Definition: gdi.h:57
Definition: ntgdihdl.h:275
INT iType
Definition: ntgdihdl.h:279
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
static HDC hDC
Definition: 3dtext.c:33
#define LDC_EMFLDC
Definition: gdi_private.h:57

◆ SetRectRgn()

BOOL WINAPI SetRectRgn ( _In_ HRGN  hrgn,
_In_ INT  xLeft,
_In_ INT  yTop,
_In_ INT  xRight,
_In_ INT  yBottom 
)

Definition at line 1031 of file region.c.

1037 {
1038  PRGN_ATTR prngattr;
1039 
1040  /* Try to get the region attribute */
1041  prngattr = GdiGetRgnAttr(hrgn);
1042  if (prngattr == NULL)
1043  {
1044  return NtGdiSetRectRgn(hrgn, xLeft, yTop, xRight, yBottom);
1045  }
1046 
1047  /* check for NULL region */
1048  if ((xLeft == xRight) || (yTop == yBottom))
1049  {
1050  IntSetNullRgn(prngattr);
1051  return TRUE;
1052  }
1053 
1054  if (xLeft > xRight)
1055  {
1056  prngattr->Rect.left = xRight;
1057  prngattr->Rect.right = xLeft;
1058  }
1059  else
1060  {
1061  prngattr->Rect.left = xLeft;
1062  prngattr->Rect.right = xRight;
1063  }
1064 
1065  if (yTop > yBottom)
1066  {
1067  prngattr->Rect.top = yBottom;
1068  prngattr->Rect.bottom = yTop;
1069  }
1070  else
1071  {
1072  prngattr->Rect.top = yTop;
1073  prngattr->Rect.bottom = yBottom;
1074  }
1075 
1076  prngattr->AttrFlags |= ATTR_RGN_DIRTY ;
1077  prngattr->iComplexity = SIMPLEREGION;
1078 
1079  return TRUE;
1080 }
#define TRUE
Definition: types.h:120
long bottom
Definition: polytest.cpp:53
FORCEINLINE PRGN_ATTR GdiGetRgnAttr(HRGN hrgn)
Definition: gdi32p.h:475
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:416
ULONG AttrFlags
Definition: ntgdihdl.h:269
long left
Definition: polytest.cpp:53
#define ATTR_RGN_DIRTY
Definition: ntgdihdl.h:211
static HRGN hrgn
Definition: win.c:55
BOOL APIENTRY NtGdiSetRectRgn(_In_ HRGN hrgn, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: region.c:4068
ULONG iComplexity
Definition: ntgdihdl.h:270
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE ULONG IntSetNullRgn(_Inout_ PRGN_ATTR prgnattr)
Definition: region.c:157
RECTL Rect
Definition: ntgdihdl.h:271

◆ SortRects()

static VOID FASTCALL SortRects ( PRECT  pRect,
INT  nCount 
)
static

Definition at line 23 of file region.c.

24 {
25  INT i, a, b, c, s;
26  RECT sRect;
27 
28  if (nCount > 0)
29  {
30  i = 1; // set index point
31  c = nCount; // set inverse count
32  do
33  {
34  s = i; // set sort count
35  if ( i < nCount )
36  {
37  a = i - 1; // [0]
38  b = i; // [1]
39  do
40  {
41  if ( pRect[a].top != pRect[b].top ) break;
42  if ( pRect[a].left > pRect[b].left )
43  {
44  sRect = pRect[a];
45  pRect[a] = pRect[b];
46  pRect[b] = sRect;
47  }
48  ++s;
49  b++;
50  }
51  while ( s < nCount );
52  }
53  ++i;
54  }
55  while ( c-- != 1 );
56  }
57 }
int32_t INT
Definition: typedefs.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
const GLubyte * c
Definition: glext.h:8905
GLint left
Definition: glext.h:7726
GLdouble s
Definition: gl.h:2039
#define c
Definition: ke_i.h:80
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by MirrorRgnByWidth().