ReactOS  0.4.15-dev-1200-gc3b3fcd
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;
126 #if 0
128 
129  // See IntSetDefaultRegion.
130 
131  rcl.left = 0;
132  rcl.top = 0;
133  rcl.right = dc->dclevel.sizl.cx;
134  rcl.bottom = dc->dclevel.sizl.cy;
135 
136  //EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
137  if (dc->ppdev->flFlags & PDEV_META_DEVICE)
138  {
139  pSurface = dc->dclevel.pSurface;
140  if (pSurface && pSurface->flags & PDEV_SURFACE)
141  {
142  rcl.left += dc->ppdev->ptlOrigion.x;
143  rcl.top += dc->ppdev->ptlOrigion.y;
144  rcl.right += dc->ppdev->ptlOrigion.x;
145  rcl.bottom += dc->ppdev->ptlOrigion.y;
146  }
147  }
148  //EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
149 //#if 0
150  rcl.left += dc->ptlDCOrig.x;
151  rcl.top += dc->ptlDCOrig.y;
152  rcl.right += dc->ptlDCOrig.x;
153  rcl.bottom += dc->ptlDCOrig.y;
154 #endif
155  REGION_GetRgnBox(dc->prgnVis, &rcl);
156 
157  prgnClip = IntSysCreateRectpRgnIndirect(&rcl);
158 
159  Ret = IntGdiCombineRgn(prgnNClip, prgnClip, prgn, fnMode);
160 
161  if (Ret)
162  {
163  dc->dclevel.prgnClip = prgnNClip;
165  }
166  else
167  REGION_Delete(prgnNClip);
168 
169  REGION_Delete(prgnClip);
170  }
171  return Ret;
172  }
173 
174  // Fall through to normal RectOS mode.
175 
176  //
177  // Handle NULL Region and Original Clip Region.
178  //
179  if (!prgn)
180  {
181  if (prgnOrigClip)
182  {
183  REGION_Delete(dc->dclevel.prgnClip);
184  dc->dclevel.prgnClip = NULL;
186  }
187  return SIMPLEREGION;
188  }
189 
190  //
191  // Combine the new Clip region with original Clip and caller Region.
192  //
193  if ( prgnOrigClip &&
194  (Ret = IntGdiCombineRgn(prgnOrigClip, prgn, NULL, RGN_COPY)) ) // Clip could fail.
195  {
197  }
198  else // NULL original Clip, just copy caller region to new.
199  {
200  prgnNClip = IntSysCreateRectpRgn(0, 0, 0, 0);
201  REGION_bCopy(prgnNClip, prgn);
202  Ret = REGION_Complexity(prgnNClip);
203  dc->dclevel.prgnClip = prgnNClip;
205  }
206  return Ret;
207 }
#define ERROR(name)
Definition: error_private.h:53
long bottom
Definition: polytest.cpp:53
#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
static const WCHAR dc[]
INT FASTCALL REGION_Complexity(PREGION prgn)
Definition: region.c:567
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2562
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2468

◆ CLIPPING_UpdateGCRegion()

VOID FASTCALL CLIPPING_UpdateGCRegion ( PDC  pDC)

Definition at line 739 of file cliprgn.c.

