ReactOS  0.4.13-dev-100-gc8611ae
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 GdiSelectVisRgn (HDC hdc, PREGION prgn)
 
int FASTCALL IntGdiExtSelectClipRgn (PDC dc, PREGION prgn, int fnMode)
 
int APIENTRY NtGdiExtSelectClipRgn (HDC hDC, HRGN hrgn, int fnMode)
 
 _Success_ (return!=ERROR)
 
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 146 of file cliprgn.c.

152 {
153  PDC pdc;
154  INT iComplexity;
155 
156  /* Lock the DC */
157  pdc = DC_LockDc(hdc);
158  if (!pdc)
159  {
160  return ERROR;
161  }
162 
163  /* Update RAO region if necessary */
164  if (pdc->fs & DC_FLAG_DIRTY_RAO)
166 
167  /* Check if we have a RAO region (intersection of API and VIS region) */
168  if (pdc->prgnRao)
169  {
170  /* We have a RAO region, use it */
171  iComplexity = REGION_GetRgnBox(pdc->prgnRao, prc);
172  }
173  else
174  {
175  /* No RAO region means no API region, so use the VIS region */
176  ASSERT(pdc->prgnVis);
177  iComplexity = REGION_GetRgnBox(pdc->prgnVis, prc);
178  }
179 
180  /* Unlock the DC */
181  DC_UnlockDc(pdc);
182 
183  /* Convert the rect to logical coordinates */
184  IntDPtoLP(pdc, (LPPOINT)prc, 2);
185 
186  /* Return the complexity */
187  return iComplexity;
188 }
#define IntDPtoLP(pdc, ppt, count)
Definition: coord.h:12
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
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC)
Definition: cliprgn.c:544
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HDC hdc
Definition: main.c:9
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2565
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ CLIPPING_UpdateGCRegion()

VOID FASTCALL CLIPPING_UpdateGCRegion ( PDC  pDC)

Definition at line 544 of file cliprgn.c.

