2 * PostScript brush handling
4 * Copyright 1998 Huw D M Davies
10 #include "debugtools.h"
14 DEFAULT_DEBUG_CHANNEL(psdrv
)
16 /***********************************************************************
17 * PSDRV_BRUSH_SelectObject
19 HBRUSH
PSDRV_BRUSH_SelectObject( DC
* dc
, HBRUSH hbrush
, BRUSHOBJ
* brush
)
21 HBRUSH prevbrush
= dc
->w
.hBrush
;
22 PSDRV_PDEVICE
*physDev
= (PSDRV_PDEVICE
*)dc
->physDev
;
24 TRACE("hbrush = %08x\n", hbrush
);
25 dc
->w
.hBrush
= hbrush
;
27 switch(brush
->logbrush
.lbStyle
) {
30 PSDRV_CreateColor(physDev
, &physDev
->brush
.color
,
31 brush
->logbrush
.lbColor
);
38 PSDRV_CreateColor(physDev
, &physDev
->brush
.color
,
39 brush
->logbrush
.lbColor
);
43 FIXME("Unsupported brush style %d\n", brush
->logbrush
.lbStyle
);
47 FIXME("Unrecognized brush style %d\n", brush
->logbrush
.lbStyle
);
51 physDev
->brush
.set
= FALSE
;
56 /**********************************************************************
61 static BOOL
PSDRV_SetBrush(DC
*dc
)
63 PSDRV_PDEVICE
*physDev
= (PSDRV_PDEVICE
*)dc
->physDev
;
64 BRUSHOBJ
*brush
= (BRUSHOBJ
*)GDI_GetObjPtr( dc
->w
.hBrush
, BRUSH_MAGIC
);
67 ERR("Can't get BRUSHOBJ\n");
71 switch (brush
->logbrush
.lbStyle
) {
74 PSDRV_WriteSetColor(dc
, &physDev
->brush
.color
);
85 physDev
->brush
.set
= TRUE
;
90 /**********************************************************************
95 static BOOL
PSDRV_Fill(DC
*dc
, BOOL EO
)
98 return PSDRV_WriteFill(dc
);
100 return PSDRV_WriteEOFill(dc
);
104 /**********************************************************************
109 static BOOL
PSDRV_Clip(DC
*dc
, BOOL EO
)
112 return PSDRV_WriteClip(dc
);
114 return PSDRV_WriteEOClip(dc
);
117 /**********************************************************************
122 BOOL
PSDRV_Brush(DC
*dc
, BOOL EO
)
124 BRUSHOBJ
*brush
= (BRUSHOBJ
*)GDI_GetObjPtr( dc
->w
.hBrush
, BRUSH_MAGIC
);
125 PSDRV_PDEVICE
*physDev
= dc
->physDev
;
128 ERR("Can't get BRUSHOBJ\n");
132 switch (brush
->logbrush
.lbStyle
) {
135 PSDRV_WriteGSave(dc
);
137 PSDRV_WriteGRestore(dc
);
144 switch(brush
->logbrush
.lbHatch
) {
147 PSDRV_WriteGSave(dc
);
149 PSDRV_WriteHatch(dc
);
150 PSDRV_WriteStroke(dc
);
151 PSDRV_WriteGRestore(dc
);
152 if(brush
->logbrush
.lbHatch
== HS_VERTICAL
)
154 /* else fallthrough for HS_CROSS */
157 PSDRV_WriteGSave(dc
);
159 PSDRV_WriteRotate(dc
, 90.0);
160 PSDRV_WriteHatch(dc
);
161 PSDRV_WriteStroke(dc
);
162 PSDRV_WriteGRestore(dc
);
167 PSDRV_WriteGSave(dc
);
169 PSDRV_WriteRotate(dc
, -45.0);
170 PSDRV_WriteHatch(dc
);
171 PSDRV_WriteStroke(dc
);
172 PSDRV_WriteGRestore(dc
);
173 if(brush
->logbrush
.lbHatch
== HS_FDIAGONAL
)
175 /* else fallthrough for HS_DIAGCROSS */
178 PSDRV_WriteGSave(dc
);
180 PSDRV_WriteRotate(dc
, 45.0);
181 PSDRV_WriteHatch(dc
);
182 PSDRV_WriteStroke(dc
);
183 PSDRV_WriteGRestore(dc
);
187 ERR("Unknown hatch style\n");
201 GetObjectA(brush
->logbrush
.lbHatch
, sizeof(BITMAP
), &bm
);
202 TRACE("BS_PATTERN %dx%d %d bpp\n", bm
.bmWidth
, bm
.bmHeight
,
204 bits
= HeapAlloc(PSDRV_Heap
, 0, bm
.bmWidthBytes
* bm
.bmHeight
);
205 GetBitmapBits(brush
->logbrush
.lbHatch
,
206 bm
.bmWidthBytes
* bm
.bmHeight
, bits
);
208 if(physDev
->pi
->ppd
->LanguageLevel
> 1) {
209 PSDRV_WriteGSave(dc
);
210 PSDRV_WritePatternDict(dc
, &bm
, bits
);
212 PSDRV_WriteGRestore(dc
);
214 FIXME("Trying to set a pattern brush on a level 1 printer\n");
216 HeapFree(PSDRV_Heap
, 0, bits
);