Clear invalid selectors also in CallTo16 relay code.
[wine/wine-kai.git] / graphics / psdrv / brush.c
blob58c1647bfe9cc6b8fb4b331febe747aca9d11b22
1 /*
2 * PostScript brush handling
4 * Copyright 1998 Huw D M Davies
6 */
8 #include "psdrv.h"
9 #include "brush.h"
10 #include "debug.h"
11 #include "gdi.h"
13 /***********************************************************************
14 * PSDRV_BRUSH_SelectObject
16 HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
18 HBRUSH prevbrush = dc->w.hBrush;
19 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
21 TRACE(psdrv, "hbrush = %08x\n", hbrush);
22 dc->w.hBrush = hbrush;
24 switch(brush->logbrush.lbStyle) {
26 case BS_SOLID:
27 PSDRV_CreateColor(physDev, &physDev->brush.color,
28 brush->logbrush.lbColor);
29 break;
31 case BS_NULL:
32 break;
34 case BS_HATCHED:
35 PSDRV_CreateColor(physDev, &physDev->brush.color,
36 brush->logbrush.lbColor);
37 break;
39 case BS_PATTERN:
40 FIXME(psdrv, "Unsupported brush style %d\n", brush->logbrush.lbStyle);
41 break;
43 default:
44 FIXME(psdrv, "Unrecognized brush style %d\n", brush->logbrush.lbStyle);
45 break;
48 physDev->brush.set = FALSE;
49 return prevbrush;
53 /**********************************************************************
55 * PSDRV_SetBrush
58 static BOOL PSDRV_SetBrush(DC *dc)
60 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
61 BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
63 if(!brush) {
64 ERR(psdrv, "Can't get BRUSHOBJ\n");
65 return FALSE;
68 switch (brush->logbrush.lbStyle) {
69 case BS_SOLID:
70 case BS_HATCHED:
71 PSDRV_WriteSetColor(dc, &physDev->brush.color);
72 break;
74 case BS_NULL:
75 break;
77 default:
78 return FALSE;
79 break;
82 physDev->brush.set = TRUE;
83 return TRUE;
87 /**********************************************************************
89 * PSDRV_Fill
92 static BOOL PSDRV_Fill(DC *dc, BOOL EO)
94 if(!EO)
95 return PSDRV_WriteFill(dc);
96 else
97 return PSDRV_WriteEOFill(dc);
101 /**********************************************************************
103 * PSDRV_Clip
106 static BOOL PSDRV_Clip(DC *dc, BOOL EO)
108 if(!EO)
109 return PSDRV_WriteClip(dc);
110 else
111 return PSDRV_WriteEOClip(dc);
114 /**********************************************************************
116 * PSDRV_Brush
119 BOOL PSDRV_Brush(DC *dc, BOOL EO)
121 BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
123 if(!brush) {
124 ERR(psdrv, "Can't get BRUSHOBJ\n");
125 return FALSE;
128 switch (brush->logbrush.lbStyle) {
129 case BS_SOLID:
130 PSDRV_SetBrush(dc);
131 PSDRV_WriteGSave(dc);
132 PSDRV_Fill(dc, EO);
133 PSDRV_WriteGRestore(dc);
134 return TRUE;
135 break;
137 case BS_HATCHED:
138 PSDRV_SetBrush(dc);
140 switch(brush->logbrush.lbHatch) {
141 case HS_VERTICAL:
142 case HS_CROSS:
143 PSDRV_WriteGSave(dc);
144 PSDRV_Clip(dc, EO);
145 PSDRV_WriteHatch(dc);
146 PSDRV_WriteStroke(dc);
147 PSDRV_WriteGRestore(dc);
148 if(brush->logbrush.lbHatch == HS_VERTICAL)
149 break;
150 /* else fallthrough for HS_CROSS */
152 case HS_HORIZONTAL:
153 PSDRV_WriteGSave(dc);
154 PSDRV_Clip(dc, EO);
155 PSDRV_WriteRotate(dc, 90.0);
156 PSDRV_WriteHatch(dc);
157 PSDRV_WriteStroke(dc);
158 PSDRV_WriteGRestore(dc);
159 break;
161 case HS_FDIAGONAL:
162 case HS_DIAGCROSS:
163 PSDRV_WriteGSave(dc);
164 PSDRV_Clip(dc, EO);
165 PSDRV_WriteRotate(dc, -45.0);
166 PSDRV_WriteHatch(dc);
167 PSDRV_WriteStroke(dc);
168 PSDRV_WriteGRestore(dc);
169 if(brush->logbrush.lbHatch == HS_FDIAGONAL)
170 break;
171 /* else fallthrough for HS_DIAGCROSS */
173 case HS_BDIAGONAL:
174 PSDRV_WriteGSave(dc);
175 PSDRV_Clip(dc, EO);
176 PSDRV_WriteRotate(dc, 45.0);
177 PSDRV_WriteHatch(dc);
178 PSDRV_WriteStroke(dc);
179 PSDRV_WriteGRestore(dc);
180 break;
182 default:
183 ERR(psdrv, "Unknown hatch style\n");
184 return FALSE;
186 return TRUE;
187 break;
189 case BS_NULL:
190 return TRUE;
191 break;
193 default:
194 return FALSE;
195 break;