mf/session: Implement support for sinks that provide sample allocators.
[wine.git] / dlls / gdi32 / gdiobj.c
blob2309fdac582422c7bed5d005b24893d42c977792
1 /*
2 * GDI 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
22 #include <stdlib.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winreg.h"
30 #include "winnls.h"
31 #include "winerror.h"
32 #include "winternl.h"
34 #include "gdi_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
39 #define FIRST_GDI_HANDLE 32
40 #define MAX_GDI_HANDLES 16384
42 struct hdc_list
44 HDC hdc;
45 struct hdc_list *next;
48 struct gdi_handle_entry
50 void *obj; /* pointer to the object-specific data */
51 const struct gdi_obj_funcs *funcs; /* type-specific functions */
52 struct hdc_list *hdcs; /* list of HDCs interested in this object */
53 WORD generation; /* generation count for reusing handle values */
54 WORD type; /* object type (one of the OBJ_* constants) */
55 WORD selcount; /* number of times the object is selected in a DC */
56 WORD system : 1; /* system object flag */
57 WORD deleted : 1; /* whether DeleteObject has been called on this object */
60 static struct gdi_handle_entry gdi_handles[MAX_GDI_HANDLES];
61 static struct gdi_handle_entry *next_free;
62 static struct gdi_handle_entry *next_unused = gdi_handles;
63 static LONG debug_count;
64 HMODULE gdi32_module = 0;
66 static inline HGDIOBJ entry_to_handle( struct gdi_handle_entry *entry )
68 unsigned int idx = entry - gdi_handles + FIRST_GDI_HANDLE;
69 return LongToHandle( idx | (entry->generation << 16) );
72 static inline struct gdi_handle_entry *handle_entry( HGDIOBJ handle )
74 unsigned int idx = LOWORD(handle) - FIRST_GDI_HANDLE;
76 if (idx < MAX_GDI_HANDLES && gdi_handles[idx].type)
78 if (!HIWORD( handle ) || HIWORD( handle ) == gdi_handles[idx].generation)
79 return &gdi_handles[idx];
81 if (handle) WARN( "invalid handle %p\n", handle );
82 return NULL;
85 /***********************************************************************
86 * GDI stock objects
89 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
90 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
91 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
93 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
94 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
95 static const LOGBRUSH DkGrayBrush = { BS_SOLID, RGB(64,64,64), 0 };
97 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
98 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
99 static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
101 static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 };
102 static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
104 /* reserve one extra entry for the stock default bitmap */
105 /* this is what Windows does too */
106 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
108 static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
109 static HGDIOBJ scaled_stock_objects[NB_STOCK_OBJECTS];
111 static CRITICAL_SECTION gdi_section;
112 static CRITICAL_SECTION_DEBUG critsect_debug =
114 0, 0, &gdi_section,
115 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
116 0, 0, { (DWORD_PTR)(__FILE__ ": gdi_section") }
118 static CRITICAL_SECTION gdi_section = { &critsect_debug, -1, 0, 0, 0, 0 };
121 /****************************************************************************
123 * language-independent stock fonts
127 static const LOGFONTW OEMFixedFont =
128 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
129 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" };
131 static const LOGFONTW AnsiFixedFont =
132 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
133 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier" };
135 static const LOGFONTW AnsiVarFont =
136 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
137 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" };
139 /******************************************************************************
141 * language-dependent stock fonts
143 * 'ANSI' charset and 'DEFAULT' charset is not same.
144 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
145 * 'ANSI' charset seems to be identical with ISO-8859-1.
146 * 'DEFAULT' charset is a language-dependent charset.
148 * 'System' font seems to be an alias for language-dependent font.
152 * language-dependent stock fonts for all known charsets
153 * please see TranslateCharsetInfo (dlls/gdi/font.c) and
154 * CharsetBindingInfo (dlls/x11drv/xfont.c),
155 * and modify entries for your language if needed.
157 struct DefaultFontInfo
159 UINT charset;
160 LOGFONTW SystemFont;
161 LOGFONTW DeviceDefaultFont;
162 LOGFONTW SystemFixedFont;
163 LOGFONTW DefaultGuiFont;
166 static const struct DefaultFontInfo default_fonts[] =
168 { ANSI_CHARSET,
169 { /* System */
170 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
171 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
173 { /* Device Default */
174 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
175 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
177 { /* System Fixed */
178 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
179 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
181 { /* DefaultGuiFont */
182 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
183 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
186 { EASTEUROPE_CHARSET,
187 { /* System */
188 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
189 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
191 { /* Device Default */
192 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
193 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
195 { /* System Fixed */
196 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
197 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
199 { /* DefaultGuiFont */
200 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
201 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
204 { RUSSIAN_CHARSET,
205 { /* System */
206 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
207 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
209 { /* Device Default */
210 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
211 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
213 { /* System Fixed */
214 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
215 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
217 { /* DefaultGuiFont */
218 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
219 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
222 { GREEK_CHARSET,
223 { /* System */
224 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
225 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
227 { /* Device Default */
228 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
229 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
231 { /* System Fixed */
232 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
233 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
235 { /* DefaultGuiFont */
236 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
237 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
240 { TURKISH_CHARSET,
241 { /* System */
242 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, TURKISH_CHARSET,
243 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
245 { /* Device Default */
246 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, TURKISH_CHARSET,
247 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
249 { /* System Fixed */
250 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
251 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
253 { /* DefaultGuiFont */
254 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
255 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
258 { HEBREW_CHARSET,
259 { /* System */
260 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, HEBREW_CHARSET,
261 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
263 { /* Device Default */
264 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, HEBREW_CHARSET,
265 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
267 { /* System Fixed */
268 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
269 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
271 { /* DefaultGuiFont */
272 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
273 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
276 { ARABIC_CHARSET,
277 { /* System */
278 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ARABIC_CHARSET,
279 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
281 { /* Device Default */
282 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ARABIC_CHARSET,
283 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
285 { /* System Fixed */
286 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
287 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
289 { /* DefaultGuiFont */
290 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
291 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
294 { BALTIC_CHARSET,
295 { /* System */
296 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, BALTIC_CHARSET,
297 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
299 { /* Device Default */
300 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, BALTIC_CHARSET,
301 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
303 { /* System Fixed */
304 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
305 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
307 { /* DefaultGuiFont */
308 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
309 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
312 { THAI_CHARSET,
313 { /* System */
314 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, THAI_CHARSET,
315 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
317 { /* Device Default */
318 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, THAI_CHARSET,
319 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
321 { /* System Fixed */
322 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
323 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
325 { /* DefaultGuiFont */
326 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
327 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
330 { SHIFTJIS_CHARSET,
331 { /* System */
332 18, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
333 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
335 { /* Device Default */
336 18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
337 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
339 { /* System Fixed */
340 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
341 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
343 { /* DefaultGuiFont */
344 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
345 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
348 { GB2312_CHARSET,
349 { /* System */
350 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GB2312_CHARSET,
351 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
353 { /* Device Default */
354 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GB2312_CHARSET,
355 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
357 { /* System Fixed */
358 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
359 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
361 { /* DefaultGuiFont */
362 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
363 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
366 { HANGEUL_CHARSET,
367 { /* System */
368 16, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
369 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
371 { /* Device Default */
372 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
373 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
375 { /* System Fixed */
376 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
377 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
379 { /* DefaultGuiFont */
380 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
381 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
384 { CHINESEBIG5_CHARSET,
385 { /* System */
386 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
387 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
389 { /* Device Default */
390 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
391 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
393 { /* System Fixed */
394 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
395 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
397 { /* DefaultGuiFont */
398 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
399 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
402 { JOHAB_CHARSET,
403 { /* System */
404 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, JOHAB_CHARSET,
405 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
407 { /* Device Default */
408 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, JOHAB_CHARSET,
409 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
411 { /* System Fixed */
412 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
413 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
415 { /* DefaultGuiFont */
416 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
417 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
423 /*************************************************************************
424 * __wine_make_gdi_object_system (GDI32.@)
426 * USER has to tell GDI that its system brushes and pens are non-deletable.
427 * For a description of the GDI object magics and their flags,
428 * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though).
430 void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set)
432 struct gdi_handle_entry *entry;
434 EnterCriticalSection( &gdi_section );
435 if ((entry = handle_entry( handle ))) entry->system = !!set;
436 LeaveCriticalSection( &gdi_section );
439 /******************************************************************************
440 * get_default_fonts
442 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
444 unsigned int n;
446 for(n = 0; n < ARRAY_SIZE( default_fonts ); n++)
448 if ( default_fonts[n].charset == charset )
449 return &default_fonts[n];
452 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
453 return &default_fonts[0];
457 /******************************************************************************
458 * get_default_charset (internal)
460 * get the language-dependent charset that can handle CP_ACP correctly.
462 static UINT get_default_charset( void )
464 CHARSETINFO csi;
465 UINT uACP;
467 uACP = GetACP();
468 csi.ciCharset = ANSI_CHARSET;
469 if ( !TranslateCharsetInfo( ULongToPtr(uACP), &csi, TCI_SRCCODEPAGE ) )
471 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
472 return ANSI_CHARSET;
475 return csi.ciCharset;
479 /***********************************************************************
480 * GDI_get_ref_count
482 * Retrieve the reference count of a GDI object.
483 * Note: the object must be locked otherwise the count is meaningless.
485 UINT GDI_get_ref_count( HGDIOBJ handle )
487 struct gdi_handle_entry *entry;
488 UINT ret = 0;
490 EnterCriticalSection( &gdi_section );
491 if ((entry = handle_entry( handle ))) ret = entry->selcount;
492 LeaveCriticalSection( &gdi_section );
493 return ret;
497 /***********************************************************************
498 * GDI_inc_ref_count
500 * Increment the reference count of a GDI object.
502 HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle )
504 struct gdi_handle_entry *entry;
506 EnterCriticalSection( &gdi_section );
507 if ((entry = handle_entry( handle ))) entry->selcount++;
508 else handle = 0;
509 LeaveCriticalSection( &gdi_section );
510 return handle;
514 /***********************************************************************
515 * GDI_dec_ref_count
517 * Decrement the reference count of a GDI object.
519 BOOL GDI_dec_ref_count( HGDIOBJ handle )
521 struct gdi_handle_entry *entry;
523 EnterCriticalSection( &gdi_section );
524 if ((entry = handle_entry( handle )))
526 assert( entry->selcount );
527 if (!--entry->selcount && entry->deleted)
529 /* handle delayed DeleteObject*/
530 entry->deleted = 0;
531 LeaveCriticalSection( &gdi_section );
532 TRACE( "executing delayed DeleteObject for %p\n", handle );
533 DeleteObject( handle );
534 return TRUE;
537 LeaveCriticalSection( &gdi_section );
538 return entry != NULL;
542 /******************************************************************************
543 * get_reg_dword
545 * Read a DWORD value from the registry
547 static BOOL get_reg_dword(HKEY base, const WCHAR *key_name, const WCHAR *value_name, DWORD *value)
549 HKEY key;
550 DWORD type, data, size = sizeof(data);
551 BOOL ret = FALSE;
553 if (RegOpenKeyW(base, key_name, &key) == ERROR_SUCCESS)
555 if (RegQueryValueExW(key, value_name, NULL, &type, (void *)&data, &size) == ERROR_SUCCESS &&
556 type == REG_DWORD)
558 *value = data;
559 ret = TRUE;
561 RegCloseKey(key);
563 return ret;
566 /******************************************************************************
567 * get_dpi
569 * get the dpi from the registry
571 DWORD get_dpi(void)
573 DWORD dpi;
575 if (get_reg_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", &dpi))
576 return dpi;
577 if (get_reg_dword(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", &dpi))
578 return dpi;
579 return 0;
582 /******************************************************************************
583 * get_system_dpi
585 * Get the system DPI, based on the DPI awareness mode.
587 DWORD get_system_dpi(void)
589 static UINT (WINAPI *pGetDpiForSystem)(void);
591 if (!pGetDpiForSystem)
593 HMODULE user = GetModuleHandleW( L"user32.dll" );
594 if (user) pGetDpiForSystem = (void *)GetProcAddress( user, "GetDpiForSystem" );
596 return pGetDpiForSystem ? pGetDpiForSystem() : 96;
599 static HFONT create_scaled_font( const LOGFONTW *deffont )
601 LOGFONTW lf;
602 static DWORD dpi;
604 if (!dpi)
606 dpi = get_dpi();
607 if (!dpi) dpi = 96;
610 lf = *deffont;
611 lf.lfHeight = MulDiv( lf.lfHeight, dpi, 96 );
612 return CreateFontIndirectW( &lf );
615 /***********************************************************************
616 * DllMain
618 * GDI initialization.
620 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
622 const struct DefaultFontInfo* deffonts;
623 int i;
625 if (reason != DLL_PROCESS_ATTACH) return TRUE;
627 gdi32_module = inst;
628 DisableThreadLibraryCalls( inst );
629 font_init();
631 /* create stock objects */
632 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
633 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
634 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
635 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
636 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
637 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
639 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
640 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
641 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
643 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
644 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
646 /* language-independent stock fonts */
647 stock_objects[OEM_FIXED_FONT] = CreateFontIndirectW( &OEMFixedFont );
648 stock_objects[ANSI_FIXED_FONT] = CreateFontIndirectW( &AnsiFixedFont );
649 stock_objects[ANSI_VAR_FONT] = CreateFontIndirectW( &AnsiVarFont );
651 /* language-dependent stock fonts */
652 deffonts = get_default_fonts(get_default_charset());
653 stock_objects[SYSTEM_FONT] = CreateFontIndirectW( &deffonts->SystemFont );
654 stock_objects[DEVICE_DEFAULT_FONT] = CreateFontIndirectW( &deffonts->DeviceDefaultFont );
655 stock_objects[SYSTEM_FIXED_FONT] = CreateFontIndirectW( &deffonts->SystemFixedFont );
656 stock_objects[DEFAULT_GUI_FONT] = CreateFontIndirectW( &deffonts->DefaultGuiFont );
658 scaled_stock_objects[OEM_FIXED_FONT] = create_scaled_font( &OEMFixedFont );
659 scaled_stock_objects[SYSTEM_FONT] = create_scaled_font( &deffonts->SystemFont );
660 scaled_stock_objects[SYSTEM_FIXED_FONT] = create_scaled_font( &deffonts->SystemFixedFont );
661 scaled_stock_objects[DEFAULT_GUI_FONT] = create_scaled_font( &deffonts->DefaultGuiFont );
663 stock_objects[DC_BRUSH] = CreateBrushIndirect( &DCBrush );
664 stock_objects[DC_PEN] = CreatePenIndirect( &DCPen );
666 /* clear the NOSYSTEM bit on all stock objects*/
667 for (i = 0; i < NB_STOCK_OBJECTS; i++)
669 if (stock_objects[i]) __wine_make_gdi_object_system( stock_objects[i], TRUE );
670 if (scaled_stock_objects[i]) __wine_make_gdi_object_system( scaled_stock_objects[i], TRUE );
672 return TRUE;
676 /***********************************************************************
677 * GdiDllInitialize
679 * Stub entry point, some games (CoD: Black Ops 3) call it directly.
681 BOOL WINAPI GdiDllInitialize( HINSTANCE inst, DWORD reason, LPVOID reserved )
683 FIXME("stub\n");
684 return TRUE;
688 static const char *gdi_obj_type( unsigned type )
690 switch ( type )
692 case OBJ_PEN: return "OBJ_PEN";
693 case OBJ_BRUSH: return "OBJ_BRUSH";
694 case OBJ_DC: return "OBJ_DC";
695 case OBJ_METADC: return "OBJ_METADC";
696 case OBJ_PAL: return "OBJ_PAL";
697 case OBJ_FONT: return "OBJ_FONT";
698 case OBJ_BITMAP: return "OBJ_BITMAP";
699 case OBJ_REGION: return "OBJ_REGION";
700 case OBJ_METAFILE: return "OBJ_METAFILE";
701 case OBJ_MEMDC: return "OBJ_MEMDC";
702 case OBJ_EXTPEN: return "OBJ_EXTPEN";
703 case OBJ_ENHMETADC: return "OBJ_ENHMETADC";
704 case OBJ_ENHMETAFILE: return "OBJ_ENHMETAFILE";
705 case OBJ_COLORSPACE: return "OBJ_COLORSPACE";
706 default: return "UNKNOWN";
710 static void dump_gdi_objects( void )
712 struct gdi_handle_entry *entry;
714 TRACE( "%u objects:\n", MAX_GDI_HANDLES );
716 EnterCriticalSection( &gdi_section );
717 for (entry = gdi_handles; entry < next_unused; entry++)
719 if (!entry->type)
720 TRACE( "handle %p FREE\n", entry_to_handle( entry ));
721 else
722 TRACE( "handle %p obj %p type %s selcount %u deleted %u\n",
723 entry_to_handle( entry ), entry->obj, gdi_obj_type( entry->type ),
724 entry->selcount, entry->deleted );
726 LeaveCriticalSection( &gdi_section );
729 /***********************************************************************
730 * alloc_gdi_handle
732 * Allocate a GDI handle for an object, which must have been allocated on the process heap.
734 HGDIOBJ alloc_gdi_handle( void *obj, WORD type, const struct gdi_obj_funcs *funcs )
736 struct gdi_handle_entry *entry;
737 HGDIOBJ ret;
739 assert( type ); /* type 0 is reserved to mark free entries */
741 EnterCriticalSection( &gdi_section );
743 entry = next_free;
744 if (entry)
745 next_free = entry->obj;
746 else if (next_unused < gdi_handles + MAX_GDI_HANDLES)
747 entry = next_unused++;
748 else
750 LeaveCriticalSection( &gdi_section );
751 ERR( "out of GDI object handles, expect a crash\n" );
752 if (TRACE_ON(gdi)) dump_gdi_objects();
753 return 0;
755 entry->obj = obj;
756 entry->funcs = funcs;
757 entry->hdcs = NULL;
758 entry->type = type;
759 entry->selcount = 0;
760 entry->system = 0;
761 entry->deleted = 0;
762 if (++entry->generation == 0xffff) entry->generation = 1;
763 ret = entry_to_handle( entry );
764 LeaveCriticalSection( &gdi_section );
765 TRACE( "allocated %s %p %u/%u\n", gdi_obj_type(type), ret,
766 InterlockedIncrement( &debug_count ), MAX_GDI_HANDLES );
767 return ret;
771 /***********************************************************************
772 * free_gdi_handle
774 * Free a GDI handle and return a pointer to the object.
776 void *free_gdi_handle( HGDIOBJ handle )
778 void *object = NULL;
779 struct gdi_handle_entry *entry;
781 EnterCriticalSection( &gdi_section );
782 if ((entry = handle_entry( handle )))
784 TRACE( "freed %s %p %u/%u\n", gdi_obj_type( entry->type ), handle,
785 InterlockedDecrement( &debug_count ) + 1, MAX_GDI_HANDLES );
786 object = entry->obj;
787 entry->type = 0;
788 entry->obj = next_free;
789 next_free = entry;
791 LeaveCriticalSection( &gdi_section );
792 return object;
796 /***********************************************************************
797 * get_full_gdi_handle
799 * Return the full GDI handle from a possibly truncated value.
801 HGDIOBJ get_full_gdi_handle( HGDIOBJ handle )
803 struct gdi_handle_entry *entry;
805 if (!HIWORD( handle ))
807 EnterCriticalSection( &gdi_section );
808 if ((entry = handle_entry( handle ))) handle = entry_to_handle( entry );
809 LeaveCriticalSection( &gdi_section );
811 return handle;
814 /***********************************************************************
815 * get_any_obj_ptr
817 * Return a pointer to, and the type of, the GDI object
818 * associated with the handle.
819 * The object must be released with GDI_ReleaseObj.
821 void *get_any_obj_ptr( HGDIOBJ handle, WORD *type )
823 void *ptr = NULL;
824 struct gdi_handle_entry *entry;
826 EnterCriticalSection( &gdi_section );
828 if ((entry = handle_entry( handle )))
830 ptr = entry->obj;
831 *type = entry->type;
834 if (!ptr) LeaveCriticalSection( &gdi_section );
835 return ptr;
838 /***********************************************************************
839 * GDI_GetObjPtr
841 * Return a pointer to the GDI object associated with the handle.
842 * Return NULL if the object has the wrong type.
843 * The object must be released with GDI_ReleaseObj.
845 void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
847 WORD ret_type;
848 void *ptr = get_any_obj_ptr( handle, &ret_type );
849 if (ptr && ret_type != type)
851 GDI_ReleaseObj( handle );
852 ptr = NULL;
854 return ptr;
857 /***********************************************************************
858 * GDI_ReleaseObj
861 void GDI_ReleaseObj( HGDIOBJ handle )
863 LeaveCriticalSection( &gdi_section );
867 /***********************************************************************
868 * GDI_CheckNotLock
870 void GDI_CheckNotLock(void)
872 if (RtlIsCriticalSectionLockedByThread(&gdi_section))
874 ERR( "BUG: holding GDI lock\n" );
875 DebugBreak();
880 /***********************************************************************
881 * DeleteObject (GDI32.@)
883 * Delete a Gdi object.
885 * PARAMS
886 * obj [I] Gdi object to delete
888 * RETURNS
889 * Success: TRUE. If obj was not returned from GetStockObject(), any resources
890 * it consumed are released.
891 * Failure: FALSE, if obj is not a valid Gdi object, or is currently selected
892 * into a DC.
894 BOOL WINAPI DeleteObject( HGDIOBJ obj )
896 struct gdi_handle_entry *entry;
897 struct hdc_list *hdcs_head;
898 const struct gdi_obj_funcs *funcs = NULL;
900 EnterCriticalSection( &gdi_section );
901 if (!(entry = handle_entry( obj )))
903 LeaveCriticalSection( &gdi_section );
904 return FALSE;
907 if (entry->system)
909 TRACE("Preserving system object %p\n", obj);
910 LeaveCriticalSection( &gdi_section );
911 return TRUE;
914 obj = entry_to_handle( entry ); /* make it a full handle */
916 hdcs_head = entry->hdcs;
917 entry->hdcs = NULL;
919 if (entry->selcount)
921 TRACE("delayed for %p because object in use, count %u\n", obj, entry->selcount );
922 entry->deleted = 1; /* mark for delete */
924 else funcs = entry->funcs;
926 LeaveCriticalSection( &gdi_section );
928 while (hdcs_head)
930 struct hdc_list *next = hdcs_head->next;
931 DC *dc = get_dc_ptr(hdcs_head->hdc);
933 TRACE("hdc %p has interest in %p\n", hdcs_head->hdc, obj);
934 if(dc)
936 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeleteObject );
937 physdev->funcs->pDeleteObject( physdev, obj );
938 release_dc_ptr( dc );
940 HeapFree(GetProcessHeap(), 0, hdcs_head);
941 hdcs_head = next;
944 TRACE("%p\n", obj );
946 if (funcs && funcs->pDeleteObject) return funcs->pDeleteObject( obj );
947 return TRUE;
950 /***********************************************************************
951 * GDI_hdc_using_object
953 * Call this if the dc requires DeleteObject notification
955 void GDI_hdc_using_object(HGDIOBJ obj, HDC hdc)
957 struct gdi_handle_entry *entry;
958 struct hdc_list *phdc;
960 TRACE("obj %p hdc %p\n", obj, hdc);
962 EnterCriticalSection( &gdi_section );
963 if ((entry = handle_entry( obj )) && !entry->system)
965 for (phdc = entry->hdcs; phdc; phdc = phdc->next)
966 if (phdc->hdc == hdc) break;
968 if (!phdc)
970 phdc = HeapAlloc(GetProcessHeap(), 0, sizeof(*phdc));
971 phdc->hdc = hdc;
972 phdc->next = entry->hdcs;
973 entry->hdcs = phdc;
976 LeaveCriticalSection( &gdi_section );
979 /***********************************************************************
980 * GDI_hdc_not_using_object
983 void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc)
985 struct gdi_handle_entry *entry;
986 struct hdc_list **pphdc;
988 TRACE("obj %p hdc %p\n", obj, hdc);
990 EnterCriticalSection( &gdi_section );
991 if ((entry = handle_entry( obj )) && !entry->system)
993 for (pphdc = &entry->hdcs; *pphdc; pphdc = &(*pphdc)->next)
994 if ((*pphdc)->hdc == hdc)
996 struct hdc_list *phdc = *pphdc;
997 *pphdc = phdc->next;
998 HeapFree(GetProcessHeap(), 0, phdc);
999 break;
1002 LeaveCriticalSection( &gdi_section );
1005 /***********************************************************************
1006 * GetStockObject (GDI32.@)
1008 HGDIOBJ WINAPI GetStockObject( INT obj )
1010 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
1011 switch (obj)
1013 case OEM_FIXED_FONT:
1014 case SYSTEM_FONT:
1015 case SYSTEM_FIXED_FONT:
1016 case DEFAULT_GUI_FONT:
1017 if (get_system_dpi() != 96) return scaled_stock_objects[obj];
1018 break;
1020 return stock_objects[obj];
1024 /***********************************************************************
1025 * GetObjectA (GDI32.@)
1027 INT WINAPI GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer )
1029 struct gdi_handle_entry *entry;
1030 const struct gdi_obj_funcs *funcs = NULL;
1031 INT result = 0;
1033 TRACE("%p %d %p\n", handle, count, buffer );
1035 EnterCriticalSection( &gdi_section );
1036 if ((entry = handle_entry( handle )))
1038 funcs = entry->funcs;
1039 handle = entry_to_handle( entry ); /* make it a full handle */
1041 LeaveCriticalSection( &gdi_section );
1043 if (funcs)
1045 if (!funcs->pGetObjectA)
1046 SetLastError( ERROR_INVALID_HANDLE );
1047 else if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
1048 SetLastError( ERROR_NOACCESS );
1049 else
1050 result = funcs->pGetObjectA( handle, count, buffer );
1052 return result;
1055 /***********************************************************************
1056 * GetObjectW (GDI32.@)
1058 INT WINAPI GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer )
1060 struct gdi_handle_entry *entry;
1061 const struct gdi_obj_funcs *funcs = NULL;
1062 INT result = 0;
1064 TRACE("%p %d %p\n", handle, count, buffer );
1066 EnterCriticalSection( &gdi_section );
1067 if ((entry = handle_entry( handle )))
1069 funcs = entry->funcs;
1070 handle = entry_to_handle( entry ); /* make it a full handle */
1072 LeaveCriticalSection( &gdi_section );
1074 if (funcs)
1076 if (!funcs->pGetObjectW)
1077 SetLastError( ERROR_INVALID_HANDLE );
1078 else if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
1079 SetLastError( ERROR_NOACCESS );
1080 else
1081 result = funcs->pGetObjectW( handle, count, buffer );
1083 return result;
1086 /***********************************************************************
1087 * GetObjectType (GDI32.@)
1089 DWORD WINAPI GetObjectType( HGDIOBJ handle )
1091 struct gdi_handle_entry *entry;
1092 DWORD result = 0;
1094 EnterCriticalSection( &gdi_section );
1095 if ((entry = handle_entry( handle ))) result = entry->type;
1096 LeaveCriticalSection( &gdi_section );
1098 TRACE("%p -> %u\n", handle, result );
1099 if (!result) SetLastError( ERROR_INVALID_HANDLE );
1100 return result;
1103 /***********************************************************************
1104 * GetCurrentObject (GDI32.@)
1106 * Get the currently selected object of a given type in a device context.
1108 * PARAMS
1109 * hdc [I] Device context to get the current object from
1110 * type [I] Type of current object to get (OBJ_* defines from "wingdi.h")
1112 * RETURNS
1113 * Success: The current object of the given type selected in hdc.
1114 * Failure: A NULL handle.
1116 * NOTES
1117 * - only the following object types are supported:
1118 *| OBJ_PEN
1119 *| OBJ_BRUSH
1120 *| OBJ_PAL
1121 *| OBJ_FONT
1122 *| OBJ_BITMAP
1124 HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
1126 HGDIOBJ ret = 0;
1127 DC * dc = get_dc_ptr( hdc );
1129 if (!dc) return 0;
1131 switch (type) {
1132 case OBJ_EXTPEN: /* fall through */
1133 case OBJ_PEN: ret = dc->hPen; break;
1134 case OBJ_BRUSH: ret = dc->hBrush; break;
1135 case OBJ_PAL: ret = dc->hPalette; break;
1136 case OBJ_FONT: ret = dc->hFont; break;
1137 case OBJ_BITMAP: ret = dc->hBitmap; break;
1139 /* tests show that OBJ_REGION is explicitly ignored */
1140 case OBJ_REGION: break;
1141 default:
1142 /* the SDK only mentions those above */
1143 FIXME("(%p,%d): unknown type.\n",hdc,type);
1144 break;
1146 release_dc_ptr( dc );
1147 return ret;
1151 /***********************************************************************
1152 * SelectObject (GDI32.@)
1154 * Select a Gdi object into a device context.
1156 * PARAMS
1157 * hdc [I] Device context to associate the object with
1158 * hObj [I] Gdi object to associate with hdc
1160 * RETURNS
1161 * Success: A non-NULL handle representing the previously selected object of
1162 * the same type as hObj.
1163 * Failure: A NULL object. If hdc is invalid, GetLastError() returns ERROR_INVALID_HANDLE.
1164 * if hObj is not a valid object handle, no last error is set. In either
1165 * case, hdc is unaffected by the call.
1167 HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ hObj )
1169 struct gdi_handle_entry *entry;
1170 const struct gdi_obj_funcs *funcs = NULL;
1172 TRACE( "(%p,%p)\n", hdc, hObj );
1174 EnterCriticalSection( &gdi_section );
1175 if ((entry = handle_entry( hObj )))
1177 funcs = entry->funcs;
1178 hObj = entry_to_handle( entry ); /* make it a full handle */
1180 LeaveCriticalSection( &gdi_section );
1182 if (funcs && funcs->pSelectObject) return funcs->pSelectObject( hObj, hdc );
1183 return 0;
1187 /***********************************************************************
1188 * UnrealizeObject (GDI32.@)
1190 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1192 const struct gdi_obj_funcs *funcs = NULL;
1193 struct gdi_handle_entry *entry;
1195 EnterCriticalSection( &gdi_section );
1196 if ((entry = handle_entry( obj )))
1198 funcs = entry->funcs;
1199 obj = entry_to_handle( entry ); /* make it a full handle */
1201 LeaveCriticalSection( &gdi_section );
1203 if (funcs && funcs->pUnrealizeObject) return funcs->pUnrealizeObject( obj );
1204 return funcs != NULL;
1208 /* Solid colors to enumerate */
1209 static const COLORREF solid_colors[] =
1210 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1211 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1212 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1213 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1214 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1215 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1216 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1217 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1221 /***********************************************************************
1222 * EnumObjects (GDI32.@)
1224 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1225 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1227 UINT i;
1228 INT retval = 0;
1229 LOGPEN pen;
1230 LOGBRUSH brush;
1232 TRACE("%p %d %p %08lx\n", hdc, nObjType, lpEnumFunc, lParam );
1233 switch(nObjType)
1235 case OBJ_PEN:
1236 /* Enumerate solid pens */
1237 for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
1239 pen.lopnStyle = PS_SOLID;
1240 pen.lopnWidth.x = 1;
1241 pen.lopnWidth.y = 0;
1242 pen.lopnColor = solid_colors[i];
1243 retval = lpEnumFunc( &pen, lParam );
1244 TRACE("solid pen %08x, ret=%d\n",
1245 solid_colors[i], retval);
1246 if (!retval) break;
1248 break;
1250 case OBJ_BRUSH:
1251 /* Enumerate solid brushes */
1252 for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
1254 brush.lbStyle = BS_SOLID;
1255 brush.lbColor = solid_colors[i];
1256 brush.lbHatch = 0;
1257 retval = lpEnumFunc( &brush, lParam );
1258 TRACE("solid brush %08x, ret=%d\n",
1259 solid_colors[i], retval);
1260 if (!retval) break;
1263 /* Now enumerate hatched brushes */
1264 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1266 brush.lbStyle = BS_HATCHED;
1267 brush.lbColor = RGB(0,0,0);
1268 brush.lbHatch = i;
1269 retval = lpEnumFunc( &brush, lParam );
1270 TRACE("hatched brush %d, ret=%d\n",
1271 i, retval);
1272 if (!retval) break;
1274 break;
1276 default:
1277 /* FIXME: implement Win32 types */
1278 WARN("(%d): Invalid type\n", nObjType );
1279 break;
1281 return retval;
1285 /***********************************************************************
1286 * SetObjectOwner (GDI32.@)
1288 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1290 /* Nothing to do */
1293 /***********************************************************************
1294 * GdiInitializeLanguagePack (GDI32.@)
1296 DWORD WINAPI GdiInitializeLanguagePack( DWORD arg )
1298 FIXME("stub\n");
1299 return 0;
1302 /***********************************************************************
1303 * GdiFlush (GDI32.@)
1305 BOOL WINAPI GdiFlush(void)
1307 return TRUE; /* FIXME */
1311 /***********************************************************************
1312 * GdiGetBatchLimit (GDI32.@)
1314 DWORD WINAPI GdiGetBatchLimit(void)
1316 return 1; /* FIXME */
1320 /***********************************************************************
1321 * GdiSetBatchLimit (GDI32.@)
1323 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1325 return 1; /* FIXME */
1329 /*******************************************************************
1330 * GetColorAdjustment [GDI32.@]
1334 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1336 FIXME("stub\n");
1337 return FALSE;
1340 /*******************************************************************
1341 * GdiComment [GDI32.@]
1345 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1347 DC *dc = get_dc_ptr(hdc);
1348 BOOL ret = FALSE;
1350 if(dc)
1352 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGdiComment );
1353 ret = physdev->funcs->pGdiComment( physdev, cbSize, lpData );
1354 release_dc_ptr( dc );
1356 return ret;
1359 /*******************************************************************
1360 * SetColorAdjustment [GDI32.@]
1364 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1366 FIXME("stub\n");
1367 return FALSE;