ReactOS  0.4.13-dev-73-gcfe54aa
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, _In_ HRGN *phrgn)
 
INT WINAPI MirrorRgnDC (_In_ HDC hdc, _In_ HRGN hrgn, _In_ 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 194 of file region.c.

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

Referenced by get_region_hrgn(), and MirrorRgnByWidth().

◆ CreateEllipticRgnIndirect()

HRGN WINAPI CreateEllipticRgnIndirect ( const RECT prc)

Definition at line 519 of file region.c.

522 {
523  /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
525 
526 }
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
LONG bottom
Definition: windef.h:294
_Out_ LPRECT prc
Definition: ntgdi.h:1658
HRGN APIENTRY NtGdiCreateEllipticRgn(INT Left, INT Top, INT Right, INT Bottom)
Definition: region.c:3593

◆ CreatePolygonRgn()

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

Definition at line 533 of file region.c.

534 {
535  return (HRGN) NtGdiPolyPolyDraw( (HDC)UlongToHandle(fnPolyFillMode), (PPOINT) lppt, (PULONG) &cPoints, 1, GdiPolyPolyRgn);
536 }
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 543 of file region.c.

547 {
548  return (HRGN) NtGdiPolyPolyDraw( (HDC)UlongToHandle(fnPolyFillMode), (PPOINT) lppt, (PULONG) lpPolyCounts, (ULONG) nCount, GdiPolyPolyRgn );
549 }
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 556 of file region.c.

557 {
558  PRGN_ATTR pRgn_Attr;
559  HRGN hrgn = NULL;
560  int tmp;
561 
562  /* Normalize points, REGION_SetRectRgn does this too. */
563  if ( x1 > x2 )
564  {
565  tmp = x1;
566  x1 = x2;
567  x2 = tmp;
568  }
569 
570  if ( y1 > y2 )
571  {
572  tmp = y1;
573  y1 = y2;
574  y2 = tmp;
575  }
576  /* Check outside 28 bit limit for universal set bound box. REGION_SetRectRgn doesn't do this! */
577  if ( x1 < MIN_COORD ||
578  y1 < MIN_COORD ||
579  x2 > MAX_COORD ||
580  y2 > MAX_COORD )
581  {
583  return NULL;
584  }
585 
587  if (hrgn)
588  {
589  DPRINT1("PEB Handle Cache Test return hrgn %p, should be NULL!\n",hrgn);
590  hrgn = NULL;
591  }
592 
593  if (!hrgn)
594  hrgn = NtGdiCreateRectRgn(0, 0, 1, 1);
595 
596  if (!hrgn)
597  return hrgn;
598 
599  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)) )
600  {
601  DPRINT1("No Attr for Region handle!!!\n");
603  return NULL;
604  }
605 
606  pRgn_Attr->AttrFlags = ATTR_RGN_VALID;
607 
608  IntSetRectRgn( pRgn_Attr, x1, y1, x2, y2 );
609 
610  return hrgn;
611 }
_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:3608
#define MAX_COORD
Definition: region.c:12
#define ATTR_RGN_VALID
Definition: ntgdihdl.h:206
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:167
ULONG AttrFlags
Definition: ntgdihdl.h:265
#define SetLastError(x)
Definition: compat.h:409
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 618 of file region.c.

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

◆ DeleteRegion()

BOOL FASTCALL DeleteRegion ( _In_ HRGN  hrgn)

Definition at line 64 of file region.c.

66 {
67 #if 0
68  PRGN_ATTR Rgn_Attr = GdiGetRgnAttr(hrgn);
69 
70  if ( Rgn_Attr )
71  {
72  PGDIBSOBJECT pgO;
73 
75  if (pgO)
76  {
77  pgO->hgdiobj = hrgn;
78  return TRUE;
79  }
80  }
81 #endif
82  return NtGdiDeleteObjectApp(hrgn);
83 }
#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:554
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 632 of file region.c.

638 {
639  HANDLE_METADC(INT, ExcludeClipRect, ERROR, hdc, xLeft, yTop, xRight, yBottom);
640 
641  return NtGdiExcludeClipRect(hdc, xLeft, yTop, xRight, yBottom);
642 }
#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:223
int32_t INT
Definition: typedefs.h:56
#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:632
HDC hdc
Definition: main.c:9

