13 ExtCreatePen(DWORD dwPenStyle
,
19 PVOID lpPackedDIB
= NULL
;
21 PBITMAPINFO pConvertedInfo
= NULL
;
22 UINT ConvertedInfoSize
= 0, lbStyle
;
25 if ((dwPenStyle
& PS_STYLE_MASK
) == PS_USERSTYLE
)
29 SetLastError(ERROR_INVALID_PARAMETER
);
32 } // This is an enhancement and prevents a call to kernel space.
33 else if ((dwPenStyle
& PS_STYLE_MASK
) == PS_INSIDEFRAME
&&
34 (dwPenStyle
& PS_TYPE_MASK
) != PS_GEOMETRIC
)
36 SetLastError(ERROR_INVALID_PARAMETER
);
39 else if ((dwPenStyle
& PS_STYLE_MASK
) == PS_ALTERNATE
&&
40 (dwPenStyle
& PS_TYPE_MASK
) != PS_COSMETIC
)
42 SetLastError(ERROR_INVALID_PARAMETER
);
47 if (dwStyleCount
|| lpStyle
)
49 SetLastError(ERROR_INVALID_PARAMETER
);
54 lbStyle
= lplb
->lbStyle
;
56 if (lplb
->lbStyle
> BS_HATCHED
)
58 if (lplb
->lbStyle
== BS_PATTERN
)
60 pConvertedInfo
= (PBITMAPINFO
)lplb
->lbHatch
;
61 if (!pConvertedInfo
) return 0;
65 if ((lplb
->lbStyle
== BS_DIBPATTERN
) || (lplb
->lbStyle
== BS_DIBPATTERNPT
))
67 if (lplb
->lbStyle
== BS_DIBPATTERN
)
69 lbStyle
= BS_DIBPATTERNPT
;
70 lpPackedDIB
= GlobalLock((HGLOBAL
)lplb
->lbHatch
);
71 if (lpPackedDIB
== NULL
) return 0;
73 pConvertedInfo
= ConvertBitmapInfo((PBITMAPINFO
)lpPackedDIB
,
77 Hit
= TRUE
; // We converted DIB.
80 pConvertedInfo
= (PBITMAPINFO
)lpStyle
;
84 pConvertedInfo
= (PBITMAPINFO
)lplb
->lbHatch
;
87 hPen
= NtGdiExtCreatePen(dwPenStyle
,
92 (ULONG_PTR
)pConvertedInfo
,
100 if (lplb
->lbStyle
== BS_DIBPATTERN
) GlobalUnlock((HGLOBAL
)lplb
->lbHatch
);
104 if ((PBITMAPINFO
)lpPackedDIB
!= pConvertedInfo
)
105 RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo
);
114 CreateDIBPatternBrush(
115 HGLOBAL hglbDIBPacked
,
119 HBRUSH hBrush
= NULL
;
120 PBITMAPINFO pConvertedInfo
;
121 UINT ConvertedInfoSize
;
123 lpPackedDIB
= GlobalLock(hglbDIBPacked
);
124 if (lpPackedDIB
== NULL
)
127 pConvertedInfo
= ConvertBitmapInfo((PBITMAPINFO
)lpPackedDIB
, fuColorSpec
,
128 &ConvertedInfoSize
, TRUE
);
131 hBrush
= NtGdiCreateDIBBrush(pConvertedInfo
, fuColorSpec
,
132 ConvertedInfoSize
, FALSE
, FALSE
, lpPackedDIB
);
133 if ((PBITMAPINFO
)lpPackedDIB
!= pConvertedInfo
)
134 RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo
);
137 GlobalUnlock(hglbDIBPacked
);
146 CreateDIBPatternBrushPt(
147 CONST VOID
*lpPackedDIB
,
150 HBRUSH hBrush
= NULL
;
151 PBITMAPINFO pConvertedInfo
;
152 UINT ConvertedInfoSize
;
154 if (lpPackedDIB
== NULL
)
157 pConvertedInfo
= ConvertBitmapInfo((PBITMAPINFO
)lpPackedDIB
, fuColorSpec
,
158 &ConvertedInfoSize
, TRUE
);
161 hBrush
= NtGdiCreateDIBBrush(pConvertedInfo
, fuColorSpec
,
162 ConvertedInfoSize
, FALSE
, FALSE
, (PVOID
)lpPackedDIB
);
163 if ((PBITMAPINFO
)lpPackedDIB
!= pConvertedInfo
)
164 RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo
);
175 CreateHatchBrush(INT fnStyle
,
178 return NtGdiCreateHatchBrushInternal(fnStyle
, clrref
, FALSE
);
186 CreatePatternBrush(HBITMAP hbmp
)
188 return NtGdiCreatePatternBrushInternal(hbmp
, FALSE
, FALSE
);
196 CreateSolidBrush(IN COLORREF crColor
)
198 /* Call Server-Side API */
199 return NtGdiCreateSolidBrush(crColor
, NULL
);
207 CONST LOGBRUSH
*LogBrush
)
211 switch (LogBrush
->lbStyle
)
213 case BS_DIBPATTERN8X8
:
215 hBrush
= CreateDIBPatternBrush((HGLOBAL
)LogBrush
->lbHatch
,
219 case BS_DIBPATTERNPT
:
220 hBrush
= CreateDIBPatternBrushPt((PVOID
)LogBrush
->lbHatch
,
225 hBrush
= NtGdiCreatePatternBrushInternal((HBITMAP
)LogBrush
->lbHatch
,
231 hBrush
= NtGdiCreatePatternBrushInternal((HBITMAP
)LogBrush
->lbHatch
,
237 /* hBrush = hGetPEBHandle(hctBrushHandle, LogBrush->lbColor);
239 hBrush
= NtGdiCreateSolidBrush(LogBrush
->lbColor
, 0);
243 hBrush
= NtGdiCreateHatchBrushInternal(LogBrush
->lbHatch
,
249 hBrush
= NtGdiGetStockObject(NULL_BRUSH
);
253 SetLastError(ERROR_INVALID_PARAMETER
);
270 /* FIXME some part need be done in user mode */
271 return NtGdiPatBlt( hdc
, nXLeft
, nYLeft
, nWidth
, nHeight
, dwRop
);
276 PolyPatBlt(IN HDC hdc
,
278 IN PPOLYPATBLT pPoly
,
282 /* FIXME some part need be done in user mode */
283 return NtGdiPolyPatBlt(hdc
, rop4
, pPoly
,Count
,Mode
);
295 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return 0;
296 return Dc_Attr
->jROP2
;
311 // Handle something other than a normal dc object.
312 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
314 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
315 return MFDRV_SetROP2( hdc
, fnDrawMode
);
318 PLDC pLDC
= GdiGetLDC(hdc
);
321 SetLastError(ERROR_INVALID_HANDLE
);
324 if (pLDC
->iType
== LDC_EMFLDC
)
326 return EMFDRV_SetROP2(( hdc
, fnDrawMode
);
332 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
334 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
336 if (Dc_Attr
->ulDirty_
& DC_MODE_DIRTY
)
339 Dc_Attr
->ulDirty_
&= ~DC_MODE_DIRTY
;
343 Old_ROP2
= Dc_Attr
->jROP2
;
344 Dc_Attr
->jROP2
= fnDrawMode
;
355 GetBrushOrgEx(HDC hdc
,LPPOINT pt
)
359 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
362 pt
->x
= Dc_Attr
->ptlBrushOrigin
.x
;
363 pt
->y
= Dc_Attr
->ptlBrushOrigin
.y
;
373 SetBrushOrgEx(HDC hdc
,
380 // Handle something other than a normal dc object.
381 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
383 PLDC pLDC
= GdiGetLDC(hdc
);
384 if ( (pLDC
== NULL
) || (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
))
386 SetLastError(ERROR_INVALID_HANDLE
);
389 if (pLDC
->iType
== LDC_EMFLDC
)
391 return EMFDRV_SetBrushOrg(hdc
, nXOrg
, nYOrg
); // ReactOS only.
396 if (GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
)&Dc_Attr
))
398 PGDIBSSETBRHORG pgSBO
;
400 /* Does the caller want the current brush origin to be returned? */
403 lppt
->x
= Dc_Attr
->ptlBrushOrigin
.x
;
404 lppt
->y
= Dc_Attr
->ptlBrushOrigin
.y
;
407 /* Check if we have nothing to do */
408 if ((nXOrg
== Dc_Attr
->ptlBrushOrigin
.x
) &&
409 (nYOrg
== Dc_Attr
->ptlBrushOrigin
.y
))
412 /* Allocate a batch command buffer */
413 pgSBO
= GdiAllocBatchCommand(hdc
, GdiBCSetBrushOrg
);
416 /* Set current brush origin in the DC attribute */
417 Dc_Attr
->ptlBrushOrigin
.x
= nXOrg
;
418 Dc_Attr
->ptlBrushOrigin
.y
= nYOrg
;
420 /* Setup the GDI batch command */
421 pgSBO
->ptlBrushOrigin
= Dc_Attr
->ptlBrushOrigin
;
427 /* Fall back to the slower kernel path */
428 return NtGdiSetBrushOrg(hdc
, nXOrg
, nYOrg
, lppt
);