740 {
741  // Moved from Release Rao. Though it still gets over written.
742  RECTL_vSetEmptyRect(&pDC->erclClip);
743 
744  /* Must have VisRgn set to a valid state! */
745  ASSERT (pDC->prgnVis);
746 #if 0 // (w2k3) This works with limitations. (w7u) ReactOS relies on Rao.
747  if ( !pDC->dclevel.prgnClip &&
748  !pDC->dclevel.prgnMeta &&
749  !pDC->prgnAPI)
750  {
751  if (pDC->prgnRao)
752  REGION_Delete(pDC->prgnRao);
753  pDC->prgnRao = NULL;
754 
755  REGION_bOffsetRgn(pDC->prgnVis, pDC->ptlDCOrig.x, pDC->ptlDCOrig.y);
756 
757  RtlCopyMemory(&pDC->erclClip,
758  &pDC->prgnVis->rdh.rcBound,
759  sizeof(RECTL));
760 
761  IntEngUpdateClipRegion(&pDC->co,
762  pDC->prgnVis->rdh.nCount,
763  pDC->prgnVis->Buffer,
764  &pDC->erclClip);
765 
766  REGION_bOffsetRgn(pDC->prgnVis, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y);
767 
768  pDC->fs &= ~DC_FLAG_DIRTY_RAO;
769  UpdateVisRgn(pDC);
770  return;
771  }
772 #endif
773  if (pDC->prgnAPI)
774  {
775  REGION_Delete(pDC->prgnAPI);
776  pDC->prgnAPI = NULL;
777  }
778 
779  if (pDC->prgnRao)
780  REGION_Delete(pDC->prgnRao);
781 
782  pDC->prgnRao = IntSysCreateRectpRgn(0,0,0,0);
783 
784  ASSERT(pDC->prgnRao);
785 
786  if (pDC->dclevel.prgnMeta || pDC->dclevel.prgnClip)
787  {
788  pDC->prgnAPI = IntSysCreateRectpRgn(0,0,0,0);
789  if (!pDC->dclevel.prgnMeta)
790  {
791  REGION_bCopy(pDC->prgnAPI,
792  pDC->dclevel.prgnClip);
793  }
794  else if (!pDC->dclevel.prgnClip)
795  {
796  REGION_bCopy(pDC->prgnAPI,
797  pDC->dclevel.prgnMeta);
798  }
799  else
800  {
801  REGION_bIntersectRegion(pDC->prgnAPI,
802  pDC->dclevel.prgnClip,
803  pDC->dclevel.prgnMeta);
804  }
805  }
806 
807  if (pDC->prgnAPI)
808  {
809  REGION_bIntersectRegion(pDC->prgnRao,
810  pDC->prgnVis,
811  pDC->prgnAPI);
812  }
813  else
814  {
815  REGION_bCopy(pDC->prgnRao,
816  pDC->prgnVis);
817  }
818 
819 
820  REGION_bOffsetRgn(pDC->prgnRao, pDC->ptlDCOrig.x, pDC->ptlDCOrig.y);
821 
822  RtlCopyMemory(&pDC->erclClip,
823  &pDC->prgnRao->rdh.rcBound,
824  sizeof(RECTL));
825 
826  pDC->fs &= ~DC_FLAG_DIRTY_RAO;
827  UpdateVisRgn(pDC);
828 
829  // pDC->co should be used. Example, CLIPOBJ_cEnumStart uses XCLIPOBJ to build
830  // the rects from region objects rects in pClipRgn->Buffer.
831  // With pDC->co.pClipRgn->Buffer,
832  // pDC->co.pClipRgn = pDC->prgnRao ? pDC->prgnRao : pDC->prgnVis;
833 
834  IntEngUpdateClipRegion(&pDC->co,
835  pDC->prgnRao->rdh.nCount,
836  pDC->prgnRao->Buffer,
837  &pDC->erclClip);
838 
839  REGION_bOffsetRgn(pDC->prgnRao, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y);
840 }
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:98
VOID FASTCALL IntGdiReleaseVisRgn(PDC pDC)
Definition: cliprgn.c:26
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
static const WCHAR dc[]
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:58
#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 675 of file cliprgn.c.

676 {
677  INT Ret = ERROR;
678 
679  if ( pDC->dclevel.prgnMeta )
680  {
681  if ( pDC->dclevel.prgnClip )
682  {
683  PREGION prgn = IntSysCreateRectpRgn(0,0,0,0);
684  if ( prgn )
685  {
686  if (REGION_bIntersectRegion(prgn, pDC->dclevel.prgnMeta, pDC->dclevel.prgnClip))
687  {
688  // See Restore/SaveDC
689  REGION_Delete(pDC->dclevel.prgnMeta);
690  pDC->dclevel.prgnMeta = prgn;
691 
692  REGION_Delete(pDC->dclevel.prgnClip);
693  pDC->dclevel.prgnClip = NULL;
694  IntGdiReleaseRaoRgn(pDC);
695 
696  Ret = REGION_Complexity(pDC->dclevel.prgnMeta);
697  }
698  else
699  REGION_Delete(prgn);
700  }
701  }
702  else
703  Ret = REGION_Complexity(pDC->dclevel.prgnMeta);
704  }
705  else
706  {
707  if ( pDC->dclevel.prgnClip )
708  {
709  Ret = REGION_Complexity(pDC->dclevel.prgnClip);
710  pDC->dclevel.prgnMeta = pDC->dclevel.prgnClip;
711  pDC->dclevel.prgnClip = NULL;
712  }
713  else
714  Ret = SIMPLEREGION;
715  }
716 
717  return Ret;
718 }
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:58
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 438 of file cliprgn.c.

