Some broken games do not put the TEXTURE flags in the surface caps.
[wine/multimedia.git] / objects / dcvalues.c
blob6cad06e50189e29d5720223ee186554bef6715ab
1 /*
2 * DC device-independent Get/SetXXX functions
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include "winbase.h"
24 #include "winerror.h"
25 #include "wownt32.h"
27 #include "gdi.h"
30 /***********************************************************************
31 * SetBkMode (GDI32.@)
33 INT WINAPI SetBkMode( HDC hdc, INT mode )
35 INT ret;
36 DC *dc;
37 if ((mode <= 0) || (mode > BKMODE_LAST))
39 SetLastError(ERROR_INVALID_PARAMETER);
40 return 0;
42 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
43 if (dc->funcs->pSetBkMode)
44 ret = dc->funcs->pSetBkMode( dc->physDev, mode );
45 else
47 ret = dc->backgroundMode;
48 dc->backgroundMode = mode;
50 GDI_ReleaseObj( hdc );
51 return ret;
55 /***********************************************************************
56 * SetROP2 (GDI32.@)
58 INT WINAPI SetROP2( HDC hdc, INT mode )
60 INT ret;
61 DC *dc;
62 if ((mode < R2_BLACK) || (mode > R2_WHITE))
64 SetLastError(ERROR_INVALID_PARAMETER);
65 return 0;
67 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
68 if (dc->funcs->pSetROP2)
69 ret = dc->funcs->pSetROP2( dc->physDev, mode );
70 else
72 ret = dc->ROPmode;
73 dc->ROPmode = mode;
75 GDI_ReleaseObj( hdc );
76 return ret;
80 /***********************************************************************
81 * SetRelAbs (GDI32.@)
83 INT WINAPI SetRelAbs( HDC hdc, INT mode )
85 INT ret;
86 DC *dc;
87 if ((mode != ABSOLUTE) && (mode != RELATIVE))
89 SetLastError(ERROR_INVALID_PARAMETER);
90 return 0;
92 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
93 if (dc->funcs->pSetRelAbs)
94 ret = dc->funcs->pSetRelAbs( dc->physDev, mode );
95 else
97 ret = dc->relAbsMode;
98 dc->relAbsMode = mode;
100 GDI_ReleaseObj( hdc );
101 return ret;
105 /***********************************************************************
106 * SetPolyFillMode (GDI32.@)
108 INT WINAPI SetPolyFillMode( HDC hdc, INT mode )
110 INT ret;
111 DC *dc;
112 if ((mode <= 0) || (mode > POLYFILL_LAST))
114 SetLastError(ERROR_INVALID_PARAMETER);
115 return 0;
117 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
118 if (dc->funcs->pSetPolyFillMode)
119 ret = dc->funcs->pSetPolyFillMode( dc->physDev, mode );
120 else
122 ret = dc->polyFillMode;
123 dc->polyFillMode = mode;
125 GDI_ReleaseObj( hdc );
126 return ret;
130 /***********************************************************************
131 * SetStretchBltMode (GDI32.@)
133 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
135 INT ret;
136 DC *dc;
137 if ((mode <= 0) || (mode > MAXSTRETCHBLTMODE))
139 SetLastError(ERROR_INVALID_PARAMETER);
140 return 0;
142 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
143 if (dc->funcs->pSetStretchBltMode)
144 ret = dc->funcs->pSetStretchBltMode( dc->physDev, mode );
145 else
147 ret = dc->stretchBltMode;
148 dc->stretchBltMode = mode;
150 GDI_ReleaseObj( hdc );
151 return ret;
155 /***********************************************************************
156 * GetBkColor (GDI32.@)
158 COLORREF WINAPI GetBkColor( HDC hdc )
160 COLORREF ret = 0;
161 DC * dc = DC_GetDCPtr( hdc );
162 if (dc)
164 ret = dc->backgroundColor;
165 GDI_ReleaseObj( hdc );
167 return ret;
171 /***********************************************************************
172 * GetBkMode (GDI32.@)
174 INT WINAPI GetBkMode( HDC hdc )
176 INT ret = 0;
177 DC * dc = DC_GetDCPtr( hdc );
178 if (dc)
180 ret = dc->backgroundMode;
181 GDI_ReleaseObj( hdc );
183 return ret;
187 /***********************************************************************
188 * GetMapMode (GDI32.@)
190 INT WINAPI GetMapMode( HDC hdc )
192 INT ret = 0;
193 DC * dc = DC_GetDCPtr( hdc );
194 if (dc)
196 ret = dc->MapMode;
197 GDI_ReleaseObj( hdc );
199 return ret;
203 /***********************************************************************
204 * GetPolyFillMode (GDI32.@)
206 INT WINAPI GetPolyFillMode( HDC hdc )
208 INT ret = 0;
209 DC * dc = DC_GetDCPtr( hdc );
210 if (dc)
212 ret = dc->polyFillMode;
213 GDI_ReleaseObj( hdc );
215 return ret;
219 /***********************************************************************
220 * GetROP2 (GDI32.@)
222 INT WINAPI GetROP2( HDC hdc )
224 INT ret = 0;
225 DC * dc = DC_GetDCPtr( hdc );
226 if (dc)
228 ret = dc->ROPmode;
229 GDI_ReleaseObj( hdc );
231 return ret;
235 /***********************************************************************
236 * GetStretchBltMode (GDI32.@)
238 INT WINAPI GetStretchBltMode( HDC hdc )
240 INT ret = 0;
241 DC * dc = DC_GetDCPtr( hdc );
242 if (dc)
244 ret = dc->stretchBltMode;
245 GDI_ReleaseObj( hdc );
247 return ret;
251 /***********************************************************************
252 * GetTextColor (GDI32.@)
254 COLORREF WINAPI GetTextColor( HDC hdc )
256 COLORREF ret = 0;
257 DC * dc = DC_GetDCPtr( hdc );
258 if (dc)
260 ret = dc->textColor;
261 GDI_ReleaseObj( hdc );
263 return ret;
267 /***********************************************************************
268 * GetTextAlign (GDI32.@)
270 UINT WINAPI GetTextAlign( HDC hdc )
272 UINT ret = 0;
273 DC * dc = DC_GetDCPtr( hdc );
274 if (dc)
276 ret = dc->textAlign;
277 GDI_ReleaseObj( hdc );
279 return ret;
283 /***********************************************************************
284 * GetArcDirection (GDI32.@)
286 INT WINAPI GetArcDirection( HDC hdc )
288 INT ret = 0;
289 DC * dc = DC_GetDCPtr( hdc );
290 if (dc)
292 ret = dc->ArcDirection;
293 GDI_ReleaseObj( hdc );
295 return ret;
299 /***********************************************************************
300 * GetGraphicsMode (GDI32.@)
302 INT WINAPI GetGraphicsMode( HDC hdc )
304 INT ret = 0;
305 DC * dc = DC_GetDCPtr( hdc );
306 if (dc)
308 ret = dc->GraphicsMode;
309 GDI_ReleaseObj( hdc );
311 return ret;
315 /***********************************************************************
316 * GetBrushOrgEx (GDI32.@)
318 BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
320 DC * dc = DC_GetDCPtr( hdc );
321 if (!dc) return FALSE;
322 pt->x = dc->brushOrgX;
323 pt->y = dc->brushOrgY;
324 GDI_ReleaseObj( hdc );
325 return TRUE;
329 /***********************************************************************
330 * GetCurrentPositionEx (GDI32.@)
332 BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
334 DC * dc = DC_GetDCPtr( hdc );
335 if (!dc) return FALSE;
336 pt->x = dc->CursPosX;
337 pt->y = dc->CursPosY;
338 GDI_ReleaseObj( hdc );
339 return TRUE;
343 /***********************************************************************
344 * GetViewportExtEx (GDI32.@)
346 BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
348 DC * dc = DC_GetDCPtr( hdc );
349 if (!dc) return FALSE;
350 size->cx = dc->vportExtX;
351 size->cy = dc->vportExtY;
352 GDI_ReleaseObj( hdc );
353 return TRUE;
357 /***********************************************************************
358 * GetViewportOrgEx (GDI32.@)
360 BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
362 DC * dc = DC_GetDCPtr( hdc );
363 if (!dc) return FALSE;
364 pt->x = dc->vportOrgX;
365 pt->y = dc->vportOrgY;
366 GDI_ReleaseObj( hdc );
367 return TRUE;
371 /***********************************************************************
372 * GetWindowExtEx (GDI32.@)
374 BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
376 DC * dc = DC_GetDCPtr( hdc );
377 if (!dc) return FALSE;
378 size->cx = dc->wndExtX;
379 size->cy = dc->wndExtY;
380 GDI_ReleaseObj( hdc );
381 return TRUE;
385 /***********************************************************************
386 * GetWindowOrgEx (GDI32.@)
388 BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
390 DC * dc = DC_GetDCPtr( hdc );
391 if (!dc) return FALSE;
392 pt->x = dc->wndOrgX;
393 pt->y = dc->wndOrgY;
394 GDI_ReleaseObj( hdc );
395 return TRUE;
399 /**** 16-bit functions ***/
401 /***********************************************************************
402 * InquireVisRgn (GDI.131)
404 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
406 HRGN16 ret = 0;
407 DC * dc = DC_GetDCPtr( HDC_32(hdc) );
408 if (dc)
410 ret = HRGN_16(dc->hVisRgn);
411 GDI_ReleaseObj( HDC_32(hdc) );
413 return ret;
417 /***********************************************************************
418 * GetClipRgn (GDI.173)
420 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
422 HRGN16 ret = 0;
423 DC * dc = DC_GetDCPtr( HDC_32(hdc) );
424 if (dc)
426 ret = HRGN_16(dc->hClipRgn);
427 GDI_ReleaseObj( HDC_32(hdc) );
429 return ret;