wined3d: Clear dirty flags after calling all the state handlers in context_apply_draw...
[wine.git] / dlls / gdi32 / gdiobj.c
blob8435c009716f2ecbb99ffd3c2835df6e83279af3
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 "ntgdi_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
39 #define FIRST_GDI_HANDLE 32
41 static GDI_SHARED_MEMORY gdi_shared;
42 static GDI_HANDLE_ENTRY *next_free;
43 static GDI_HANDLE_ENTRY *next_unused = gdi_shared.Handles + FIRST_GDI_HANDLE;
44 static LONG debug_count;
45 HMODULE gdi32_module = 0;
47 static inline HGDIOBJ entry_to_handle( GDI_HANDLE_ENTRY *entry )
49 unsigned int idx = entry - gdi_shared.Handles;
50 return LongToHandle( idx | (entry->Unique << 16) );
53 static inline GDI_HANDLE_ENTRY *handle_entry( HGDIOBJ handle )
55 unsigned int idx = LOWORD(handle);
57 if (idx < GDI_MAX_HANDLE_COUNT && gdi_shared.Handles[idx].Type)
59 if (!HIWORD( handle ) || HIWORD( handle ) == gdi_shared.Handles[idx].Unique)
60 return &gdi_shared.Handles[idx];
62 if (handle) WARN( "invalid handle %p\n", handle );
63 return NULL;
66 static inline struct gdi_obj_header *entry_obj( GDI_HANDLE_ENTRY *entry )
68 return (struct gdi_obj_header *)(ULONG_PTR)entry->Object;
71 /***********************************************************************
72 * GDI stock objects
75 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
76 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
77 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
79 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
80 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
81 static const LOGBRUSH DkGrayBrush = { BS_SOLID, RGB(64,64,64), 0 };
83 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
84 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
85 static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
87 static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 };
88 static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
90 /* reserve one extra entry for the stock default bitmap */
91 /* this is what Windows does too */
92 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
94 static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
95 static HGDIOBJ scaled_stock_objects[NB_STOCK_OBJECTS];
97 static CRITICAL_SECTION gdi_section;
98 static CRITICAL_SECTION_DEBUG critsect_debug =
100 0, 0, &gdi_section,
101 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
102 0, 0, { (DWORD_PTR)(__FILE__ ": gdi_section") }
104 static CRITICAL_SECTION gdi_section = { &critsect_debug, -1, 0, 0, 0, 0 };
107 /****************************************************************************
109 * language-independent stock fonts
113 static const LOGFONTW OEMFixedFont =
114 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
115 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" };
117 static const LOGFONTW AnsiFixedFont =
118 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
119 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier" };
121 static const LOGFONTW AnsiVarFont =
122 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
123 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" };
125 /******************************************************************************
127 * language-dependent stock fonts
129 * 'ANSI' charset and 'DEFAULT' charset is not same.
130 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
131 * 'ANSI' charset seems to be identical with ISO-8859-1.
132 * 'DEFAULT' charset is a language-dependent charset.
134 * 'System' font seems to be an alias for language-dependent font.
138 * language-dependent stock fonts for all known charsets
139 * please see TranslateCharsetInfo (dlls/gdi/font.c) and
140 * CharsetBindingInfo (dlls/x11drv/xfont.c),
141 * and modify entries for your language if needed.
143 struct DefaultFontInfo
145 UINT charset;
146 LOGFONTW SystemFont;
147 LOGFONTW DeviceDefaultFont;
148 LOGFONTW SystemFixedFont;
149 LOGFONTW DefaultGuiFont;
152 static const struct DefaultFontInfo default_fonts[] =
154 { ANSI_CHARSET,
155 { /* System */
156 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
157 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
159 { /* Device Default */
160 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
161 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
163 { /* System Fixed */
164 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
165 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
167 { /* DefaultGuiFont */
168 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
169 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
172 { EASTEUROPE_CHARSET,
173 { /* System */
174 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
175 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
177 { /* Device Default */
178 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
179 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
181 { /* System Fixed */
182 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
183 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
185 { /* DefaultGuiFont */
186 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
187 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
190 { RUSSIAN_CHARSET,
191 { /* System */
192 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
193 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
195 { /* Device Default */
196 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
197 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
199 { /* System Fixed */
200 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
201 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
203 { /* DefaultGuiFont */
204 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
205 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
208 { GREEK_CHARSET,
209 { /* System */
210 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
211 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
213 { /* Device Default */
214 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
215 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
217 { /* System Fixed */
218 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
219 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
221 { /* DefaultGuiFont */
222 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
223 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
226 { TURKISH_CHARSET,
227 { /* System */
228 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, TURKISH_CHARSET,
229 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
231 { /* Device Default */
232 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, TURKISH_CHARSET,
233 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
235 { /* System Fixed */
236 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
237 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
239 { /* DefaultGuiFont */
240 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
241 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
244 { HEBREW_CHARSET,
245 { /* System */
246 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, HEBREW_CHARSET,
247 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
249 { /* Device Default */
250 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, HEBREW_CHARSET,
251 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
253 { /* System Fixed */
254 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
255 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
257 { /* DefaultGuiFont */
258 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
259 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
262 { ARABIC_CHARSET,
263 { /* System */
264 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ARABIC_CHARSET,
265 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
267 { /* Device Default */
268 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ARABIC_CHARSET,
269 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
271 { /* System Fixed */
272 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
273 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
275 { /* DefaultGuiFont */
276 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
277 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
280 { BALTIC_CHARSET,
281 { /* System */
282 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, BALTIC_CHARSET,
283 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
285 { /* Device Default */
286 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, BALTIC_CHARSET,
287 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
289 { /* System Fixed */
290 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
291 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
293 { /* DefaultGuiFont */
294 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
295 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
298 { THAI_CHARSET,
299 { /* System */
300 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, THAI_CHARSET,
301 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
303 { /* Device Default */
304 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, THAI_CHARSET,
305 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
307 { /* System Fixed */
308 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
309 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
311 { /* DefaultGuiFont */
312 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
313 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
316 { SHIFTJIS_CHARSET,
317 { /* System */
318 18, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
319 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
321 { /* Device Default */
322 18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
323 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
325 { /* System Fixed */
326 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
327 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
329 { /* DefaultGuiFont */
330 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
331 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
334 { GB2312_CHARSET,
335 { /* System */
336 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GB2312_CHARSET,
337 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
339 { /* Device Default */
340 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GB2312_CHARSET,
341 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
343 { /* System Fixed */
344 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
345 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
347 { /* DefaultGuiFont */
348 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
349 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
352 { HANGEUL_CHARSET,
353 { /* System */
354 16, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
355 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
357 { /* Device Default */
358 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
359 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
361 { /* System Fixed */
362 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
363 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
365 { /* DefaultGuiFont */
366 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
367 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
370 { CHINESEBIG5_CHARSET,
371 { /* System */
372 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
373 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
375 { /* Device Default */
376 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
377 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
379 { /* System Fixed */
380 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
381 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
383 { /* DefaultGuiFont */
384 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
385 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
388 { JOHAB_CHARSET,
389 { /* System */
390 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, JOHAB_CHARSET,
391 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
393 { /* Device Default */
394 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, JOHAB_CHARSET,
395 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
397 { /* System Fixed */
398 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
399 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
401 { /* DefaultGuiFont */
402 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
403 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
409 /*************************************************************************
410 * __wine_make_gdi_object_system (GDI32.@)
412 * USER has to tell GDI that its system brushes and pens are non-deletable.
413 * For a description of the GDI object magics and their flags,
414 * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though).
416 void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set)
418 GDI_HANDLE_ENTRY *entry;
420 EnterCriticalSection( &gdi_section );
421 if ((entry = handle_entry( handle ))) entry_obj( entry )->system = !!set;
422 LeaveCriticalSection( &gdi_section );
425 /******************************************************************************
426 * get_default_fonts
428 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
430 unsigned int n;
432 for(n = 0; n < ARRAY_SIZE( default_fonts ); n++)
434 if ( default_fonts[n].charset == charset )
435 return &default_fonts[n];
438 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
439 return &default_fonts[0];
443 /******************************************************************************
444 * get_default_charset (internal)
446 * get the language-dependent charset that can handle CP_ACP correctly.
448 static UINT get_default_charset( void )
450 CHARSETINFO csi;
451 UINT uACP;
453 uACP = GetACP();
454 csi.ciCharset = ANSI_CHARSET;
455 if ( !TranslateCharsetInfo( ULongToPtr(uACP), &csi, TCI_SRCCODEPAGE ) )
457 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
458 return ANSI_CHARSET;
461 return csi.ciCharset;
465 /***********************************************************************
466 * GDI_get_ref_count
468 * Retrieve the reference count of a GDI object.
469 * Note: the object must be locked otherwise the count is meaningless.
471 UINT GDI_get_ref_count( HGDIOBJ handle )
473 GDI_HANDLE_ENTRY *entry;
474 UINT ret = 0;
476 EnterCriticalSection( &gdi_section );
477 if ((entry = handle_entry( handle ))) ret = entry_obj( entry )->selcount;
478 LeaveCriticalSection( &gdi_section );
479 return ret;
483 /***********************************************************************
484 * GDI_inc_ref_count
486 * Increment the reference count of a GDI object.
488 HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle )
490 GDI_HANDLE_ENTRY *entry;
492 EnterCriticalSection( &gdi_section );
493 if ((entry = handle_entry( handle ))) entry_obj( entry )->selcount++;
494 else handle = 0;
495 LeaveCriticalSection( &gdi_section );
496 return handle;
500 /***********************************************************************
501 * GDI_dec_ref_count
503 * Decrement the reference count of a GDI object.
505 BOOL GDI_dec_ref_count( HGDIOBJ handle )
507 GDI_HANDLE_ENTRY *entry;
509 EnterCriticalSection( &gdi_section );
510 if ((entry = handle_entry( handle )))
512 assert( entry_obj( entry )->selcount );
513 if (!--entry_obj( entry )->selcount && entry_obj( entry )->deleted)
515 /* handle delayed DeleteObject*/
516 entry_obj( entry )->deleted = 0;
517 LeaveCriticalSection( &gdi_section );
518 TRACE( "executing delayed DeleteObject for %p\n", handle );
519 DeleteObject( handle );
520 return TRUE;
523 LeaveCriticalSection( &gdi_section );
524 return entry != NULL;
528 /******************************************************************************
529 * get_reg_dword
531 * Read a DWORD value from the registry
533 static BOOL get_reg_dword(HKEY base, const WCHAR *key_name, const WCHAR *value_name, DWORD *value)
535 HKEY key;
536 DWORD type, data, size = sizeof(data);
537 BOOL ret = FALSE;
539 if (RegOpenKeyW(base, key_name, &key) == ERROR_SUCCESS)
541 if (RegQueryValueExW(key, value_name, NULL, &type, (void *)&data, &size) == ERROR_SUCCESS &&
542 type == REG_DWORD)
544 *value = data;
545 ret = TRUE;
547 RegCloseKey(key);
549 return ret;
552 /******************************************************************************
553 * get_dpi
555 * get the dpi from the registry
557 DWORD get_dpi(void)
559 DWORD dpi;
561 if (get_reg_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", &dpi))
562 return dpi;
563 if (get_reg_dword(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", &dpi))
564 return dpi;
565 return 0;
568 /******************************************************************************
569 * get_system_dpi
571 * Get the system DPI, based on the DPI awareness mode.
573 DWORD get_system_dpi(void)
575 static UINT (WINAPI *pGetDpiForSystem)(void);
577 if (!pGetDpiForSystem)
579 HMODULE user = GetModuleHandleW( L"user32.dll" );
580 if (user) pGetDpiForSystem = (void *)GetProcAddress( user, "GetDpiForSystem" );
582 return pGetDpiForSystem ? pGetDpiForSystem() : 96;
585 static HFONT create_scaled_font( const LOGFONTW *deffont )
587 LOGFONTW lf;
588 static DWORD dpi;
590 if (!dpi)
592 dpi = get_dpi();
593 if (!dpi) dpi = 96;
596 lf = *deffont;
597 lf.lfHeight = MulDiv( lf.lfHeight, dpi, 96 );
598 return CreateFontIndirectW( &lf );
601 static void set_gdi_shared(void)
603 #ifndef _WIN64
604 if (NtCurrentTeb()->GdiBatchCount)
606 TEB64 *teb64 = (TEB64 *)(UINT_PTR)NtCurrentTeb()->GdiBatchCount;
607 PEB64 *peb64 = (PEB64 *)(UINT_PTR)teb64->Peb;
608 peb64->GdiSharedHandleTable = (UINT_PTR)&gdi_shared;
609 return;
611 #endif
612 /* NOTE: Windows uses 32-bit for 32-bit kernel */
613 NtCurrentTeb()->Peb->GdiSharedHandleTable = &gdi_shared;
616 static HGDIOBJ make_stock_object( HGDIOBJ obj )
618 GDI_HANDLE_ENTRY *entry;
620 if (!(entry = handle_entry( obj ))) return 0;
621 entry_obj( entry )->system = TRUE;
622 entry->StockFlag = 1;
623 return entry_to_handle( entry );
626 /***********************************************************************
627 * DllMain
629 * GDI initialization.
631 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
633 const struct DefaultFontInfo* deffonts;
634 int i;
636 if (reason != DLL_PROCESS_ATTACH) return TRUE;
638 gdi32_module = inst;
639 DisableThreadLibraryCalls( inst );
640 set_gdi_shared();
641 font_init();
643 /* create stock objects */
644 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
645 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
646 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
647 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
648 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
649 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
651 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
652 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
653 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
655 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
656 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
658 /* language-independent stock fonts */
659 stock_objects[OEM_FIXED_FONT] = CreateFontIndirectW( &OEMFixedFont );
660 stock_objects[ANSI_FIXED_FONT] = CreateFontIndirectW( &AnsiFixedFont );
661 stock_objects[ANSI_VAR_FONT] = CreateFontIndirectW( &AnsiVarFont );
663 /* language-dependent stock fonts */
664 deffonts = get_default_fonts(get_default_charset());
665 stock_objects[SYSTEM_FONT] = CreateFontIndirectW( &deffonts->SystemFont );
666 stock_objects[DEVICE_DEFAULT_FONT] = CreateFontIndirectW( &deffonts->DeviceDefaultFont );
667 stock_objects[SYSTEM_FIXED_FONT] = CreateFontIndirectW( &deffonts->SystemFixedFont );
668 stock_objects[DEFAULT_GUI_FONT] = CreateFontIndirectW( &deffonts->DefaultGuiFont );
670 scaled_stock_objects[OEM_FIXED_FONT] = create_scaled_font( &OEMFixedFont );
671 scaled_stock_objects[SYSTEM_FONT] = create_scaled_font( &deffonts->SystemFont );
672 scaled_stock_objects[SYSTEM_FIXED_FONT] = create_scaled_font( &deffonts->SystemFixedFont );
673 scaled_stock_objects[DEFAULT_GUI_FONT] = create_scaled_font( &deffonts->DefaultGuiFont );
675 stock_objects[DC_BRUSH] = CreateBrushIndirect( &DCBrush );
676 stock_objects[DC_PEN] = CreatePenIndirect( &DCPen );
678 /* clear the NOSYSTEM bit on all stock objects*/
679 for (i = 0; i < NB_STOCK_OBJECTS; i++)
681 stock_objects[i] = make_stock_object( stock_objects[i] );
682 scaled_stock_objects[i] = make_stock_object( scaled_stock_objects[i] );
684 return TRUE;
688 /***********************************************************************
689 * GdiDllInitialize
691 * Stub entry point, some games (CoD: Black Ops 3) call it directly.
693 BOOL WINAPI GdiDllInitialize( HINSTANCE inst, DWORD reason, LPVOID reserved )
695 FIXME("stub\n");
696 return TRUE;
700 static const char *gdi_obj_type( unsigned type )
702 switch ( type )
704 case NTGDI_OBJ_PEN: return "NTGDI_OBJ_PEN";
705 case NTGDI_OBJ_BRUSH: return "NTGDI_OBJ_BRUSH";
706 case NTGDI_OBJ_DC: return "NTGDI_OBJ_DC";
707 case NTGDI_OBJ_METADC: return "NTGDI_OBJ_METADC";
708 case NTGDI_OBJ_PAL: return "NTGDI_OBJ_PAL";
709 case NTGDI_OBJ_FONT: return "NTGDI_OBJ_FONT";
710 case NTGDI_OBJ_BITMAP: return "NTGDI_OBJ_BITMAP";
711 case NTGDI_OBJ_REGION: return "NTGDI_OBJ_REGION";
712 case NTGDI_OBJ_METAFILE: return "NTGDI_OBJ_METAFILE";
713 case NTGDI_OBJ_MEMDC: return "NTGDI_OBJ_MEMDC";
714 case NTGDI_OBJ_EXTPEN: return "NTGDI_OBJ_EXTPEN";
715 case NTGDI_OBJ_ENHMETADC: return "NTGDI_OBJ_ENHMETADC";
716 case NTGDI_OBJ_ENHMETAFILE: return "NTGDI_OBJ_ENHMETAFILE";
717 default: return "UNKNOWN";
721 static void dump_gdi_objects( void )
723 GDI_HANDLE_ENTRY *entry;
725 TRACE( "%u objects:\n", GDI_MAX_HANDLE_COUNT );
727 EnterCriticalSection( &gdi_section );
728 for (entry = gdi_shared.Handles; entry < next_unused; entry++)
730 if (!entry->Type)
731 TRACE( "handle %p FREE\n", entry_to_handle( entry ));
732 else
733 TRACE( "handle %p obj %s type %s selcount %u deleted %u\n",
734 entry_to_handle( entry ), wine_dbgstr_longlong( entry->Object ),
735 gdi_obj_type( entry->ExtType ), entry_obj( entry )->selcount,
736 entry_obj( entry )->deleted );
738 LeaveCriticalSection( &gdi_section );
741 /***********************************************************************
742 * alloc_gdi_handle
744 * Allocate a GDI handle for an object, which must have been allocated on the process heap.
746 HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, WORD type, const struct gdi_obj_funcs *funcs )
748 GDI_HANDLE_ENTRY *entry;
749 HGDIOBJ ret;
751 assert( type ); /* type 0 is reserved to mark free entries */
753 EnterCriticalSection( &gdi_section );
755 entry = next_free;
756 if (entry)
757 next_free = (GDI_HANDLE_ENTRY *)(UINT_PTR)entry->Object;
758 else if (next_unused < gdi_shared.Handles + GDI_MAX_HANDLE_COUNT)
759 entry = next_unused++;
760 else
762 LeaveCriticalSection( &gdi_section );
763 ERR( "out of GDI object handles, expect a crash\n" );
764 if (TRACE_ON(gdi)) dump_gdi_objects();
765 return 0;
767 obj->funcs = funcs;
768 obj->selcount = 0;
769 obj->system = 0;
770 obj->deleted = 0;
771 entry->Object = (UINT_PTR)obj;
772 entry->Type = type & 0x1f;
773 entry->ExtType = type;
774 if (++entry->Generation == 0xff) entry->Generation = 1;
775 ret = entry_to_handle( entry );
776 LeaveCriticalSection( &gdi_section );
777 TRACE( "allocated %s %p %u/%u\n", gdi_obj_type(type), ret,
778 InterlockedIncrement( &debug_count ), GDI_MAX_HANDLE_COUNT );
779 return ret;
783 /***********************************************************************
784 * free_gdi_handle
786 * Free a GDI handle and return a pointer to the object.
788 void *free_gdi_handle( HGDIOBJ handle )
790 void *object = NULL;
791 GDI_HANDLE_ENTRY *entry;
793 EnterCriticalSection( &gdi_section );
794 if ((entry = handle_entry( handle )))
796 TRACE( "freed %s %p %u/%u\n", gdi_obj_type( entry->ExtType ), handle,
797 InterlockedDecrement( &debug_count ) + 1, GDI_MAX_HANDLE_COUNT );
798 object = entry_obj( entry );
799 entry->Type = 0;
800 entry->Object = (UINT_PTR)next_free;
801 next_free = entry;
803 LeaveCriticalSection( &gdi_section );
804 return object;
808 /***********************************************************************
809 * get_full_gdi_handle
811 * Return the full GDI handle from a possibly truncated value.
813 HGDIOBJ get_full_gdi_handle( HGDIOBJ handle )
815 GDI_HANDLE_ENTRY *entry;
817 if (!HIWORD( handle ))
819 EnterCriticalSection( &gdi_section );
820 if ((entry = handle_entry( handle ))) handle = entry_to_handle( entry );
821 LeaveCriticalSection( &gdi_section );
823 return handle;
826 /***********************************************************************
827 * get_any_obj_ptr
829 * Return a pointer to, and the type of, the GDI object
830 * associated with the handle.
831 * The object must be released with GDI_ReleaseObj.
833 void *get_any_obj_ptr( HGDIOBJ handle, WORD *type )
835 void *ptr = NULL;
836 GDI_HANDLE_ENTRY *entry;
838 EnterCriticalSection( &gdi_section );
840 if ((entry = handle_entry( handle )))
842 ptr = entry_obj( entry );
843 *type = entry->ExtType;
846 if (!ptr) LeaveCriticalSection( &gdi_section );
847 return ptr;
850 /***********************************************************************
851 * GDI_GetObjPtr
853 * Return a pointer to the GDI object associated with the handle.
854 * Return NULL if the object has the wrong type.
855 * The object must be released with GDI_ReleaseObj.
857 void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
859 WORD ret_type;
860 void *ptr = get_any_obj_ptr( handle, &ret_type );
861 if (ptr && ret_type != type)
863 GDI_ReleaseObj( handle );
864 ptr = NULL;
866 return ptr;
869 /***********************************************************************
870 * GDI_ReleaseObj
873 void GDI_ReleaseObj( HGDIOBJ handle )
875 LeaveCriticalSection( &gdi_section );
879 /***********************************************************************
880 * GDI_CheckNotLock
882 void GDI_CheckNotLock(void)
884 if (RtlIsCriticalSectionLockedByThread(&gdi_section))
886 ERR( "BUG: holding GDI lock\n" );
887 DebugBreak();
892 /***********************************************************************
893 * NtGdiDeleteObjectApp (win32u.@)
895 * Delete a Gdi object.
897 * PARAMS
898 * obj [I] Gdi object to delete
900 * RETURNS
901 * Success: TRUE. If obj was not returned from GetStockObject(), any resources
902 * it consumed are released.
903 * Failure: FALSE, if obj is not a valid Gdi object, or is currently selected
904 * into a DC.
906 BOOL WINAPI NtGdiDeleteObjectApp( HGDIOBJ obj )
908 GDI_HANDLE_ENTRY *entry;
909 const struct gdi_obj_funcs *funcs = NULL;
910 struct gdi_obj_header *header;
912 EnterCriticalSection( &gdi_section );
913 if (!(entry = handle_entry( obj )))
915 LeaveCriticalSection( &gdi_section );
916 return FALSE;
919 header = entry_obj( entry );
920 if (header->system)
922 TRACE("Preserving system object %p\n", obj);
923 LeaveCriticalSection( &gdi_section );
924 return TRUE;
927 obj = entry_to_handle( entry ); /* make it a full handle */
929 if (header->selcount)
931 TRACE("delayed for %p because object in use, count %u\n", obj, header->selcount );
932 header->deleted = 1; /* mark for delete */
934 else funcs = header->funcs;
936 LeaveCriticalSection( &gdi_section );
938 TRACE("%p\n", obj );
940 if (funcs && funcs->pDeleteObject) return funcs->pDeleteObject( obj );
941 return TRUE;
944 /***********************************************************************
945 * NtGdiCreateClientObj (win32u.@)
947 HANDLE WINAPI NtGdiCreateClientObj( ULONG type )
949 struct gdi_obj_header *obj;
950 HGDIOBJ handle;
952 if (!(obj = HeapAlloc( GetProcessHeap(), 0, sizeof(*obj) )))
953 return 0;
955 handle = alloc_gdi_handle( obj, type, NULL );
956 if (!handle) HeapFree( GetProcessHeap(), 0, obj );
957 return handle;
960 /***********************************************************************
961 * NtGdiDeleteClientObj (win32u.@)
963 BOOL WINAPI NtGdiDeleteClientObj( HGDIOBJ handle )
965 void *obj;
966 if (!(obj = free_gdi_handle( handle ))) return FALSE;
967 HeapFree( GetProcessHeap(), 0, obj );
968 return TRUE;
971 /***********************************************************************
972 * GetStockObject (GDI32.@)
974 HGDIOBJ WINAPI GetStockObject( INT obj )
976 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
977 switch (obj)
979 case OEM_FIXED_FONT:
980 case SYSTEM_FONT:
981 case SYSTEM_FIXED_FONT:
982 case DEFAULT_GUI_FONT:
983 if (get_system_dpi() != 96) return scaled_stock_objects[obj];
984 break;
986 return stock_objects[obj];
990 /***********************************************************************
991 * NtGdiExtGetObjectW (win32u.@)
993 INT WINAPI NtGdiExtGetObjectW( HGDIOBJ handle, INT count, void *buffer )
995 GDI_HANDLE_ENTRY *entry;
996 const struct gdi_obj_funcs *funcs = NULL;
997 INT result = 0;
999 TRACE("%p %d %p\n", handle, count, buffer );
1001 EnterCriticalSection( &gdi_section );
1002 if ((entry = handle_entry( handle )))
1004 funcs = entry_obj( entry )->funcs;
1005 handle = entry_to_handle( entry ); /* make it a full handle */
1007 LeaveCriticalSection( &gdi_section );
1009 if (funcs && funcs->pGetObjectW)
1011 if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
1012 SetLastError( ERROR_NOACCESS );
1013 else
1014 result = funcs->pGetObjectW( handle, count, buffer );
1016 return result;
1019 /***********************************************************************
1020 * GetCurrentObject (GDI32.@)
1022 * Get the currently selected object of a given type in a device context.
1024 * PARAMS
1025 * hdc [I] Device context to get the current object from
1026 * type [I] Type of current object to get (OBJ_* defines from "wingdi.h")
1028 * RETURNS
1029 * Success: The current object of the given type selected in hdc.
1030 * Failure: A NULL handle.
1032 * NOTES
1033 * - only the following object types are supported:
1034 *| OBJ_PEN
1035 *| OBJ_BRUSH
1036 *| OBJ_PAL
1037 *| OBJ_FONT
1038 *| OBJ_BITMAP
1040 HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
1042 HGDIOBJ ret = 0;
1043 DC * dc = get_dc_ptr( hdc );
1045 if (!dc) return 0;
1047 switch (type) {
1048 case OBJ_EXTPEN: /* fall through */
1049 case OBJ_PEN: ret = dc->hPen; break;
1050 case OBJ_BRUSH: ret = dc->hBrush; break;
1051 case OBJ_PAL: ret = dc->hPalette; break;
1052 case OBJ_FONT: ret = dc->hFont; break;
1053 case OBJ_BITMAP: ret = dc->hBitmap; break;
1055 /* tests show that OBJ_REGION is explicitly ignored */
1056 case OBJ_REGION: break;
1057 default:
1058 /* the SDK only mentions those above */
1059 FIXME("(%p,%d): unknown type.\n",hdc,type);
1060 break;
1062 release_dc_ptr( dc );
1063 return ret;
1067 /***********************************************************************
1068 * UnrealizeObject (GDI32.@)
1070 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1072 const struct gdi_obj_funcs *funcs = NULL;
1073 GDI_HANDLE_ENTRY *entry;
1075 EnterCriticalSection( &gdi_section );
1076 if ((entry = handle_entry( obj )))
1078 funcs = entry_obj( entry )->funcs;
1079 obj = entry_to_handle( entry ); /* make it a full handle */
1081 LeaveCriticalSection( &gdi_section );
1083 if (funcs && funcs->pUnrealizeObject) return funcs->pUnrealizeObject( obj );
1084 return funcs != NULL;
1088 /* Solid colors to enumerate */
1089 static const COLORREF solid_colors[] =
1090 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1091 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1092 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1093 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1094 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1095 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1096 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1097 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1101 /***********************************************************************
1102 * EnumObjects (GDI32.@)
1104 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1105 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1107 UINT i;
1108 INT retval = 0;
1109 LOGPEN pen;
1110 LOGBRUSH brush;
1112 TRACE("%p %d %p %08lx\n", hdc, nObjType, lpEnumFunc, lParam );
1113 switch(nObjType)
1115 case OBJ_PEN:
1116 /* Enumerate solid pens */
1117 for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
1119 pen.lopnStyle = PS_SOLID;
1120 pen.lopnWidth.x = 1;
1121 pen.lopnWidth.y = 0;
1122 pen.lopnColor = solid_colors[i];
1123 retval = lpEnumFunc( &pen, lParam );
1124 TRACE("solid pen %08x, ret=%d\n",
1125 solid_colors[i], retval);
1126 if (!retval) break;
1128 break;
1130 case OBJ_BRUSH:
1131 /* Enumerate solid brushes */
1132 for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
1134 brush.lbStyle = BS_SOLID;
1135 brush.lbColor = solid_colors[i];
1136 brush.lbHatch = 0;
1137 retval = lpEnumFunc( &brush, lParam );
1138 TRACE("solid brush %08x, ret=%d\n",
1139 solid_colors[i], retval);
1140 if (!retval) break;
1143 /* Now enumerate hatched brushes */
1144 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1146 brush.lbStyle = BS_HATCHED;
1147 brush.lbColor = RGB(0,0,0);
1148 brush.lbHatch = i;
1149 retval = lpEnumFunc( &brush, lParam );
1150 TRACE("hatched brush %d, ret=%d\n",
1151 i, retval);
1152 if (!retval) break;
1154 break;
1156 default:
1157 /* FIXME: implement Win32 types */
1158 WARN("(%d): Invalid type\n", nObjType );
1159 break;
1161 return retval;
1165 /***********************************************************************
1166 * SetObjectOwner (GDI32.@)
1168 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1170 /* Nothing to do */
1173 /***********************************************************************
1174 * GdiInitializeLanguagePack (GDI32.@)
1176 DWORD WINAPI GdiInitializeLanguagePack( DWORD arg )
1178 FIXME("stub\n");
1179 return 0;
1182 /***********************************************************************
1183 * GdiFlush (GDI32.@)
1185 BOOL WINAPI GdiFlush(void)
1187 return TRUE; /* FIXME */
1191 /***********************************************************************
1192 * GdiGetBatchLimit (GDI32.@)
1194 DWORD WINAPI GdiGetBatchLimit(void)
1196 return 1; /* FIXME */
1200 /***********************************************************************
1201 * GdiSetBatchLimit (GDI32.@)
1203 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1205 return 1; /* FIXME */
1209 /*******************************************************************
1210 * GetColorAdjustment [GDI32.@]
1214 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1216 FIXME("stub\n");
1217 return FALSE;
1220 /*******************************************************************
1221 * GdiComment [GDI32.@]
1225 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1227 DC *dc = get_dc_ptr(hdc);
1228 BOOL ret = FALSE;
1230 if(dc)
1232 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGdiComment );
1233 ret = physdev->funcs->pGdiComment( physdev, cbSize, lpData );
1234 release_dc_ptr( dc );
1236 return ret;
1239 /*******************************************************************
1240 * SetColorAdjustment [GDI32.@]
1244 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1246 FIXME("stub\n");
1247 return FALSE;