444 {
445  INT iComplexity = ERROR;
446  RECTL rect;
447  PDC pdc;
448  PREGION prgn;
449 
450  /* Lock the DC */
451  pdc = DC_LockDc(hdc);
452  if (pdc == NULL)
453  {
455  return ERROR;
456  }
457 
458  /* Convert coordinates to device space */
459  rect.left = xLeft;
460  rect.top = yTop;
461  rect.right = xRight;
462  rect.bottom = yBottom;
464  IntLPtoDP(pdc, (LPPOINT)&rect, 2);
465 
467  if ( prgn )
468  {
469  iComplexity = IntSelectClipRgn( pdc, prgn, RGN_DIFF );
470 
471  REGION_Delete(prgn);
472  }
473 
474  /* Emulate Windows behavior */
475  if (iComplexity == SIMPLEREGION)
476  iComplexity = COMPLEXREGION;
477 
478  /* Unlock the DC */
479  DC_UnlockDc(pdc);
480 
481  return iComplexity;
482 }
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:98
#define COMPLEXREGION
Definition: wingdi.h:362
int32_t INT
Definition: typedefs.h:58
& rect
Definition: startmenu.cpp:1413
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
Definition: polytest.cpp:40
#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
#define RGN_DIFF
Definition: wingdi.h:357
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2468
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(), and START_TEST().

◆ NtGdiExtSelectClipRgn()

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

Definition at line 310 of file cliprgn.c.

