ReactOS 0.4.15-dev-5672-gf73ac17
clip.c File Reference
#include <win32k.h>
Include dependency graph for clip.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (EngClip)
 
static __inline int CompareRightDown (const RECTL *r1, const RECTL *r2)
 
static __inline int CompareRightUp (const RECTL *r1, const RECTL *r2)
 
static __inline int CompareLeftDown (const RECTL *r1, const RECTL *r2)
 
static __inline int CompareLeftUp (const RECTL *r1, const RECTL *r2)
 
VOID FASTCALL IntEngInitClipObj (XCLIPOBJ *Clip)
 
VOID FASTCALL IntEngFreeClipResources (XCLIPOBJ *Clip)
 
VOID FASTCALL IntEngUpdateClipRegion (XCLIPOBJ *Clip, ULONG count, const RECTL *pRect, const RECTL *rcBounds)
 
CLIPOBJ *APIENTRY EngCreateClip (VOID)
 
VOID APIENTRY EngDeleteClip (_In_ _Post_ptr_invalid_ CLIPOBJ *pco)
 
ULONG APIENTRY CLIPOBJ_cEnumStart (_Inout_ CLIPOBJ *pco, _In_ BOOL bAll, _In_ ULONG iType, _In_ ULONG iDirection, _In_ ULONG cMaxRects)
 
BOOL APIENTRY CLIPOBJ_bEnum (_In_ CLIPOBJ *pco, _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pulEnumRects)
 

Function Documentation

◆ CLIPOBJ_bEnum()

BOOL APIENTRY CLIPOBJ_bEnum ( _In_ CLIPOBJ pco,
_In_ ULONG  cj,
_Out_bytecap_(cj) ULONG pulEnumRects 
)

Definition at line 319 of file clip.c.

323{
324 const RECTL* src;
325 XCLIPOBJ* Clip = (XCLIPOBJ *)pco;
326 ULONG nCopy;
327 ENUMRECTS* pERects = (ENUMRECTS*)pulEnumRects;
328
329 // Calculate how many rectangles we should copy
330 nCopy = min( Clip->EnumMax - Clip->EnumPos,
331 min( Clip->RectCount - Clip->EnumPos,
332 (cj - sizeof(ULONG)) / sizeof(RECTL)));
333
334 if(nCopy == 0)
335 {
336 return FALSE;
337 }
338
339 /* Copy rectangles */
340 src = &Clip->Rects[Clip->EnumPos];
341 RtlCopyMemory(pERects->arcl, src, nCopy * sizeof(RECTL));
342
343 pERects->c = nCopy;
344
345 Clip->EnumPos+=nCopy;
346
347 return Clip->EnumPos < Clip->RectCount;
348}
#define FALSE
Definition: types.h:117
GLenum src
Definition: glext.h:6340
#define min(a, b)
Definition: monoChain.cc:55
RECTL arcl[1]
Definition: winddi.h:577
ULONG c
Definition: winddi.h:576
ULONG EnumMax
Definition: engobjects.h:70
RECTL * Rects
Definition: engobjects.h:65
DWORD RectCount
Definition: engobjects.h:78
ULONG EnumPos
Definition: engobjects.h:68
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
_In_ ULONG cj
Definition: winddi.h:3540
_In_ SURFOBJ _In_ CLIPOBJ * pco
Definition: winddi.h:3415

Referenced by DrvBitBlt(), DrvLineTo(), EngAlphaBlend(), EngBitBlt(), EngCopyBits(), EngLineTo(), EngMaskBitBlt(), EngStretchBltROP(), EngTransparentBlt(), IntEngGradientFillRect(), IntEngGradientFillTriangle(), NEtoSW(), NWtoSE(), SEtoNW(), SWtoNE(), VGADDIPaintRgn(), vgaNEtoSW(), vgaNWtoSE(), vgaSEtoNW(), vgaSWtoNE(), and WNDOBJ_bEnum().

