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)
64 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
65 BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
68 ERR("Can't get BRUSHOBJ\n");
72 switch (brush->logbrush.lbStyle) {
75 PSDRV_WriteSetColor(dc, &physDev->brush.color);
86 physDev->brush.set = TRUE;
87 GDI_ReleaseObj( dc->w.hBrush );
92 /**********************************************************************
97 static BOOL PSDRV_Fill(DC *dc, BOOL EO)
100 return PSDRV_WriteFill(dc);
102 return PSDRV_WriteEOFill(dc);
106 /**********************************************************************
111 static BOOL PSDRV_Clip(DC *dc, BOOL EO)
114 return PSDRV_WriteClip(dc);
116 return PSDRV_WriteEOClip(dc);
119 /**********************************************************************
124 BOOL PSDRV_Brush(DC *dc, BOOL EO)
127 BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
128 PSDRV_PDEVICE *physDev = dc->physDev;
131 ERR("Can't get BRUSHOBJ\n");
135 switch (brush->logbrush.lbStyle) {
138 PSDRV_WriteGSave(dc);
140 PSDRV_WriteGRestore(dc);
146 switch(brush->logbrush.lbHatch) {
149 PSDRV_WriteGSave(dc);
151 PSDRV_WriteHatch(dc);
152 PSDRV_WriteStroke(dc);
153 PSDRV_WriteGRestore(dc);
154 if(brush->logbrush.lbHatch == HS_VERTICAL)
156 /* else fallthrough for HS_CROSS */
159 PSDRV_WriteGSave(dc);
161 PSDRV_WriteRotate(dc, 90.0);
162 PSDRV_WriteHatch(dc);
163 PSDRV_WriteStroke(dc);
164 PSDRV_WriteGRestore(dc);
169 PSDRV_WriteGSave(dc);
171 PSDRV_WriteRotate(dc, -45.0);
172 PSDRV_WriteHatch(dc);
173 PSDRV_WriteStroke(dc);
174 PSDRV_WriteGRestore(dc);
175 if(brush->logbrush.lbHatch == HS_FDIAGONAL)
177 /* else fallthrough for HS_DIAGCROSS */
180 PSDRV_WriteGSave(dc);
182 PSDRV_WriteRotate(dc, 45.0);
183 PSDRV_WriteHatch(dc);
184 PSDRV_WriteStroke(dc);
185 PSDRV_WriteGRestore(dc);
189 ERR("Unknown hatch style\n");
202 GetObjectA(brush->logbrush.lbHatch, sizeof(BITMAP), &bm);
203 TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
205 bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
206 GetBitmapBits(brush->logbrush.lbHatch,
207 bm.bmWidthBytes * bm.bmHeight, bits);
209 if(physDev->pi->ppd->LanguageLevel > 1) {
210 PSDRV_WriteGSave(dc);
211 PSDRV_WritePatternDict(dc, &bm, bits);
213 PSDRV_WriteGRestore(dc);
215 FIXME("Trying to set a pattern brush on a level 1 printer\n");
218 HeapFree(PSDRV_Heap, 0, bits);
227 GDI_ReleaseObj( dc->w.hBrush );