314 {
315  int retval;
316  DC *dc;
317  PREGION prgn;
318 
319  if ( fnMode < RGN_AND || fnMode > RGN_COPY )
320  {
322  return ERROR;
323  }
324 
325  if (!(dc = DC_LockDc(hDC)))
326  {
328  return ERROR;
329  }
330 
331  prgn = REGION_LockRgn(hrgn);
332 
333  if ((prgn == NULL) && (fnMode != RGN_COPY))
334  {
335  //EngSetLastError(ERROR_INVALID_HANDLE); doesn't set this.
336  retval = ERROR;
337  }
338  else
339  {
340 #if 0 // Testing GDI Batch.
341  {
342  RECTL rcl;
343  if (prgn)
344  REGION_GetRgnBox(prgn, &rcl);
345  else
346  fnMode |= GDIBS_NORECT;
347  retval = IntGdiExtSelectClipRect(dc, &rcl, fnMode);
348  }
349 #else
350  retval = IntGdiExtSelectClipRgn(dc, prgn, fnMode);
351 #endif
352  }
353 
354  if (prgn)
355  REGION_UnlockRgn(prgn);
356 
357  DC_UnlockDc(dc);
358  return retval;
359 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
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:98
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:507
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
static const WCHAR dc[]
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 486 of file cliprgn.c.

492 {
493  INT iComplexity = ERROR;
494  RECTL rect;
495  PDC pdc;
496  PREGION prgn;
497 
498  DPRINT("NtGdiIntersectClipRect(%p, %d,%d-%d,%d)\n",
499  hdc, xLeft, yTop, xRight, yBottom);
500 
501  /* Lock the DC */
502  pdc = DC_LockDc(hdc);
503  if (!pdc)
504  {
506  return ERROR;
507  }
508 
509  /* Convert coordinates to device space */
510  rect.left = xLeft;
511  rect.top = yTop;
512  rect.right = xRight;
513  rect.bottom = yBottom;
515  IntLPtoDP(pdc, (LPPOINT)&rect, 2);
516 
518  if ( prgn )
519  {
520  iComplexity = IntSelectClipRgn( pdc, prgn, RGN_AND );
521 
522  REGION_Delete(prgn);
523  }
524 
525  /* Emulate Windows behavior */
526  if ( iComplexity == SIMPLEREGION )
527  iComplexity = COMPLEXREGION;
528 
529  /* Unlock the DC */
530  DC_UnlockDc(pdc);
531 
532  return iComplexity;
533 }
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:98
#define COMPLEXREGION
Definition: wingdi.h:362
int32_t INT
Definition: typedefs.h:58
& rect
Definition: startmenu.cpp:1413
#define RGN_AND
Definition: wingdi.h:355
void DPRINT(...)
Definition: polytest.cpp:61
Definition: region.h:7
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
Definition: polytest.cpp:40
#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 REGION_Delete(PREGION pRgn)
Definition: region.c:2468
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

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

◆ NtGdiOffsetClipRgn()

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

Definition at line 537 of file cliprgn.c.

541 {
542  INT iComplexity;
543  PDC pdc;
544  POINTL apt[2];
545 
546  /* Lock the DC */
547  pdc = DC_LockDc(hdc);
548  if (pdc == NULL)
549  {
551  return ERROR;
552  }
553 
554  /* Check if we have a clip region */
555  if (pdc->dclevel.prgnClip != NULL)
556  {
557  /* Convert coordinates into device space. Note that we need to convert
558  2 coordinates to account for rotation / shear / offset */
559  apt[0].x = 0;
560  apt[0].y = 0;
561  apt[1].x = xOffset;
562  apt[1].y = yOffset;
563  IntLPtoDP(pdc, &apt, 2);
564 
565  /* Offset the clip region */
566  if (!REGION_bOffsetRgn(pdc->dclevel.prgnClip,
567  apt[1].x - apt[0].x,
568  apt[1].y - apt[0].y))
569  {
570  iComplexity = ERROR;
571  }
572  else
573  {
574  IntGdiReleaseRaoRgn(pdc);
575  UpdateVisRgn(pdc);
576  iComplexity = REGION_Complexity(pdc->dclevel.prgnClip);
577  }
578 
579  /* Mark the RAO region as dirty */
580  pdc->fs |= DC_FLAG_DIRTY_RAO;
581  }
582  else
583  {
584  /* NULL means no clipping, i.e. the "whole" region */
585  iComplexity = SIMPLEREGION;
586  }
587 
588  /* Unlock the DC and return the complexity */
589  DC_UnlockDc(pdc);
590  return iComplexity;
591 }
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:98
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:58
LONG y
Definition: windef.h:330
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:329
#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(), and START_TEST().

◆ NtGdiPtVisible()

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

Definition at line 593 of file cliprgn.c.

596 {
597  BOOL ret = FALSE;
598  PDC dc;
599  PREGION prgn;
600 
601  if(!(dc = DC_LockDc(hDC)))
602  {
604  return FALSE;
605  }
606 
607  prgn = dc->prgnRao ? dc->prgnRao : dc->prgnVis;
608 
609  if (prgn)
610  {
611  POINT pt = {X, Y};
612  IntLPtoDP(dc, &pt, 1);
613  ret = REGION_PtInRegion(prgn, pt.x, pt.y);
614  }
615 
616  DC_UnlockDc(dc);
617 
618  return ret;
619 }
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:98
#define FALSE
Definition: types.h:117
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
static const WCHAR dc[]
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 623 of file cliprgn.c.

626 {
628  PDC dc = DC_LockDc(hDC);
629  BOOL Result = FALSE;
630  RECTL Rect;
631  PREGION prgn;
632 
633  if (!dc)
634  {
636  return FALSE;
637  }
638 
639  _SEH2_TRY
640  {
641  ProbeForRead(UnsafeRect,
642  sizeof(RECT),
643  1);
644  Rect = *UnsafeRect;
645  }
647  {
649  }
650  _SEH2_END;
651 
652  if(!NT_SUCCESS(Status))
653  {
654  DC_UnlockDc(dc);
656  return FALSE;
657  }
658 
659  if (dc->fs & DC_FLAG_DIRTY_RAO)
661 
662  prgn = dc->prgnRao ? dc->prgnRao : dc->prgnVis;
663  if (prgn)
664  {
665  IntLPtoDP(dc, (LPPOINT)&Rect, 2);
666  Result = REGION_RectInRegion(prgn, &Rect);
667  }
668  DC_UnlockDc(dc);
669 
670  return Result;
671 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
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:739
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
Status
Definition: gdiplustypes.h:24
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
static HDC hDC
Definition: 3dtext.c:33
_SEH2_END
Definition: create.c:4400
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
static const WCHAR dc[]
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:3014
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
struct Rect Rect

◆ NtGdiSetMetaRgn()

int APIENTRY NtGdiSetMetaRgn ( HDC  hDC)

Definition at line 721 of file cliprgn.c.

722 {
723  INT Ret;
724  PDC pDC = DC_LockDc(hDC);
725 
726  if (!pDC)
727  {
729  return ERROR;
730  }
731  Ret = IntGdiSetMetaRgn(pDC);
732 
733  DC_UnlockDc(pDC);
734  return Ret;
735 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:58
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:675
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:58
#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().