◆ ExtCreateRegion()

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

Definition at line 649 of file region.c.

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

Referenced by MirrorRgnByWidth().

◆ ExtSelectClipRgn()

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

Definition at line 673 of file region.c.

677 {
678  INT Ret;
679  HRGN NewRgn = NULL;
680 
682 
683 #if 0
684  if ( hrgn )
685  {
686  if ( GetLayout(hdc) & LAYOUT_RTL )
687  {
688  if ( MirrorRgnDC(hdc, hrgn, &NewRgn) )
689  {
690  if ( NewRgn ) hrgn = NewRgn;
691  }
692  }
693  }
694 #endif
695  /* Batch handles RGN_COPY only! */
696  if (iMode == RGN_COPY)
697  {
698  PDC_ATTR pdcattr;
699  PRGN_ATTR pRgn_Attr = NULL;
700 
701  /* Get the DC attribute */
702  pdcattr = GdiGetDcAttr(hdc);
703  if ( pdcattr )
704  {
706 
707  /* hrgn can be NULL unless the RGN_COPY mode is specified. */
708  if (hrgn) pRgn_Attr = GdiGetRgnAttr(hrgn);
709 
710  if ( !(pdcattr->ulDirty_ & DC_DIBSECTION) &&
711  !(pEntry->Flags & GDI_ENTRY_VALIDATE_VIS) )
712  {
713  if (!hrgn || (hrgn && pRgn_Attr && pRgn_Attr->iComplexity <= SIMPLEREGION) )
714  {
716  if (pgO)
717  {
718  pgO->fnMode = iMode;
719 
720  if ( hrgn && pRgn_Attr )
721  {
722  Ret = pRgn_Attr->iComplexity;
723  // Note from ntgdi/dcstate.c : "The VisRectRegion field needs to be set to a valid state."
724  if ( pdcattr->VisRectRegion.Rect.left >= pRgn_Attr->Rect.right ||
725  pdcattr->VisRectRegion.Rect.top >= pRgn_Attr->Rect.bottom ||
726  pdcattr->VisRectRegion.Rect.right <= pRgn_Attr->Rect.left ||
727  pdcattr->VisRectRegion.Rect.bottom <= pRgn_Attr->Rect.top )
728  Ret = NULLREGION;
729 
730  // Pass the rect since this region will go away.
731  pgO->rcl = pRgn_Attr->Rect;
732  }
733  else
734  {
735  Ret = pdcattr->VisRectRegion.iComplexity;
736  pgO->fnMode |= GDIBS_NORECT; // Set no hrgn mode.
737  }
738  if ( NewRgn ) DeleteObject(NewRgn);
739  return Ret;
740  }
741  }
742  }
743  }
744  }
746 
747  if ( NewRgn ) DeleteObject(NewRgn);
748 
749  return Ret;
750 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
#define LAYOUT_RTL
Definition: wingdi.h:1353
_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:56
#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
INT WINAPI MirrorRgnDC(_In_ HDC hdc, _In_ HRGN hrgn, _In_ HRGN *phrn)
Definition: region.c:140
long left
Definition: polytest.cpp:53
ULONG ulDirty_
Definition: ntgdihdl.h:291
#define GdiHandleTable
Definition: win32nt.h:36
#define GDIBS_NORECT
Definition: ntgdityp.h:501
HDC hdc
Definition: main.c:9
RGN_ATTR VisRectRegion
Definition: ntgdihdl.h:347
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:266
#define RGN_COPY
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:361
Definition: gdi.h:1
UCHAR Flags
Definition: ntgdihdl.h:221
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:735
#define GDI_ENTRY_VALIDATE_VIS
Definition: ntgdihdl.h:40
INT WINAPI ExtSelectClipRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iMode)
Definition: region.c:673
RECTL Rect
Definition: ntgdihdl.h:267
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 757 of file region.c.