◆ CLIPOBJ_cEnumStart()

ULONG APIENTRY CLIPOBJ_cEnumStart ( _Inout_ CLIPOBJ pco,
_In_ BOOL  bAll,
_In_ ULONG  iType,
_In_ ULONG  iDirection,
_In_ ULONG  cMaxRects 
)

Definition at line 255 of file clip.c.

261{
262 XCLIPOBJ* Clip = (XCLIPOBJ *)pco;
263 SORTCOMP CompareFunc;
264
265 Clip->bAll = bAll;
266 Clip->iType = iType;
267 Clip->EnumPos = 0;
268 Clip->EnumMax = (cMaxRects > 0) ? cMaxRects : Clip->RectCount;
269
270 if (CD_ANY != iDirection && Clip->iDirection != iDirection)
271 {
272 switch (iDirection)
273 {
274 case CD_RIGHTDOWN:
275 CompareFunc = (SORTCOMP) CompareRightDown;
276 break;
277
278 case CD_RIGHTUP:
279 CompareFunc = (SORTCOMP) CompareRightUp;
280 break;
281
282 case CD_LEFTDOWN:
283 CompareFunc = (SORTCOMP) CompareLeftDown;
284 break;
285
286 case CD_LEFTUP:
287 CompareFunc = (SORTCOMP) CompareLeftUp;
288 break;
289
290 default:
291 ERR("Invalid iDirection %lu\n", iDirection);
292 iDirection = Clip->iDirection;
294 break;
295 }
296
297 if (NULL != CompareFunc)
298 {
299 EngSort((PBYTE) Clip->Rects, sizeof(RECTL), Clip->RectCount, CompareFunc);
300 }
301
302 Clip->iDirection = iDirection;
303 }
304
305 /* Return the number of rectangles enumerated */
306 if ((cMaxRects > 0) && (Clip->RectCount > cMaxRects))
307 {
308 return 0xFFFFFFFF;
309 }
310
311 return Clip->RectCount;
312}
static INT CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: mainwnd.c:243
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
if(dx< 0)
Definition: linetemp.h:194
BYTE * PBYTE
Definition: pedump.c:66
ULONG iDirection
Definition: engobjects.h:71
ULONG iType
Definition: engobjects.h:72
BOOL bAll
Definition: engobjects.h:76
static __inline int CompareRightUp(const RECTL *r1, const RECTL *r2)
Definition: clip.c:50
static __inline int CompareRightDown(const RECTL *r1, const RECTL *r2)
Definition: clip.c:14
static __inline int CompareLeftDown(const RECTL *r1, const RECTL *r2)
Definition: clip.c:86
static __inline int CompareLeftUp(const RECTL *r1, const RECTL *r2)
Definition: clip.c:122
#define CD_RIGHTUP
Definition: winddi.h:1323
#define CD_LEFTDOWN
Definition: winddi.h:1321
#define CD_RIGHTDOWN
Definition: winddi.h:1320
#define CD_ANY
Definition: winddi.h:1326
_In_ ULONG iType
Definition: winddi.h:3748
ENGAPI VOID APIENTRY EngSort(_Inout_updates_bytes_(c *cjElem) PBYTE pjBuf, _In_ ULONG c, _In_ ULONG cjElem, _In_ SORTCOMP pfnComp)
#define CD_LEFTUP
Definition: winddi.h:1325

Referenced by DrvBitBlt(), DrvLineTo(), EngAlphaBlend(), EngBitBlt(), EngCopyBits(), EngLineTo(), EngMaskBitBlt(), EngStretchBltROP(), EngTransparentBlt(), IntEngGradientFillRect(), IntEngGradientFillTriangle(), NEtoSW(), NWtoSE(), SEtoNW(), SWtoNE(), VGADDIPaintRgn(), vgaNEtoSW(), vgaNWtoSE(), vgaSEtoNW(), vgaSWtoNE(), and WNDOBJ_cEnumStart().

◆ CompareLeftDown()

