6 SortRects(PRECT pRect
, INT nCount
)
8 INT i
= 0, a
= 0, b
= 0, c
, s
;
13 i
= 1; // set index point
14 c
= nCount
; // set inverse count
17 s
= i
; // set sort count
24 if(pRect
[b
].top
!= pRect
[i
].bottom
) break;
25 if(pRect
[b
].left
< pRect
[a
].left
)
33 } while ( s
< nCount
);
41 * I thought it was okay to have this in DeleteObject but~ Speed. (jt)
45 DeleteRegion( HRGN hRgn
)
50 if ((GdiGetHandleUserData((HGDIOBJ
) hRgn
, GDI_OBJECT_TYPE_REGION
, (PVOID
) &Rgn_Attr
)) &&
53 PTEB pTeb
= NtCurrentTeb();
54 if (pTeb
->Win32ThreadInfo
!= NULL
)
56 if ((pTeb
->GdiTebBatch
.Offset
+ sizeof(GDIBSOBJECT
)) <= GDIBATCHBUFSIZE
)
58 PGDIBSOBJECT pgO
= (PGDIBSOBJECT
)(&pTeb
->GdiTebBatch
.Buffer
[0] +
59 pTeb
->GdiTebBatch
.Offset
);
60 pgO
->gbHdr
.Cmd
= GdiBCDelRgn
;
61 pgO
->gbHdr
.Size
= sizeof(GDIBSOBJECT
);
62 pgO
->hgdiobj
= (HGDIOBJ
)hRgn
;
64 pTeb
->GdiTebBatch
.Offset
+= sizeof(GDIBSOBJECT
);
65 pTeb
->GdiBatchCount
++;
66 if (pTeb
->GdiBatchCount
>= GDI_BatchLimit
) NtGdiFlush();
72 return NtGdiDeleteObjectApp((HGDIOBJ
) hRgn
);
77 MirrorRgnByWidth(HRGN hRgn
, INT Width
, HRGN
*phRgn
)
79 INT cRgnDSize
, Ret
= 0;
82 cRgnDSize
= NtGdiGetRegionData(hRgn
, 0, NULL
);
86 pRgnData
= LocalAlloc(LMEM_FIXED
, cRgnDSize
* sizeof(LONG
));
89 if ( GetRegionData(hRgn
, cRgnDSize
, pRgnData
) )
93 INT SaveL
= pRgnData
->rdh
.rcBound
.left
;
94 pRgnData
->rdh
.rcBound
.left
= Width
- pRgnData
->rdh
.rcBound
.right
;
95 pRgnData
->rdh
.rcBound
.right
= Width
- SaveL
;
96 if (pRgnData
->rdh
.nCount
> 0)
98 PRECT pRect
= (PRECT
)&pRgnData
->Buffer
;
99 for (i
= 0; i
< pRgnData
->rdh
.nCount
; i
++)
101 SaveL
= pRect
[i
].left
;
102 pRect
[i
].left
= Width
- pRect
[i
].right
;
103 pRect
[i
].right
= Width
- SaveL
;
106 SortRects((PRECT
)&pRgnData
->Buffer
, pRgnData
->rdh
.nCount
);
107 hRgnex
= ExtCreateRegion(NULL
, cRgnDSize
, pRgnData
);
110 if (phRgn
) phRgn
= (HRGN
*)hRgnex
;
113 CombineRgn(hRgn
, hRgnex
, 0, RGN_COPY
);
114 DeleteObject(hRgnex
);
127 MirrorRgnDC(HDC hdc
, HRGN hRgn
, HRGN
*phRgn
)
129 if (!GdiIsHandleValid((HGDIOBJ
) hdc
) ||
130 (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)) return 0;
132 return MirrorRgnByWidth(hRgn
, NtGdiGetDeviceWidth(hdc
), phRgn
);
135 /* FUNCTIONS *****************************************************************/
142 CombineRgn(HRGN hDest
,
147 /* FIXME some part should be done in user mode */
148 return NtGdiCombineRgn(hDest
, hSrc1
, hSrc2
, CombineMode
);
156 CreatePolygonRgn( const POINT
* lppt
, int cPoints
, int fnPolyFillMode
)
158 return (HRGN
) NtGdiPolyPolyDraw( (HDC
) fnPolyFillMode
, (PPOINT
) lppt
, (PULONG
) &cPoints
, 1, GdiPolyPolyRgn
);
166 CreatePolyPolygonRgn( const POINT
* lppt
,
167 const INT
* lpPolyCounts
,
171 return (HRGN
) NtGdiPolyPolyDraw( (HDC
) fnPolyFillMode
, (PPOINT
) lppt
, (PULONG
) lpPolyCounts
, (ULONG
) nCount
, GdiPolyPolyRgn
);
179 CreateEllipticRgnIndirect(
183 /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
184 return NtGdiCreateEllipticRgn(prc
->left
, prc
->top
, prc
->right
, prc
->bottom
);
193 CreateRectRgn(int x1
, int y1
, int x2
,int y2
)
195 /* FIXME Some part need be done in user mode */
196 return NtGdiCreateRectRgn(x1
,y1
,x2
,y2
);
204 CreateRectRgnIndirect(
208 /* Notes if prc is NULL it will crash on All Windows NT I checked 2000/XP/VISTA */
209 return CreateRectRgn(prc
->left
, prc
->top
, prc
->right
, prc
->bottom
);
218 ExcludeClipRect(IN HDC hdc
, IN INT xLeft
, IN INT yTop
, IN INT xRight
, IN INT yBottom
)
220 /* FIXME some part need be done on user mode size */
221 return NtGdiExcludeClipRect(hdc
, xLeft
, yTop
, xRight
, yBottom
);
230 CONST XFORM
* lpXform
,
232 CONST RGNDATA
* lpRgnData
237 if ((!lpXform
) && (lpRgnData
->rdh
.nCount
== 1))
239 PRECT pRect
= (PRECT
)&lpRgnData
->Buffer
[0];
240 return CreateRectRgn(pRect
->left
, pRect
->top
, pRect
->right
, pRect
->bottom
);
242 return NtGdiExtCreateRegion((LPXFORM
) lpXform
, nCount
,(LPRGNDATA
) lpRgnData
);
244 SetLastError(ERROR_INVALID_PARAMETER
);
253 ExtSelectClipRgn( IN HDC hdc
, IN HRGN hrgn
, IN INT iMode
)
255 /* FIXME some part need be done on user mode size */
256 return NtGdiExtSelectClipRgn(hdc
,hrgn
, iMode
);
269 INT Ret
= NtGdiGetRandomRgn(hdc
, hrgn
, CLIPRGN
);
272 // if(GetLayout(hdc) & LAYOUT_RTL) MirrorRgnDC(hdc,(HRGN)Ret, NULL);
285 return NtGdiGetRandomRgn(hdc
, hrgn
, METARGN
);
299 if (!GdiGetHandleUserData((HGDIOBJ
) hRgn
, GDI_OBJECT_TYPE_REGION
, (PVOID
) &Rgn_Attr
))
300 return NtGdiGetRgnBox(hrgn
, prcOut
);
301 if (Rgn_Attr
->Flags
== NULLREGION
)
310 if (Rgn_Attr
->Flags
!= SIMPLEREGION
) return NtGdiGetRgnBox(hrgn
, prcOut
);
311 *prcOut
= Rgn_Attr
->Rect
;
313 return Rgn_Attr
->Flags
;
315 return NtGdiGetRgnBox(hrgn
, prcOut
);
323 IntersectClipRect(HDC hdc
,
330 // Handle something other than a normal dc object.
331 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
333 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
334 return MFDRV_IntersectClipRect( hdc
, nLeftRect
, nTopRect
, nRightRect
, nBottomRect
);
337 PLDC pLDC
= GdiGetLDC(hdc
);
340 if (pLDC
->iType
!= LDC_EMFLDC
|| EMFDRV_IntersectClipRect( hdc
, nLeftRect
, nTopRect
, nRightRect
, nBottomRect
))
341 return NtGdiIntersectClipRect(hdc
, nLeftRect
, nTopRect
, nRightRect
, nBottomRect
);
344 SetLastError(ERROR_INVALID_HANDLE
);
349 return NtGdiIntersectClipRect(hdc
, nLeftRect
, nTopRect
, nRightRect
, nBottomRect
);
357 MirrorRgn(HWND hwnd
, HRGN hrgn
)
360 GetWindowRect(hwnd
, &Rect
);
361 return MirrorRgnByWidth(hrgn
, Rect
.right
- Rect
.left
, NULL
);
369 OffsetClipRgn(HDC hdc
,
374 // Handle something other than a normal dc object.
375 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
377 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
378 return MFDRV_OffsetClipRgn( hdc
, nXOffset
, nYOffset
);
381 PLDC pLDC
= GdiGetLDC(hdc
);
384 SetLastError(ERROR_INVALID_HANDLE
);
387 if (pLDC
->iType
== LDC_EMFLDC
&& !EMFDRV_OffsetClipRgn( hdc
, nXOffset
, nYOffset
))
389 return NtGdiOffsetClipRgn( hdc
, nXOffset
, nYOffset
);
393 return NtGdiOffsetClipRgn( hdc
, nXOffset
, nYOffset
);
402 OffsetRgn( HRGN hrgn
,
406 /* FIXME some part are done in user mode */
407 return NtGdiOffsetRgn(hrgn
,nXOffset
,nYOffset
);
415 PtInRegion(IN HRGN hrgn
,
419 /* FIXME some stuff at user mode need be fixed */
420 return NtGdiPtInRegion(hrgn
,x
,y
);
428 RectInRegion(HRGN hrgn
,
431 /* FIXME some stuff at user mode need be fixed */
432 return NtGdiRectInRegion(hrgn
, (LPRECT
) prcl
);
444 return ExtSelectClipRgn(hdc
, hrgn
, RGN_COPY
);
452 SetRectRgn(HRGN hrgn
,
460 if (!GdiGetHandleUserData((HGDIOBJ
) hrgn
, GDI_OBJECT_TYPE_REGION
, (PVOID
) &Rgn_Attr
))
461 return NtGdiSetRectRgn(hrgn
, nLeftRect
, nTopRect
, nRightRect
, nBottomRect
);
463 if ((nLeftRect
== nRightRect
) || (nTopRect
== nBottomRect
))
465 Rgn_Attr
->AttrFlags
|= ATTR_RGN_DIRTY
;
466 Rgn_Attr
->Flags
= NULLREGION
;
467 Rgn_Attr
->Rect
.left
= Rgn_Attr
->Rect
.top
=
468 Rgn_Attr
->Rect
.right
= Rgn_Attr
->Rect
.bottom
= 0;
472 Rgn_Attr
->Rect
.left
= nLeftRect
;
473 Rgn_Attr
->Rect
.top
= nTopRect
;
474 Rgn_Attr
->Rect
.right
= nRightRect
;
475 Rgn_Attr
->Rect
.bottom
= nBottomRect
;
477 if(nLeftRect
> nRightRect
)
479 Rgn_Attr
->Rect
.left
= nRightRect
;
480 Rgn_Attr
->Rect
.right
= nLeftRect
;
482 if(nTopRect
> nBottomRect
)
484 Rgn_Attr
->Rect
.top
= nBottomRect
;
485 Rgn_Attr
->Rect
.bottom
= nTopRect
;
488 Rgn_Attr
->AttrFlags
|= ATTR_RGN_DIRTY
;
489 Rgn_Attr
->Flags
= SIMPLEREGION
;
498 SetMetaRgn( HDC hDC
)
500 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_DC
)
501 return NtGdiSetMetaRgn(hDC
);
503 PLDC pLDC
= GdiGetLDC(hDC
);
504 if ( pLDC
&& GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_METADC
)
506 if (pLDC
->iType
== LDC_EMFLDC
|| EMFDRV_SetMetaRgn(hDC
))
508 return NtGdiSetMetaRgn(hDC
);
511 SetLastError(ERROR_INVALID_HANDLE
);