ReactOS  0.4.14-dev-41-g31d7680
cliprgn.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for cliprgn.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID FASTCALL IntGdiReleaseRaoRgn (PDC pDC)
 
VOID FASTCALL IntGdiReleaseVisRgn (PDC pDC)
 
VOID FASTCALL UpdateVisRgn (PDC pdc)
 
VOID FASTCALL GdiSelectVisRgn (HDC hdc, PREGION prgn)
 
 _Success_ (return!=ERROR)
 
int APIENTRY NtGdiExtSelectClipRgn (HDC hDC, HRGN hrgn, int fnMode)
 
INT APIENTRY NtGdiExcludeClipRect (_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
 
INT APIENTRY NtGdiIntersectClipRect (_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
 
INT APIENTRY NtGdiOffsetClipRgn (_In_ HDC hdc, _In_ INT xOffset, _In_ INT yOffset)
 
BOOL APIENTRY NtGdiPtVisible (HDC hDC, int X, int Y)
 
BOOL APIENTRY NtGdiRectVisible (HDC hDC, LPRECT UnsafeRect)
 
int FASTCALL IntGdiSetMetaRgn (PDC pDC)
 
int APIENTRY NtGdiSetMetaRgn (HDC hDC)
 
VOID FASTCALL CLIPPING_UpdateGCRegion (PDC pDC)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file cliprgn.c.

Function Documentation

◆ _Success_()

_Success_ ( return!  = ERROR)

Definition at line 89 of file cliprgn.c.

96 {
97  int Ret = ERROR;
98  PREGION prgnNClip, prgnOrigClip = dc->dclevel.prgnClip;
99 
100  //
101  // No Coping Regions and no intersecting Regions or an User calling w NULL Region or have the Original Clip Region.
102  //
103  if (fnMode != RGN_COPY && (fnMode != RGN_AND || !prgn || prgnOrigClip))
104  {
105  prgnNClip = IntSysCreateRectpRgn(0, 0, 0, 0);
106 
107  // Have Original Clip Region.
108  if (prgnOrigClip)
109  {
110  // This will fail on NULL prgn.
111  Ret = IntGdiCombineRgn(prgnNClip, prgnOrigClip, prgn, fnMode);
112 
113  if (Ret)
114  {
115  REGION_Delete(prgnOrigClip);
116  dc->dclevel.prgnClip = prgnNClip;
118  }
119  else
120  REGION_Delete(prgnNClip);
121  }
122  else // NULL Original Clip Region, setup a new one and process mode.
123  {
124  PREGION prgnClip;
125  RECTL rcl;
127 
128  // See IntSetDefaultRegion.
129 
130  rcl.left = 0;
131  rcl.top = 0;
132  rcl.right = dc->dclevel.sizl.cx;
133  rcl.bottom = dc->dclevel.sizl.cy;
134 
135  //EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
136  if (dc->ppdev->flFlags & PDEV_META_DEVICE)
137  {
138  pSurface = dc->dclevel.pSurface;
139  if (pSurface && pSurface->flags & PDEV_SURFACE)
140  {
141  rcl.left += dc->ppdev->ptlOrigion.x;
142  rcl.top += dc->ppdev->ptlOrigion.y;
143  rcl.right += dc->ppdev->ptlOrigion.x;
144  rcl.bottom += dc->ppdev->ptlOrigion.y;
145  }
146  }
147  //EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
148 
149  rcl.left += dc->ptlDCOrig.x;
150  rcl.top += dc->ptlDCOrig.y;
151  rcl.right += dc->ptlDCOrig.x;
152  rcl.bottom += dc->ptlDCOrig.y;
153 
154  prgnClip = IntSysCreateRectpRgnIndirect(&rcl);
155 
156  Ret = IntGdiCombineRgn(prgnNClip, prgnClip, prgn, fnMode);
157 
158  if (Ret)
159  {
160  dc->dclevel.prgnClip = prgnNClip;
162  }
163  else
164  REGION_Delete(prgnNClip);
165 
166  REGION_Delete(prgnClip);
167  }
168  return Ret;
169  }
170 
171  // Fall through to normal RectOS mode.
172 
173  //
174  // Handle NULL Region and Original Clip Region.
175  //
176  if (!prgn)
177  {
178  if (prgnOrigClip)
179  {
180  REGION_Delete(dc->dclevel.prgnClip);
181  dc->dclevel.prgnClip = NULL;
183  }
184  return SIMPLEREGION;
185  }
186 
187  //
188  // Combine the new Clip region with original Clip and caller Region.
189  //
190  if ( prgnOrigClip &&
191  (Ret = IntGdiCombineRgn(prgnOrigClip, prgn, NULL, RGN_COPY)) ) // Clip could fail.
192  {
194  }
195  else // NULL original Clip, just copy caller region to new.
196  {
197  prgnNClip = IntSysCreateRectpRgn(0, 0, 0, 0);
198  REGION_bCopy(prgnNClip, prgn);
199  Ret = REGION_Complexity(prgnNClip);
200  dc->dclevel.prgnClip = prgnNClip;
202  }
203  return Ret;
204 }
#define ERROR(name)
Definition: error_private.h:53
long bottom
Definition: polytest.cpp:53
HDC dc
Definition: cylfrac.c:34
#define RGN_AND
Definition: wingdi.h:355
VOID FASTCALL IntGdiReleaseRaoRgn(PDC pDC)
Definition: cliprgn.c:16
long right
Definition: polytest.cpp:53
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2426
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
long left
Definition: polytest.cpp:53
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2506
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
BOOL FASTCALL REGION_bCopy(PREGION, PREGION)
Definition: region.c:1844
#define RGN_COPY
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:361
INT FASTCALL REGION_Complexity(PREGION prgn)
Definition: region.c:567
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2468

◆ CLIPPING_UpdateGCRegion()

VOID FASTCALL CLIPPING_UpdateGCRegion ( PDC  pDC)

Definition at line 771 of file cliprgn.c.

772 {
773  // Moved from Release Rao. Though it still gets over written.
774  RECTL_vSetEmptyRect(&pDC->erclClip);
775 
776  /* Must have VisRgn set to a valid state! */
777  ASSERT (pDC->prgnVis);
778 #if 0 // (w2k3) This works with limitations. (w7u) ReactOS relies on Rao.
779  if ( !pDC->dclevel.prgnClip &&
780  !pDC->dclevel.prgnMeta &&
781  !pDC->prgnAPI)
782  {
783  if (pDC->prgnRao)
784  REGION_Delete(pDC->prgnRao);
785  pDC->prgnRao = NULL;
786 
787  REGION_bOffsetRgn(pDC->prgnVis, pDC->ptlDCOrig.x, pDC->ptlDCOrig.y);
788 
789  RtlCopyMemory(&pDC->erclClip,
790  &pDC->prgnVis->rdh.rcBound,
791  sizeof(RECTL));
792 
793  IntEngUpdateClipRegion(&pDC->co,
794  pDC->prgnVis->rdh.nCount,
795  pDC->prgnVis->Buffer,
796  &pDC->erclClip);
797 
798  REGION_bOffsetRgn(pDC->prgnVis, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y);
799 
800  pDC->fs &= ~DC_FLAG_DIRTY_RAO;
801  UpdateVisRgn(pDC);
802  return;
803  }
804 #endif
805  if (pDC->prgnAPI)
806  {
807  REGION_Delete(pDC->prgnAPI);
808  pDC->prgnAPI = NULL;
809  }
810 
811  if (pDC->prgnRao)
812  REGION_Delete(pDC->prgnRao);
813 
814  pDC->prgnRao = IntSysCreateRectpRgn(0,0,0,0);
815 
816  ASSERT(pDC->prgnRao);
817 
818  if (pDC->dclevel.prgnMeta || pDC->dclevel.prgnClip)
819  {
820  pDC->prgnAPI = IntSysCreateRectpRgn(0,0,0,0);
821  if (!pDC->dclevel.prgnMeta)
822  {
823  REGION_bCopy(pDC->prgnAPI,
824  pDC->dclevel.prgnClip);
825  }
826  else if (!pDC->dclevel.prgnClip)
827  {
828  REGION_bCopy(pDC->prgnAPI,
829  pDC->dclevel.prgnMeta);
830  }
831  else
832  {
833  REGION_bIntersectRegion(pDC->prgnAPI,
834  pDC->dclevel.prgnClip,
835  pDC->dclevel.prgnMeta);
836  }
837  }
838 
839  if (pDC->prgnAPI)
840  {
841  REGION_bIntersectRegion(pDC->prgnRao,
842  pDC->prgnVis,
843  pDC->prgnAPI);
844  }
845  else
846  {
847  REGION_bCopy(pDC->prgnRao,
848  pDC->prgnVis);
849  }
850 
851 
852  REGION_bOffsetRgn(pDC->prgnRao, pDC->ptlDCOrig.x, pDC->ptlDCOrig.y);
853 
854  RtlCopyMemory(&pDC->erclClip,
855  &pDC->prgnRao->rdh.rcBound,
856  sizeof(RECTL));
857 
858  pDC->fs &= ~DC_FLAG_DIRTY_RAO;
859  UpdateVisRgn(pDC);
860 
861  // pDC->co should be used. Example, CLIPOBJ_cEnumStart uses XCLIPOBJ to build
862  // the rects from region objects rects in pClipRgn->Buffer.
863  // With pDC->co.pClipRgn->Buffer,
864  // pDC->co.pClipRgn = pDC->prgnRao ? pDC->prgnRao : pDC->prgnVis;
865 
866  IntEngUpdateClipRegion(&pDC->co,
867  pDC->prgnRao->rdh.nCount,
868  pDC->prgnRao->Buffer,
869  &pDC->erclClip);
870 
871  REGION_bOffsetRgn(pDC->prgnRao, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y);
872 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL FASTCALL REGION_bIntersectRegion(PREGION, PREGION, PREGION)
Definition: region.c:1854
FORCEINLINE VOID RECTL_vSetEmptyRect(_Out_ RECTL *prcl)
Definition: rect.h:20
VOID FASTCALL UpdateVisRgn(PDC pdc)
Definition: cliprgn.c:39
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2727
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2426
smooth NULL
Definition: ftsmooth.c:416
BOOL FASTCALL REGION_bCopy(PREGION, PREGION)
Definition: region.c:1844
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID FASTCALL IntEngUpdateClipRegion(XCLIPOBJ *Clip, ULONG count, const RECTL *pRect, const RECTL *rcBounds)
Definition: clip.c:173
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2468

Referenced by DC_vPrepareDCsForBlit(), NtGdiGetBoundsRect(), NtGdiGetRandomRgn(), and NtGdiRectVisible().

◆ GdiSelectVisRgn()

VOID FASTCALL GdiSelectVisRgn ( HDC  hdc,
PREGION  prgn 
)

Definition at line 57 of file cliprgn.c.

60 {
61  DC *dc;
62 
63  if (!(dc = DC_LockDc(hdc)))
64  {
66  return;
67  }
68 
69  if (!prgn)
70  {
71  DPRINT1("SVR: Setting NULL Region\n");
74  DC_UnlockDc(dc);
75  return;
76  }
77 
78  dc->fs |= DC_FLAG_DIRTY_RAO;
79 
80  ASSERT(dc->prgnVis != NULL);
81  ASSERT(prgn != NULL);
82 
83  REGION_bCopy(dc->prgnVis, prgn);
84  REGION_bOffsetRgn(dc->prgnVis, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y);
85 
86  DC_UnlockDc(dc);
87 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
VOID FASTCALL IntGdiReleaseVisRgn(PDC pDC)
Definition: cliprgn.c:26
HDC dc
Definition: cylfrac.c:34
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2727
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
BOOL FASTCALL REGION_bCopy(PREGION, PREGION)
Definition: region.c:1844
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HDC hdc
Definition: main.c:9
BOOL FASTCALL IntSetDefaultRegion(PDC)
Definition: dcutil.c:350
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DPRINT1
Definition: precomp.h:8
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DC_vUpdateDC(), and DceUpdateVisRgn().

◆ IntGdiReleaseRaoRgn()

VOID FASTCALL IntGdiReleaseRaoRgn ( PDC  pDC)

Definition at line 16 of file cliprgn.c.

17 {
18  INT Index = GDI_HANDLE_GET_INDEX(pDC->BaseObject.hHmgr);
20  pDC->fs |= DC_FLAG_DIRTY_RAO;
21  Entry->Flags |= GDI_ENTRY_VALIDATE_VIS; // Need to validate Vis.
22 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
int32_t INT
Definition: typedefs.h:56
#define GdiHandleTable
Definition: win32nt.h:35
static const UCHAR Index[8]
Definition: usbohci.c:18
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
Definition: gdi.h:1
#define GDI_ENTRY_VALIDATE_VIS
Definition: ntgdihdl.h:40
base of all file and directory entries
Definition: entries.h:82

Referenced by _Success_(), IntGdiReleaseVisRgn(), IntGdiSetMetaRgn(), IntSetDefaultRegion(), and NtGdiOffsetClipRgn().

◆ IntGdiReleaseVisRgn()

VOID FASTCALL IntGdiReleaseVisRgn ( PDC  pDC)

Definition at line 26 of file cliprgn.c.

27 {
29  REGION_Delete(pDC->prgnVis);
30  pDC->prgnVis = prgnDefault; // Vis can not be NULL!!!
31 }
VOID FASTCALL IntGdiReleaseRaoRgn(PDC pDC)
Definition: cliprgn.c:16
PREGION prgnDefault
Definition: region.c:130
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2468

Referenced by GdiSelectVisRgn().

◆ IntGdiSetMetaRgn()

int FASTCALL IntGdiSetMetaRgn ( PDC  pDC)

Definition at line 707 of file cliprgn.c.

708 {
709  INT Ret = ERROR;
710 
711  if ( pDC->dclevel.prgnMeta )
712  {
713  if ( pDC->dclevel.prgnClip )
714  {
715  PREGION prgn = IntSysCreateRectpRgn(0,0,0,0);
716  if ( prgn )
717  {
718  if (REGION_bIntersectRegion(prgn, pDC->dclevel.prgnMeta, pDC->dclevel.prgnClip))
719  {
720  // See Restore/SaveDC
721  REGION_Delete(pDC->dclevel.prgnMeta);
722  pDC->dclevel.prgnMeta = prgn;
723 
724  REGION_Delete(pDC->dclevel.prgnClip);
725  pDC->dclevel.prgnClip = NULL;
726  IntGdiReleaseRaoRgn(pDC);
727 
728  Ret = REGION_Complexity(pDC->dclevel.prgnMeta);
729  }
730  else
731  REGION_Delete(prgn);
732  }
733  }
734  else
735  Ret = REGION_Complexity(pDC->dclevel.prgnMeta);
736  }
737  else
738  {
739  if ( pDC->dclevel.prgnClip )
740  {
741  Ret = REGION_Complexity(pDC->dclevel.prgnClip);
742  pDC->dclevel.prgnMeta = pDC->dclevel.prgnClip;
743  pDC->dclevel.prgnClip = NULL;
744  }
745  else
746  Ret = SIMPLEREGION;
747  }
748 
749  return Ret;
750 }
BOOL FASTCALL REGION_bIntersectRegion(PREGION, PREGION, PREGION)
Definition: region.c:1854
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:56
VOID FASTCALL IntGdiReleaseRaoRgn(PDC pDC)
Definition: cliprgn.c:16
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2426
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
#define SIMPLEREGION
Definition: wingdi.h:361
INT FASTCALL REGION_Complexity(PREGION prgn)
Definition: region.c:567
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2468

Referenced by NtGdiSetMetaRgn().

◆ NtGdiExcludeClipRect()

INT APIENTRY NtGdiExcludeClipRect ( _In_ HDC  hdc,
_In_ INT  xLeft,
_In_ INT  yTop,
_In_ INT  xRight,
_In_ INT  yBottom 
)

Definition at line 435 of file cliprgn.c.

441 {
442  INT iComplexity;
443  RECTL rect;
444  PDC pdc;
445 
446  /* Lock the DC */
447  pdc = DC_LockDc(hdc);
448  if (pdc == NULL)
449  {
451  return ERROR;
452  }
453 
454  /* Convert coordinates to device space */
455  rect.left = xLeft;
456  rect.top = yTop;
457  rect.right = xRight;
458  rect.bottom = yBottom;
460  IntLPtoDP(pdc, (LPPOINT)&rect, 2);
461 
462  /* Check if we already have a clip region */
463  if (pdc->dclevel.prgnClip != NULL)
464  {
465  /* We have a region, subtract the rect */
466  iComplexity = REGION_SubtractRectFromRgn(pdc->dclevel.prgnClip,
467  pdc->dclevel.prgnClip,
468  &rect);
469  }
470  else
471  {
472  /* We don't have a clip region yet, create an empty region */
473  pdc->dclevel.prgnClip = IntSysCreateRectpRgn(0, 0, 0, 0);
474  if (pdc->dclevel.prgnClip == NULL)
475  {
476  iComplexity = ERROR;
477  }
478  else
479  {
480  /* Subtract the rect from the VIS region */
481  iComplexity = REGION_SubtractRectFromRgn(pdc->dclevel.prgnClip,
482  pdc->prgnVis,
483  &rect);
484  }
485  }
486 
487  /* Emulate Windows behavior */
488  if (iComplexity == SIMPLEREGION)
489  iComplexity = COMPLEXREGION;
490 
491  /* If we succeeded, mark the RAO region as dirty */
492  if (iComplexity != ERROR)
493  pdc->fs |= DC_FLAG_DIRTY_RAO;
494 
495  /* Unlock the DC */
496  DC_UnlockDc(pdc);
497 
498  return iComplexity;
499 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
INT FASTCALL REGION_SubtractRectFromRgn(PREGION prgnDest, PREGION prgnSrc, const RECTL *prcl)
Definition: region.c:1827
#define ERROR(name)
Definition: error_private.h:53
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define COMPLEXREGION
Definition: wingdi.h:362
int32_t INT
Definition: typedefs.h:56
& rect
Definition: startmenu.cpp:1413
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2426
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
HDC hdc
Definition: main.c:9
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by ExcludeClipRect().

◆ NtGdiExtSelectClipRgn()

int APIENTRY NtGdiExtSelectClipRgn ( HDC  hDC,
HRGN  hrgn,
int  fnMode 
)

Definition at line 307 of file cliprgn.c.

311 {
312  int retval;
313  DC *dc;
314  PREGION prgn;
315 
316  if ( fnMode < RGN_AND || fnMode > RGN_COPY )
317  {
319  return ERROR;
320  }
321 
322  if (!(dc = DC_LockDc(hDC)))
323  {
325  return ERROR;
326  }
327 
328  prgn = REGION_LockRgn(hrgn);
329 
330  if ((prgn == NULL) && (fnMode != RGN_COPY))
331  {
332  //EngSetLastError(ERROR_INVALID_HANDLE); doesn't set this.
333  retval = ERROR;
334  }
335  else
336  {
337 #if 0 // Testing GDI Batch.
338  {
339  RECTL rcl;
340  if (prgn)
341  REGION_GetRgnBox(prgn, &rcl);
342  else
343  fnMode |= GDIBS_NORECT;
344  retval = IntGdiExtSelectClipRect(dc, &rcl, fnMode);
345  }
346 #else
347  retval = IntGdiExtSelectClipRgn(dc, prgn, fnMode);
348 #endif
349  }
350 
351  if (prgn)
352  REGION_UnlockRgn(prgn);
353 
354  DC_UnlockDc(dc);
355  return retval;
356 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR(name)
Definition: error_private.h:53
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
HDC dc
Definition: cylfrac.c:34
PREGION FASTCALL REGION_LockRgn(_In_ HRGN hrgn)
Definition: region.c:2377
int FASTCALL IntGdiExtSelectClipRect(PDC, PRECTL, int)
INT FASTCALL IntGdiExtSelectClipRgn(PDC dc, PREGION prgn, int fnMode)
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
Definition: polytest.cpp:40
#define GDIBS_NORECT
Definition: ntgdityp.h:506
static HRGN hrgn
Definition: win.c:55
#define RGN_COPY
Definition: wingdi.h:356
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
VOID FASTCALL REGION_UnlockRgn(_In_ PREGION prgn)
Definition: region.c:2392
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2562
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiIntersectClipRect()

INT APIENTRY NtGdiIntersectClipRect ( _In_ HDC  hdc,
_In_ INT  xLeft,
_In_ INT  yTop,
_In_ INT  xRight,
_In_ INT  yBottom 
)

Definition at line 503 of file cliprgn.c.

509 {
510  INT iComplexity;
511  RECTL rect;
512  PREGION prgnNew;
513  PDC pdc;
514 
515  DPRINT("NtGdiIntersectClipRect(%p, %d,%d-%d,%d)\n",
516  hdc, xLeft, yTop, xRight, yBottom);
517 
518  /* Lock the DC */
519  pdc = DC_LockDc(hdc);
520  if (!pdc)
521  {
523  return ERROR;
524  }
525 
526  /* Convert coordinates to device space */
527  rect.left = xLeft;
528  rect.top = yTop;
529  rect.right = xRight;
530  rect.bottom = yBottom;
531  IntLPtoDP(pdc, (LPPOINT)&rect, 2);
532 
533  /* Check if we already have a clip region */
534  if (pdc->dclevel.prgnClip != NULL)
535  {
536  /* We have a region, crop it */
537  iComplexity = REGION_CropRegion(pdc->dclevel.prgnClip,
538  pdc->dclevel.prgnClip,
539  &rect);
540  }
541  else
542  {
543  /* We don't have a region yet, allocate a new one */
545  if (prgnNew == NULL)
546  {
547  iComplexity = ERROR;
548  }
549  else
550  {
551  /* Set the new region */
552  pdc->dclevel.prgnClip = prgnNew;
553  iComplexity = SIMPLEREGION;
554  }
555  }
556 
557  /* If we succeeded, mark the RAO region as dirty */
558  if (iComplexity != ERROR)
559  pdc->fs |= DC_FLAG_DIRTY_RAO;
560 
561  /* Unlock the DC */
562  DC_UnlockDc(pdc);
563 
564  return iComplexity;
565 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR(name)
Definition: error_private.h:53
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
int32_t INT
Definition: typedefs.h:56
& rect
Definition: startmenu.cpp:1413
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: region.h:7
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
Definition: polytest.cpp:40
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
HDC hdc
Definition: main.c:9
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
INT FASTCALL REGION_CropRegion(PREGION rgnDst, PREGION rgnSrc, const RECTL *rect)
Definition: region.c:678
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by co_IntDrawCaret(), co_UserExcludeUpdateRgn(), DrawTextExWorker(), and IntersectClipRect().

◆ NtGdiOffsetClipRgn()

INT APIENTRY NtGdiOffsetClipRgn ( _In_ HDC  hdc,
_In_ INT  xOffset,
_In_ INT  yOffset 
)

Definition at line 569 of file cliprgn.c.

573 {
574  INT iComplexity;
575  PDC pdc;
576  POINTL apt[2];
577 
578  /* Lock the DC */
579  pdc = DC_LockDc(hdc);
580  if (pdc == NULL)
581  {
583  return ERROR;
584  }
585 
586  /* Check if we have a clip region */
587  if (pdc->dclevel.prgnClip != NULL)
588  {
589  /* Convert coordinates into device space. Note that we need to convert
590  2 coordinates to account for rotation / shear / offset */
591  apt[0].x = 0;
592  apt[0].y = 0;
593  apt[1].x = xOffset;
594  apt[1].y = yOffset;
595  IntLPtoDP(pdc, &apt, 2);
596 
597  /* Offset the clip region */
598  if (!REGION_bOffsetRgn(pdc->dclevel.prgnClip,
599  apt[1].x - apt[0].x,
600  apt[1].y - apt[0].y))
601  {
602  iComplexity = ERROR;
603  }
604  else
605  {
606  IntGdiReleaseRaoRgn(pdc);
607  UpdateVisRgn(pdc);
608  iComplexity = REGION_Complexity(pdc->dclevel.prgnClip);
609  }
610 
611  /* Mark the RAO region as dirty */
612  pdc->fs |= DC_FLAG_DIRTY_RAO;
613  }
614  else
615  {
616  /* NULL means no clipping, i.e. the "whole" region */
617  iComplexity = SIMPLEREGION;
618  }
619 
620  /* Unlock the DC and return the complexity */
621  DC_UnlockDc(pdc);
622  return iComplexity;
623 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR(name)
Definition: error_private.h:53
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
VOID FASTCALL UpdateVisRgn(PDC pdc)
Definition: cliprgn.c:39
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2727
int32_t INT
Definition: typedefs.h:56
LONG y
Definition: windef.h:315
VOID FASTCALL IntGdiReleaseRaoRgn(PDC pDC)
Definition: cliprgn.c:16
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
LONG x
Definition: windef.h:314
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
HDC hdc
Definition: main.c:9
#define SIMPLEREGION
Definition: wingdi.h:361
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
int xOffset
Definition: appswitch.c:59
int yOffset
Definition: appswitch.c:59
INT FASTCALL REGION_Complexity(PREGION prgn)
Definition: region.c:567
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by OffsetClipRgn().

◆ NtGdiPtVisible()

BOOL APIENTRY NtGdiPtVisible ( HDC  hDC,
int  X,
int  Y 
)

Definition at line 625 of file cliprgn.c.

628 {
629  BOOL ret = FALSE;
630  PDC dc;
631  PREGION prgn;
632 
633  if(!(dc = DC_LockDc(hDC)))
634  {
636  return FALSE;
637  }
638 
639  prgn = dc->prgnRao ? dc->prgnRao : dc->prgnVis;
640 
641  if (prgn)
642  {
643  POINT pt = {X, Y};
644  IntLPtoDP(dc, &pt, 1);
645  ret = REGION_PtInRegion(prgn, pt.x, pt.y);
646  }
647 
648  DC_UnlockDc(dc);
649 
650  return ret;
651 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define Y(I)
#define pt(x, y)
Definition: drawing.c:79
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
HDC dc
Definition: cylfrac.c:34
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: region.h:7
Definition: polytest.cpp:40
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
int ret
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define X(b, s)
BOOL FASTCALL REGION_PtInRegion(PREGION prgn, INT X, INT Y)
Definition: region.c:2602

◆ NtGdiRectVisible()

BOOL APIENTRY NtGdiRectVisible ( HDC  hDC,
LPRECT  UnsafeRect 
)

Definition at line 655 of file cliprgn.c.

658 {
660  PDC dc = DC_LockDc(hDC);
661  BOOL Result = FALSE;
662  RECTL Rect;
663  PREGION prgn;
664 
665  if (!dc)
666  {
668  return FALSE;
669  }
670 
671  _SEH2_TRY
672  {
673  ProbeForRead(UnsafeRect,
674  sizeof(RECT),
675  1);
676  Rect = *UnsafeRect;
677  }
679  {
681  }
682  _SEH2_END;
683 
684  if(!NT_SUCCESS(Status))
685  {
686  DC_UnlockDc(dc);
688  return FALSE;
689  }
690 
691  if (dc->fs & DC_FLAG_DIRTY_RAO)
693 
694  prgn = dc->prgnRao ? dc->prgnRao : dc->prgnVis;
695  if (prgn)
696  {
697  IntLPtoDP(dc, (LPPOINT)&Rect, 2);
698  Result = REGION_RectInRegion(prgn, &Rect);
699  }
700  DC_UnlockDc(dc);
701 
702  return Result;
703 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
HDC dc
Definition: cylfrac.c:34
_SEH2_TRY
Definition: create.c:4250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
BOOL FASTCALL REGION_RectInRegion(PREGION Rgn, const RECTL *rect)
Definition: region.c:2625
Definition: region.h:7
Definition: polytest.cpp:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC)
Definition: cliprgn.c:771
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
static HDC hDC
Definition: 3dtext.c:33
_SEH2_END
Definition: create.c:4424
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
struct Rect Rect

◆ NtGdiSetMetaRgn()

int APIENTRY NtGdiSetMetaRgn ( HDC  hDC)

Definition at line 753 of file cliprgn.c.

754 {
755  INT Ret;
756  PDC pDC = DC_LockDc(hDC);
757 
758  if (!pDC)
759  {
761  return ERROR;
762  }
763  Ret = IntGdiSetMetaRgn(pDC);
764 
765  DC_UnlockDc(pDC);
766  return Ret;
767 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:56
Definition: polytest.cpp:40
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
int FASTCALL IntGdiSetMetaRgn(PDC pDC)
Definition: cliprgn.c:707
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ UpdateVisRgn()

VOID FASTCALL UpdateVisRgn ( PDC  pdc)

Definition at line 39 of file cliprgn.c.

41 {
42  INT Index = GDI_HANDLE_GET_INDEX(pdc->BaseObject.hHmgr);
43  PGDI_TABLE_ENTRY pEntry = &GdiHandleTable->Entries[Index];
44 
45  /* Setup Vis Region Attribute information to User side */
46  pEntry->Flags |= GDI_ENTRY_VALIDATE_VIS;
47  pdc->pdcattr->VisRectRegion.iComplexity = REGION_GetRgnBox(pdc->prgnVis, &pdc->pdcattr->VisRectRegion.Rect);
48  pdc->pdcattr->VisRectRegion.AttrFlags = ATTR_RGN_VALID;
49  pEntry->Flags &= ~GDI_ENTRY_VALIDATE_VIS;
50 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
int32_t INT
Definition: typedefs.h:56
#define ATTR_RGN_VALID
Definition: ntgdihdl.h:210
#define GdiHandleTable
Definition: win32nt.h:35
static const UCHAR Index[8]
Definition: usbohci.c:18
Definition: gdi.h:1
UCHAR Flags
Definition: ntgdihdl.h:225
#define GDI_ENTRY_VALIDATE_VIS
Definition: ntgdihdl.h:40
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2562

Referenced by CLIPPING_UpdateGCRegion(), DC_vInitDc(), and NtGdiOffsetClipRgn().