static __inline int CompareLeftDown ( const RECTL r1,
const RECTL r2 
)
static

Definition at line 86 of file clip.c.

89{
90 int Cmp;
91
92 if (r1->top < r2->top)
93 {
94 Cmp = -1;
95 }
96 else if (r2->top < r1->top)
97 {
98 Cmp = +1;
99 }
100 else
101 {
102 ASSERT(r1->bottom == r2->bottom);
103 if (r1->right < r2->right)
104 {
105 Cmp = +1;
106 }
107 else if (r2->right < r1->right)
108 {
109 Cmp = -1;
110 }
111 else
112 {
113 ASSERT(r1->left == r2->left);
114 Cmp = 0;
115 }
116 }
117
118 return Cmp;
119}
#define ASSERT(a)
Definition: mode.c:44
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38

Referenced by CLIPOBJ_cEnumStart().

◆ CompareLeftUp()

static __inline int CompareLeftUp ( const RECTL r1,
const RECTL r2 
)
static

Definition at line 122 of file clip.c.

125{
126 int Cmp;
127
128 if (r1->bottom < r2->bottom)
129 {
130 Cmp = +1;
131 }
132 else if (r2->bottom < r1->bottom)
133 {
134 Cmp = -1;
135 }
136 else
137 {
138 ASSERT(r1->top == r2->top);
139 if (r1->right < r2->right)
140 {
141 Cmp = +1;
142 }
143 else if (r2->right < r1->right)
144 {
145 Cmp = -1;
146 }
147 else
148 {
149 ASSERT(r1->left == r2->left);
150 Cmp = 0;
151 }
152 }
153 return Cmp;
154}

Referenced by CLIPOBJ_cEnumStart().

◆ CompareRightDown()

static __inline int CompareRightDown ( const RECTL r1,
const RECTL r2 
)
static

Definition at line 14 of file clip.c.

17{
18 int Cmp;
19
20 if (r1->top < r2->top)
21 {
22 Cmp = -1;
23 }
24 else if (r2->top < r1->top)
25 {
26 Cmp = +1;
27 }
28 else
29 {
30 ASSERT(r1->bottom == r2->bottom);
31 if (r1->left < r2->left)
32 {
33 Cmp = -1;
34 }
35 else if (r2->left < r1->left)
36 {
37 Cmp = +1;
38 }
39 else
40 {
41 ASSERT(r1->right == r2->right);
42 Cmp = 0;
43 }
44 }
45
46 return Cmp;
47}

Referenced by CLIPOBJ_cEnumStart().

◆ CompareRightUp()

static __inline int CompareRightUp ( const RECTL r1,
const RECTL r2 
)
static

Definition at line 50 of file clip.c.

53{
54 int Cmp;
55
56 if (r1->bottom < r2->bottom)
57 {
58 Cmp = +1;
59 }
60 else if (r2->bottom < r1->bottom)
61 {
62 Cmp = -1;
63 }
64 else
65 {
66 ASSERT(r1->top == r2->top);
67 if (r1->left < r2->left)
68 {
69 Cmp = -1;
70 }
71 else if (r2->left < r1->left)
72 {
73 Cmp = +1;
74 }
75 else
76 {
77 ASSERT(r1->right == r2->right);
78 Cmp = 0;
79 }
80 }
81
82 return Cmp;
83}

Referenced by CLIPOBJ_cEnumStart().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( EngClip  )

◆ EngCreateClip()

CLIPOBJ *APIENTRY EngCreateClip ( VOID  )

Definition at line 222 of file clip.c.

223{
225 if(Clip != NULL)
226 {
227 IntEngInitClipObj(Clip);
228 TRACE("Created Clip Obj %p.\n", Clip);
229 return (CLIPOBJ *)Clip;
230 }
231
232 ERR("Clip object allocation failed!\n");
233 return NULL;
234}
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL IntEngInitClipObj(XCLIPOBJ *Clip)
Definition: clip.c:158
#define GDITAG_CLIPOBJ
Definition: tags.h:78