545 {
546  /* Must have VisRgn set to a valid state! */
547  ASSERT (pDC->prgnVis);
548 
549  if (pDC->prgnAPI)
550  {
551  REGION_Delete(pDC->prgnAPI);
552  pDC->prgnAPI = NULL;
553  }
554 
555  if (pDC->prgnRao)
556  REGION_Delete(pDC->prgnRao);
557 
558  pDC->prgnRao = IntSysCreateRectpRgn(0,0,0,0);
559 
560  ASSERT(pDC->prgnRao);
561 
562  if (pDC->dclevel.prgnMeta || pDC->dclevel.prgnClip)
563  {
564  pDC->prgnAPI = IntSysCreateRectpRgn(0,0,0,0);
565  if (!pDC->dclevel.prgnMeta)
566  {
567  IntGdiCombineRgn(pDC->prgnAPI,
568  pDC->dclevel.prgnClip,
569  NULL,
570  RGN_COPY);
571  }
572  else if (!pDC->dclevel.prgnClip)
573  {
574  IntGdiCombineRgn(pDC->prgnAPI,
575  pDC->dclevel.prgnMeta,
576  NULL,
577  RGN_COPY);
578  }
579  else
580  {
581  IntGdiCombineRgn(pDC->prgnAPI,
582  pDC->dclevel.prgnClip,
583  pDC->dclevel.prgnMeta,
584  RGN_AND);
585  }
586  }
587 
588  if (pDC->prgnAPI)
589  {
590  IntGdiCombineRgn(pDC->prgnRao,
591  pDC->prgnVis,
592  pDC->prgnAPI,
593  RGN_AND);
594  }
595  else
596  {
597  IntGdiCombineRgn(pDC->prgnRao,
598  pDC->prgnVis,
599  NULL,
600  RGN_COPY);
601  }
602 
603 
604  REGION_bOffsetRgn(pDC->prgnRao, pDC->ptlDCOrig.x, pDC->ptlDCOrig.y);
605 
606  RtlCopyMemory(&pDC->erclClip,
607  &pDC->prgnRao->rdh.rcBound,
608  sizeof(RECTL));
609 
610  pDC->fs &= ~DC_FLAG_DIRTY_RAO;
611 
612  // pDC->co should be used. Example, CLIPOBJ_cEnumStart uses XCLIPOBJ to build
613  // the rects from region objects rects in pClipRgn->Buffer.
614  // With pDC->co.pClipRgn->Buffer,
615  // pDC->co.pClipRgn = pDC->prgnRao ? pDC->prgnRao : pDC->prgnVis;
616 
617  IntEngUpdateClipRegion(&pDC->co,
618  pDC->prgnRao->rdh.nCount,
619  pDC->prgnRao->Buffer,
620  &pDC->erclClip);
621 
622  REGION_bOffsetRgn(pDC->prgnRao, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y);
623 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2730
#define RGN_AND
Definition: wingdi.h:355
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2429
smooth NULL
Definition: ftsmooth.c:416
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2509
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define RGN_COPY
Definition: wingdi.h:356
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:2471

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

◆ GdiSelectVisRgn()

VOID FASTCALL GdiSelectVisRgn ( HDC  hdc,
PREGION  prgn 
)

Definition at line 42 of file cliprgn.c.

45 {
46  DC *dc;
47 
48  if (!(dc = DC_LockDc(hdc)))
49  {
51  return;
52  }
53 
54  dc->fs |= DC_FLAG_DIRTY_RAO;
55 
56  ASSERT(dc->prgnVis != NULL);
57  ASSERT(prgn != NULL);
58 
59  IntGdiCombineRgn(dc->prgnVis, prgn, NULL, RGN_COPY);
60  REGION_bOffsetRgn(dc->prgnVis, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y);
61 
62  DC_UnlockDc(dc);
63 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
HDC dc
Definition: cylfrac.c:34
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2730
smooth NULL
Definition: ftsmooth.c:416
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2509
Definition: polytest.cpp:40
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HDC hdc
Definition: main.c:9
#define RGN_COPY
Definition: wingdi.h:356
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DC_vUpdateDC(), and DceUpdateVisRgn().

◆ IntGdiExtSelectClipRgn()

int FASTCALL IntGdiExtSelectClipRgn ( PDC  dc,
PREGION  prgn,
int  fnMode 
)

Definition at line 68 of file cliprgn.c.

72 {
73  if (fnMode == RGN_COPY)
74  {
75  if (!prgn)
76  {
77  if (dc->dclevel.prgnClip != NULL)
78  {
79  REGION_Delete(dc->dclevel.prgnClip);
80  dc->dclevel.prgnClip = NULL;
81  dc->fs |= DC_FLAG_DIRTY_RAO;
82  }
83  return SIMPLEREGION;
84  }
85 
86  if (!dc->dclevel.prgnClip)
87  dc->dclevel.prgnClip = IntSysCreateRectpRgn(0, 0, 0, 0);
88 
89  dc->fs |= DC_FLAG_DIRTY_RAO;
90 
91  return IntGdiCombineRgn(dc->dclevel.prgnClip, prgn, NULL, RGN_COPY);
92  }
93 
94  ASSERT(prgn != NULL);
95 
96  if (!dc->dclevel.prgnClip)
97  {
98  RECTL rect;
99 
100  REGION_GetRgnBox(dc->prgnVis, &rect);
101  dc->dclevel.prgnClip = IntSysCreateRectpRgnIndirect(&rect);
102  }
103 
104  dc->fs |= DC_FLAG_DIRTY_RAO;
105 
106  return IntGdiCombineRgn(dc->dclevel.prgnClip, dc->dclevel.prgnClip, prgn, fnMode);
107 }
HDC dc
Definition: cylfrac.c:34
& rect
Definition: startmenu.cpp:1413
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2429
smooth NULL
Definition: ftsmooth.c:416
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2509
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define RGN_COPY
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:361
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2565
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2471

Referenced by DC_vCopyState(), NtGdiExtSelectClipRgn(), and NtGdiSelectClipPath().

◆ 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;
22  RECTL_vSetEmptyRect(&pDC->erclClip);
23  REGION_Delete(pDC->prgnRao);
24  pDC->prgnRao = NULL;
25 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
FORCEINLINE VOID RECTL_vSetEmptyRect(_Out_ RECTL *prcl)
Definition: rect.h:20
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define GdiHandleTable
Definition: win32nt.h:36
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
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2471
base of all file and directory entries
Definition: entries.h:82

Referenced by IntGdiSetMetaRgn(), and IntSetDefaultRegion().

◆ IntGdiReleaseVisRgn()

VOID FASTCALL IntGdiReleaseVisRgn ( PDC  pDC)

Definition at line 29 of file cliprgn.c.

30 {
31  INT Index = GDI_HANDLE_GET_INDEX(pDC->BaseObject.hHmgr);
33  pDC->fs |= DC_FLAG_DIRTY_RAO;
34  Entry->Flags |= GDI_ENTRY_VALIDATE_VIS;
35  RECTL_vSetEmptyRect(&pDC->erclClip);
36  REGION_Delete(pDC->prgnVis);
37  pDC->prgnVis = prgnDefault;
38 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
FORCEINLINE VOID RECTL_vSetEmptyRect(_Out_ RECTL *prcl)
Definition: rect.h:20
int32_t INT
Definition: typedefs.h:56
#define GdiHandleTable
Definition: win32nt.h:36
PREGION prgnDefault
Definition: region.c:130
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
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2471
base of all file and directory entries
Definition: entries.h:82

◆ IntGdiSetMetaRgn()

int FASTCALL IntGdiSetMetaRgn ( PDC  pDC)

Definition at line 487 of file cliprgn.c.

488 {
489  INT Ret = ERROR;
490 
491  if ( pDC->dclevel.prgnMeta )
492  {
493  if ( pDC->dclevel.prgnClip )
494  {
495  // preferably REGION_IntersectRegion
496  Ret = IntGdiCombineRgn(pDC->dclevel.prgnMeta, pDC->dclevel.prgnMeta, pDC->dclevel.prgnClip, RGN_AND);
497  if (Ret != ERROR)
498  {
499  REGION_Delete(pDC->dclevel.prgnClip);
500  pDC->dclevel.prgnClip = NULL;
501  IntGdiReleaseRaoRgn(pDC);
502  }
503  }
504  else
505  Ret = REGION_Complexity(pDC->dclevel.prgnMeta);
506  }
507  else
508  {
509  if ( pDC->dclevel.prgnClip )
510  {
511  Ret = REGION_Complexity(pDC->dclevel.prgnClip);
512  pDC->dclevel.prgnMeta = pDC->dclevel.prgnClip;
513  pDC->dclevel.prgnClip = NULL;
514  }
515  else
516  Ret = SIMPLEREGION;
517  }
518 
519  if (Ret != ERROR)
520  pDC->fs |= DC_FLAG_DIRTY_RAO;
521 
522  return Ret;
523 }
#define ERROR(name)
Definition: error_private.h:53
int32_t INT
Definition: typedefs.h:56
#define RGN_AND
Definition: wingdi.h:355
VOID FASTCALL IntGdiReleaseRaoRgn(PDC pDC)
Definition: cliprgn.c:16
smooth NULL
Definition: ftsmooth.c:416
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2509
#define DC_FLAG_DIRTY_RAO
Definition: ntgdihdl.h:132
#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:2471

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 223 of file cliprgn.c.

229 {
230  INT iComplexity;
231  RECTL rect;
232  PDC pdc;
233 
234  /* Lock the DC */
235  pdc = DC_LockDc(hdc);
236  if (pdc == NULL)
237  {
239  return ERROR;
240  }
241 
242  /* Convert coordinates to device space */
243  rect.left = xLeft;
244  rect.top = yTop;
245  rect.right = xRight;
246  rect.bottom = yBottom;
248  IntLPtoDP(pdc, (LPPOINT)&rect, 2);
249 
250  /* Check if we already have a clip region */
251  if (pdc->dclevel.prgnClip != NULL)
252  {
253  /* We have a region, subtract the rect */
254  iComplexity = REGION_SubtractRectFromRgn(pdc->dclevel.prgnClip,
255  pdc->dclevel.prgnClip,
256  &rect);
257  }
258  else
259  {
260  /* We don't have a clip region yet, create an empty region */
261  pdc->dclevel.prgnClip = IntSysCreateRectpRgn(0, 0, 0, 0);
262  if (pdc->dclevel.prgnClip == NULL)
263  {
264  iComplexity = ERROR;
265  }
266  else
267  {
268  /* Subtract the rect from the VIS region */
269  iComplexity = REGION_SubtractRectFromRgn(pdc->dclevel.prgnClip,
270  pdc->prgnVis,
271  &rect);
272  }
273  }
274 
275  /* Emulate Windows behavior */
276  if (iComplexity == SIMPLEREGION)
277  iComplexity = COMPLEXREGION;
278 
279  /* If we succeeded, mark the RAO region as dirty */
280  if (iComplexity != ERROR)
281  pdc->fs |= DC_FLAG_DIRTY_RAO;
282 
283  /* Unlock the DC */
284  DC_UnlockDc(pdc);
285 
286  return iComplexity;
287 }
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:2429
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 112 of file cliprgn.c.

116 {
117  int retval;
118  DC *dc;
119  PREGION prgn;
120 
121  if (!(dc = DC_LockDc(hDC)))
122  {
124  return ERROR;
125  }
126 
127  prgn = REGION_LockRgn(hrgn);
128 
129  if ((prgn == NULL) && (fnMode != RGN_COPY))
130  {
132  retval = ERROR;
133  }
134  else
135  {
136  retval = IntGdiExtSelectClipRgn(dc, prgn, fnMode);
137  }
138 
139  if (prgn)
140  REGION_UnlockRgn(prgn);
141 
142  DC_UnlockDc(dc);
143  return retval;
144 }
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
int FASTCALL IntGdiExtSelectClipRgn(PDC dc, PREGION prgn, int fnMode)
Definition: cliprgn.c:68
PREGION FASTCALL REGION_LockRgn(_In_ HRGN hrgn)
Definition: region.c:2380
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
Definition: polytest.cpp:40
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:2395
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 291 of file cliprgn.c.

297 {
298  INT iComplexity;
299  RECTL rect;
300  PREGION prgnNew;
301  PDC pdc;
302 
303  DPRINT("NtGdiIntersectClipRect(%p, %d,%d-%d,%d)\n",
304  hdc, xLeft, yTop, xRight, yBottom);
305 
306  /* Lock the DC */
307  pdc = DC_LockDc(hdc);
308  if (!pdc)
309  {
311  return ERROR;
312  }
313 
314  /* Convert coordinates to device space */
315  rect.left = xLeft;
316  rect.top = yTop;
317  rect.right = xRight;
318  rect.bottom = yBottom;
319  IntLPtoDP(pdc, (LPPOINT)&rect, 2);
320 
321  /* Check if we already have a clip region */
322  if (pdc->dclevel.prgnClip != NULL)
323  {
324  /* We have a region, crop it */
325  iComplexity = REGION_CropRegion(pdc->dclevel.prgnClip,
326  pdc->dclevel.prgnClip,
327  &rect);
328  }
329  else
330  {
331  /* We don't have a region yet, allocate a new one */
333  if (prgnNew == NULL)
334  {
335  iComplexity = ERROR;
336  }
337  else
338  {
339  /* Set the new region */
340  pdc->dclevel.prgnClip = prgnNew;
341  iComplexity = SIMPLEREGION;
342  }
343  }
344 
345  /* If we succeeded, mark the RAO region as dirty */
346  if (iComplexity != ERROR)
347  pdc->fs |= DC_FLAG_DIRTY_RAO;
348 
349  /* Unlock the DC */
350  DC_UnlockDc(pdc);
351 
352  return iComplexity;
353 }
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 357 of file cliprgn.c.

361 {
362  INT iComplexity;
363  PDC pdc;
364  POINTL apt[2];
365 
366  /* Lock the DC */
367  pdc = DC_LockDc(hdc);
368  if (pdc == NULL)
369  {
370  return ERROR;
371  }
372 
373  /* Check if we have a clip region */
374  if (pdc->dclevel.prgnClip != NULL)
375  {
376  /* Convert coordinates into device space. Note that we need to convert
377  2 coordinates to account for rotation / shear / offset */
378  apt[0].x = 0;
379  apt[0].y = 0;
380  apt[1].x = xOffset;
381  apt[1].y = yOffset;
382  IntLPtoDP(pdc, &apt, 2);
383 
384  /* Offset the clip region */
385  if (!REGION_bOffsetRgn(pdc->dclevel.prgnClip,
386  apt[1].x - apt[0].x,
387  apt[1].y - apt[0].y))
388  {
389  iComplexity = ERROR;
390  }
391  else
392  {
393  iComplexity = REGION_Complexity(pdc->dclevel.prgnClip);
394  }
395 
396  /* Mark the RAO region as dirty */
397  pdc->fs |= DC_FLAG_DIRTY_RAO;
398  }
399  else
400  {
401  /* NULL means no clipping, i.e. the "whole" region */
402  iComplexity = SIMPLEREGION;
403  }
404 
405  /* Unlock the DC and return the complexity */
406  DC_UnlockDc(pdc);
407  return iComplexity;
408 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR(name)
Definition: error_private.h:53
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2730
int32_t INT
Definition: typedefs.h:56
LONG y
Definition: windef.h:315
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

Referenced by OffsetClipRgn().

◆ NtGdiPtVisible()

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

Definition at line 410 of file cliprgn.c.

413 {
414  BOOL ret = FALSE;
415  PDC dc;
416 
417  if(!(dc = DC_LockDc(hDC)))
418  {
420  return FALSE;
421  }
422 
423  if (dc->prgnRao)
424  {
425  POINT pt = {X, Y};
426  IntLPtoDP(dc, &pt, 1);
427  ret = REGION_PtInRegion(dc->prgnRao, pt.x, pt.y);
428  }
429 
430  DC_UnlockDc(dc);
431 
432  return ret;
433 }
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: 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:2605

◆ NtGdiRectVisible()

BOOL APIENTRY NtGdiRectVisible ( HDC  hDC,
LPRECT  UnsafeRect 
)

Definition at line 437 of file cliprgn.c.

440 {
442  PDC dc = DC_LockDc(hDC);
443  BOOL Result = FALSE;
444  RECTL Rect;
445 
446  if (!dc)
447  {
449  return FALSE;
450  }
451 
452  _SEH2_TRY
453  {
454  ProbeForRead(UnsafeRect,
455  sizeof(RECT),
456  1);
457  Rect = *UnsafeRect;
458  }
460  {
462  }
463  _SEH2_END;
464 
465  if(!NT_SUCCESS(Status))
466  {
467  DC_UnlockDc(dc);
469  return FALSE;
470  }
471 
472  if (dc->fs & DC_FLAG_DIRTY_RAO)
474 
475  if (dc->prgnRao)
476  {
477  IntLPtoDP(dc, (LPPOINT)&Rect, 2);
478  Result = REGION_RectInRegion(dc->prgnRao, &Rect);
479  }
480  DC_UnlockDc(dc);
481 
482  return Result;
483 }
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:2628
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:544
#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:2725
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
struct Rect Rect

◆ NtGdiSetMetaRgn()

int APIENTRY NtGdiSetMetaRgn ( HDC  hDC)

Definition at line 526 of file cliprgn.c.

527 {
528  INT Ret;
529  PDC pDC = DC_LockDc(hDC);
530 
531  if (!pDC)
532  {
534  return ERROR;
535  }
536  Ret = IntGdiSetMetaRgn(pDC);
537 
538  DC_UnlockDc(pDC);
539  return Ret;
540 }
#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:487
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27