761 {
762  INT Ret;
763 
764  /* Check if DC handle is valid */
765  if (!GdiGetDcAttr(hdc))
766  {
767  /* Last error code differs from what NtGdiGetRandomRgn returns */
769  return -1;
770  }
771 
773 
774 // if (Ret)
775 // {
776 // if(GetLayout(hdc) & LAYOUT_RTL) MirrorRgnDC(hdc,(HRGN)Ret, NULL);
777 // }
778  return Ret;
779 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
int32_t INT
Definition: typedefs.h:56
#define CLIPRGN
Definition: precomp.h:18
#define SetLastError(x)
Definition: compat.h:409
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 786 of file region.c.

788 {
789  return NtGdiGetRandomRgn(hdc, hrgn, METARGN);
790 }
#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 798 of file region.c.

801 {
802  if (!lpRgnData)
803  {
804  nCount = 0;
805  }
806 
807  return NtGdiGetRegionData(hrgn,nCount,lpRgnData);
808 }
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 816 of file region.c.

818 {
819  PRGN_ATTR Rgn_Attr;
820 
821  if (!(Rgn_Attr = GdiGetRgnAttr(hrgn)))
822  return NtGdiGetRgnBox(hrgn, prcOut);
823 
824  if (Rgn_Attr->iComplexity == NULLREGION)
825  {
826  prcOut->left = 0;
827  prcOut->top = 0;
828  prcOut->right = 0;
829  prcOut->bottom = 0;
830  }
831  else
832  {
833  if (Rgn_Attr->iComplexity != SIMPLEREGION)
834  return NtGdiGetRgnBox(hrgn, prcOut);
835  /* WARNING! prcOut is never checked newbies! */
836  RtlCopyMemory( prcOut, &Rgn_Attr->Rect, sizeof(RECT));
837  }
838  return Rgn_Attr->iComplexity;
839 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define NULLREGION
Definition: wingdi.h:360
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
_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:3942
static HRGN hrgn
Definition: win.c:55
ULONG iComplexity
Definition: ntgdihdl.h:266
#define SIMPLEREGION
Definition: wingdi.h:361
RECTL Rect
Definition: ntgdihdl.h:267
LONG bottom
Definition: windef.h:294

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 846 of file region.c.

852 {
853  HANDLE_METADC(INT, IntersectClipRect, ERROR, hdc, nLeft, nTop, nRight, nBottom);
854  return NtGdiIntersectClipRect(hdc, nLeft, nTop, nRight, nBottom);
855 }
__kernel_entry W32KAPI INT APIENTRY NtGdiIntersectClipRect(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: cliprgn.c:291
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:56
#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:846

◆ IntSetNullRgn()

FORCEINLINE ULONG IntSetNullRgn ( _Inout_ PRGN_ATTR  prgnattr)

Definition at line 156 of file region.c.

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

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 167 of file region.c.

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

Referenced by CombineRgn(), and CreateRectRgn().

◆ MirrorRgn()

BOOL WINAPI MirrorRgn ( HWND  hwnd,
HRGN  hrgn 
)

Definition at line 862 of file region.c.

863 {
864  INT l;
865  RECT Rect;
867  l = Rect.right - Rect.left;
868  Rect.right -= Rect.left;
869  return MirrorRgnByWidth(hrgn, l, NULL);
870 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
int32_t INT
Definition: typedefs.h:56
INT FASTCALL MirrorRgnByWidth(_In_ HRGN hrgn, _In_ INT Width, _In_ HRGN *phrgn)
Definition: region.c:87
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,
_In_ HRGN *  phrgn 
)

Definition at line 87 of file region.c.

91 {
92  INT cRgnDSize, Ret = 0;
93  PRGNDATA pRgnData;
94 
95  cRgnDSize = NtGdiGetRegionData(hrgn, 0, NULL);
96 
97  if (cRgnDSize)
98  {
99  pRgnData = HeapAlloc(GetProcessHeap(), 0, cRgnDSize * sizeof(LONG));
100  if (pRgnData)
101  {
102  if ( GetRegionData(hrgn, cRgnDSize, pRgnData) )
103  {
104  HRGN hRgnex;
105  UINT i;
106  INT SaveL = pRgnData->rdh.rcBound.left;
107  pRgnData->rdh.rcBound.left = Width - pRgnData->rdh.rcBound.right;
108  pRgnData->rdh.rcBound.right = Width - SaveL;
109  if (pRgnData->rdh.nCount > 0)
110  {
111  PRECT pRect = (PRECT)&pRgnData->Buffer;
112  for (i = 0; i < pRgnData->rdh.nCount; i++)
113  {
114  SaveL = pRect[i].left;
115  pRect[i].left = Width - pRect[i].right;
116  pRect[i].right = Width - SaveL;
117  }
118  }
119  SortRects((PRECT)&pRgnData->Buffer, pRgnData->rdh.nCount);
120  hRgnex = ExtCreateRegion(NULL, cRgnDSize , pRgnData);
121  if (hRgnex)
122  {
123  if (phrgn) phrgn = (HRGN *)hRgnex;
124  else
125  {
126  CombineRgn(hrgn, hRgnex, 0, RGN_COPY);
127  DeleteObject(hRgnex);
128  }
129  Ret = 1;
130  }
131  }
132  HeapFree( GetProcessHeap(), 0, pRgnData);
133  }
134  }
135  return Ret;
136 }
HRGN WINAPI ExtCreateRegion(CONST XFORM *lpXform, DWORD nCount, CONST RGNDATA *lpRgnData)
Definition: region.c:649
char Buffer[1]
Definition: axextend.idl:395
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
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:395
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:798
unsigned int UINT
Definition: ndis.h:50
RGNDATAHEADER rdh
Definition: axextend.idl:394
struct tagRECT * PRECT
INT WINAPI CombineRgn(_In_ HRGN hrgnDest, _In_ HRGN hrgnSrc1, _In_ HRGN hrgnSrc2, _In_ INT iCombineMode)
Definition: region.c:194
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by MirrorRgn(), and MirrorRgnDC().

◆ MirrorRgnDC()

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

Definition at line 140 of file region.c.

144 {
145  if (!GdiValidateHandle((HGDIOBJ) hdc) ||
147  return 0;
148 
150 }
INT FASTCALL MirrorRgnByWidth(_In_ HRGN hrgn, _In_ INT Width, _In_ HRGN *phrgn)
Definition: region.c:87
#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 877 of file region.c.

881 {
882  HANDLE_METADC(INT, OffsetClipRgn, ERROR, hdc, nXOffset, nYOffset);
883  return NtGdiOffsetClipRgn(hdc, nXOffset, nYOffset);
884 }
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:56
#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:877
__kernel_entry W32KAPI INT APIENTRY NtGdiOffsetClipRgn(_In_ HDC hdc, _In_ INT x, _In_ INT y)
Definition: cliprgn.c:357

◆ OffsetRgn()

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

Definition at line 892 of file region.c.

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

◆ PtInRegion()

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

Definition at line 941 of file region.c.

944 {
945  PRGN_ATTR pRgn_Attr;
946 
947  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)))
948  return NtGdiPtInRegion(hrgn,x,y);
949 
950  if ( pRgn_Attr->iComplexity == NULLREGION)
951  return FALSE;
952 
953  if ( pRgn_Attr->iComplexity != SIMPLEREGION)
954  return NtGdiPtInRegion(hrgn,x,y);
955 
956  return INRECT( pRgn_Attr->Rect, x, y);
957 }
#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:266
#define SIMPLEREGION
Definition: wingdi.h:361
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
RECTL Rect
Definition: ntgdihdl.h:267
#define INRECT(r, x, y)
Definition: region.c:14
BOOL APIENTRY NtGdiPtInRegion(_In_ HRGN hrgn, _In_ INT x, _In_ INT y)
Definition: region.c:4019

Referenced by GdipIsVisibleRegionPoint().

◆ RectInRegion()

BOOL WINAPI RectInRegion ( HRGN  hrgn,
LPCRECT  prcl 
)

Definition at line 964 of file region.c.

966 {
967  PRGN_ATTR pRgn_Attr;
968  RECTL rc;
969 
970  if (!(pRgn_Attr = GdiGetRgnAttr(hrgn)))
971  return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
972 
973  if ( pRgn_Attr->iComplexity == NULLREGION)
974  return FALSE;
975 
976  if ( pRgn_Attr->iComplexity != SIMPLEREGION)
977  return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
978 
979  /* swap the coordinates to make right >= left and bottom >= top */
980  /* (region building rectangles are normalized the same way) */
981  if ( prcl->top > prcl->bottom)
982  {
983  rc.top = prcl->bottom;
984  rc.bottom = prcl->top;
985  }
986  else
987  {
988  rc.top = prcl->top;
989  rc.bottom = prcl->bottom;
990  }
991  if ( prcl->right < prcl->left)
992  {
993  rc.right = prcl->left;
994  rc.left = prcl->right;
995  }
996  else
997  {
998  rc.right = prcl->right;
999  rc.left = prcl->left;
1000  }
1001 
1002  if ( ( pRgn_Attr->Rect.left >= rc.right ) ||
1003  ( pRgn_Attr->Rect.right <= rc.left ) ||
1004  ( pRgn_Attr->Rect.top >= rc.bottom ) ||
1005  ( pRgn_Attr->Rect.bottom <= rc.top ) )
1006  {
1007  return FALSE;
1008  }
1009 
1010  return TRUE;
1011 }
#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:4046
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:266
#define SIMPLEREGION
Definition: wingdi.h:361
RECTL Rect
Definition: ntgdihdl.h:267
_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 1018 of file region.c.

1021 {
1022  return ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
1023 }
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:673

◆ SetMetaRgn()

int WINAPI SetMetaRgn ( HDC  hDC)

Definition at line 1086 of file region.c.

1087 {
1089  return NtGdiSetMetaRgn(hDC);
1090 #if 0
1091  PLDC pLDC = GdiGetLDC(hDC);
1093  {
1094  if (pLDC->iType == LDC_EMFLDC || EMFDRV_SetMetaRgn(hDC))
1095  {
1096  return NtGdiSetMetaRgn(hDC);
1097  }
1098  else
1100  }
1101 #endif
1102  return ERROR;
1103 }
#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 LDC_EMFLDC
Definition: ntgdihdl.h:171
#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:409
#define GDI_OBJECT_TYPE_METADC
Definition: gdi.h:57
Definition: ntgdihdl.h:271
INT iType
Definition: ntgdihdl.h:275
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
static HDC hDC
Definition: 3dtext.c:33

◆ SetRectRgn()

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

Definition at line 1030 of file region.c.

1036 {
1037  PRGN_ATTR prngattr;
1038 
1039  /* Try to get the region attribute */
1040  prngattr = GdiGetRgnAttr(hrgn);
1041  if (prngattr == NULL)
1042  {
1043  return NtGdiSetRectRgn(hrgn, xLeft, yTop, xRight, yBottom);
1044  }
1045 
1046  /* check for NULL region */
1047  if ((xLeft == xRight) || (yTop == yBottom))
1048  {
1049  IntSetNullRgn(prngattr);
1050  return TRUE;
1051  }
1052 
1053  if (xLeft > xRight)
1054  {
1055  prngattr->Rect.left = xRight;
1056  prngattr->Rect.right = xLeft;
1057  }
1058  else
1059  {
1060  prngattr->Rect.left = xLeft;
1061  prngattr->Rect.right = xRight;
1062  }
1063 
1064  if (yTop > yBottom)
1065  {
1066  prngattr->Rect.top = yBottom;
1067  prngattr->Rect.bottom = yTop;
1068  }
1069  else
1070  {
1071  prngattr->Rect.top = yTop;
1072  prngattr->Rect.bottom = yBottom;
1073  }
1074 
1075  prngattr->AttrFlags |= ATTR_RGN_DIRTY ;
1076  prngattr->iComplexity = SIMPLEREGION;
1077 
1078  return TRUE;
1079 }
#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:265
long left
Definition: polytest.cpp:53
#define ATTR_RGN_DIRTY
Definition: ntgdihdl.h:207
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:4071
ULONG iComplexity
Definition: ntgdihdl.h:266
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE ULONG IntSetNullRgn(_Inout_ PRGN_ATTR prgnattr)
Definition: region.c:156
RECTL Rect
Definition: ntgdihdl.h:267

◆ 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:56
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().