Referenced by EngLineTo(), and IntEngEnter().

◆ EngDeleteClip()

VOID APIENTRY EngDeleteClip ( _In_ _Post_ptr_invalid_ CLIPOBJ pco)

Definition at line 241 of file clip.c.

243{
244 XCLIPOBJ* pxco = (XCLIPOBJ *)pco;
245 TRACE("Deleting %p.\n", pco);
247 EngFreeMem(pxco);
248}
#define EngFreeMem
Definition: polytest.cpp:56
VOID FASTCALL IntEngFreeClipResources(XCLIPOBJ *Clip)
Definition: clip.c:164

Referenced by EngLineTo(), IntEngEnter(), and IntEngLeave().

◆ IntEngFreeClipResources()

VOID FASTCALL IntEngFreeClipResources ( XCLIPOBJ Clip)

Definition at line 164 of file clip.c.

165{
166 if (Clip->Rects != &Clip->rclBounds)
167 EngFreeMem(Clip->Rects);
168}

Referenced by DC_vCleanup(), EngDeleteClip(), EngDeleteWnd(), IntGdiBitBltRgn(), and IntGdiFillRgn().

◆ IntEngInitClipObj()

VOID FASTCALL IntEngInitClipObj ( XCLIPOBJ Clip)

Definition at line 158 of file clip.c.

159{
160 Clip->Rects = &Clip->rclBounds;
161}

Referenced by DC_vInitDc(), EngCreateClip(), EngCreateWnd(), IntGdiBitBltRgn(), and IntGdiFillRgn().

◆ IntEngUpdateClipRegion()

VOID FASTCALL IntEngUpdateClipRegion ( XCLIPOBJ Clip,
ULONG  count,
const RECTL pRect,
const RECTL rcBounds 
)

Definition at line 173 of file clip.c.

178{
179 if(count > 1)
180 {
182
183 if(NewRects != NULL)
184 {
185 Clip->RectCount = count;
186 Clip->iDirection = CD_ANY;
187 RtlCopyMemory(NewRects, pRect, count * sizeof(RECTL));
188
189 Clip->iDComplexity = DC_COMPLEX;
190 Clip->iFComplexity = ((Clip->RectCount <= 4) ? FC_RECT4 : FC_COMPLEX);
191 Clip->iMode = TC_RECTANGLES;
192 Clip->rclBounds = *rcBounds;
193
194 if (Clip->Rects != &Clip->rclBounds)
195 EngFreeMem(Clip->Rects);
196 Clip->Rects = NewRects;
197 }
198 }
199 else
200 {
201 Clip->iDirection = CD_ANY;
202
203 Clip->iDComplexity = (((rcBounds->top == rcBounds->bottom) &&
204 (rcBounds->left == rcBounds->right))
205 ? DC_TRIVIAL : DC_RECT);
206
207 Clip->iFComplexity = FC_RECT;
208 Clip->iMode = TC_RECTANGLES;
209 Clip->rclBounds = *rcBounds;
210 Clip->RectCount = 1;
211 if (Clip->Rects != &Clip->rclBounds)
212 EngFreeMem(Clip->Rects);
213 Clip->Rects = &Clip->rclBounds;
214 }
215}
GLuint GLuint GLsizei count
Definition: gl.h:1545
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define DC_TRIVIAL
Definition: winddi.h:259
#define FC_RECT4
Definition: winddi.h:265
#define FC_COMPLEX
Definition: winddi.h:266
#define DC_COMPLEX
Definition: winddi.h:261
#define DC_RECT
Definition: winddi.h:260
#define FC_RECT
Definition: winddi.h:264
#define TC_RECTANGLES
Definition: winddi.h:269

Referenced by CLIPPING_UpdateGCRegion(), EngLineTo(), IntEngWndUpdateClipObj(), IntGdiBitBltRgn(), and IntGdiFillRgn().