~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/wined3d/wined3d_main.c

Version: ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Direct3D wine internal interface main
  3  *
  4  * Copyright 2002-2003 The wine-d3d team
  5  * Copyright 2002-2003 Raphael Junqueira
  6  * Copyright 2004      Jason Edmeades
  7  * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
  8  * Copyright 2009 Henri Verbeet for CodeWeavers
  9  *
 10  * This library is free software; you can redistribute it and/or
 11  * modify it under the terms of the GNU Lesser General Public
 12  * License as published by the Free Software Foundation; either
 13  * version 2.1 of the License, or (at your option) any later version.
 14  *
 15  * This library is distributed in the hope that it will be useful,
 16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18  * Lesser General Public License for more details.
 19  *
 20  * You should have received a copy of the GNU Lesser General Public
 21  * License along with this library; if not, write to the Free Software
 22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 23  */
 24 
 25 #include "config.h"
 26 
 27 #include "initguid.h"
 28 #include "wined3d_private.h"
 29 
 30 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 31 WINE_DECLARE_DEBUG_CHANNEL(winediag);
 32 
 33 struct wined3d_wndproc
 34 {
 35     HWND window;
 36     BOOL unicode;
 37     WNDPROC proc;
 38     struct wined3d_device *device;
 39 };
 40 
 41 struct wined3d_wndproc_table
 42 {
 43     struct wined3d_wndproc *entries;
 44     unsigned int count;
 45     unsigned int size;
 46 };
 47 
 48 static struct wined3d_wndproc_table wndproc_table;
 49 
 50 int num_lock = 0;
 51 void (CDECL *wine_tsx11_lock_ptr)(void) = NULL;
 52 void (CDECL *wine_tsx11_unlock_ptr)(void) = NULL;
 53 
 54 static CRITICAL_SECTION wined3d_cs;
 55 static CRITICAL_SECTION_DEBUG wined3d_cs_debug =
 56 {
 57     0, 0, &wined3d_cs,
 58     {&wined3d_cs_debug.ProcessLocksList,
 59     &wined3d_cs_debug.ProcessLocksList},
 60     0, 0, {(DWORD_PTR)(__FILE__ ": wined3d_cs")}
 61 };
 62 static CRITICAL_SECTION wined3d_cs = {&wined3d_cs_debug, -1, 0, 0, 0, 0};
 63 
 64 static CRITICAL_SECTION wined3d_wndproc_cs;
 65 static CRITICAL_SECTION_DEBUG wined3d_wndproc_cs_debug =
 66 {
 67     0, 0, &wined3d_wndproc_cs,
 68     {&wined3d_wndproc_cs_debug.ProcessLocksList,
 69     &wined3d_wndproc_cs_debug.ProcessLocksList},
 70     0, 0, {(DWORD_PTR)(__FILE__ ": wined3d_wndproc_cs")}
 71 };
 72 static CRITICAL_SECTION wined3d_wndproc_cs = {&wined3d_wndproc_cs_debug, -1, 0, 0, 0, 0};
 73 
 74 /* When updating default value here, make sure to update winecfg as well,
 75  * where appropriate. */
 76 struct wined3d_settings wined3d_settings =
 77 {
 78     VS_HW,          /* Hardware by default */
 79     PS_HW,          /* Hardware by default */
 80     TRUE,           /* Use of GLSL enabled by default */
 81     ORM_FBO,        /* Use FBOs to do offscreen rendering */
 82     RTL_READTEX,    /* Default render target locking method */
 83     PCI_VENDOR_NONE,/* PCI Vendor ID */
 84     PCI_DEVICE_NONE,/* PCI Device ID */
 85     0,              /* The default of memory is set in init_driver_info */
 86     NULL,           /* No wine logo by default */
 87     TRUE,           /* Multisampling enabled by default. */
 88     FALSE,          /* No strict draw ordering. */
 89     FALSE,          /* Try to render onscreen by default. */
 90 };
 91 
 92 /* Do not call while under the GL lock. */
 93 struct wined3d * CDECL wined3d_create(UINT version, DWORD flags)
 94 {
 95     struct wined3d *object;
 96     HRESULT hr;
 97 
 98     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
 99     if (!object)
100     {
101         ERR("Failed to allocate wined3d object memory.\n");
102         return NULL;
103     }
104 
105     hr = wined3d_init(object, version, flags);
106     if (FAILED(hr))
107     {
108         WARN("Failed to initialize wined3d object, hr %#x.\n", hr);
109         HeapFree(GetProcessHeap(), 0, object);
110         return NULL;
111     }
112 
113     TRACE("Created wined3d object %p for d3d%d support.\n", object, version);
114 
115     return object;
116 }
117 
118 static DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
119 {
120     if (appkey && !RegQueryValueExA(appkey, name, 0, NULL, (BYTE *)buffer, &size)) return 0;
121     if (defkey && !RegQueryValueExA(defkey, name, 0, NULL, (BYTE *)buffer, &size)) return 0;
122     return ERROR_FILE_NOT_FOUND;
123 }
124 
125 static DWORD get_config_key_dword(HKEY defkey, HKEY appkey, const char *name, DWORD *data)
126 {
127     DWORD type;
128     DWORD size = sizeof(DWORD);
129     if (appkey && !RegQueryValueExA(appkey, name, 0, &type, (BYTE *)data, &size) && (type == REG_DWORD)) return 0;
130     if (defkey && !RegQueryValueExA(defkey, name, 0, &type, (BYTE *)data, &size) && (type == REG_DWORD)) return 0;
131     return ERROR_FILE_NOT_FOUND;
132 }
133 
134 static void CDECL wined3d_do_nothing(void)
135 {
136 }
137 
138 static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
139 {
140     DWORD wined3d_context_tls_idx;
141     HMODULE mod;
142     char buffer[MAX_PATH+10];
143     DWORD size = sizeof(buffer);
144     HKEY hkey = 0;
145     HKEY appkey = 0;
146     DWORD len, tmpvalue;
147     WNDCLASSA wc;
148 
149     wined3d_context_tls_idx = TlsAlloc();
150     if (wined3d_context_tls_idx == TLS_OUT_OF_INDEXES)
151     {
152         DWORD err = GetLastError();
153         ERR("Failed to allocate context TLS index, err %#x.\n", err);
154         return FALSE;
155     }
156     context_set_tls_idx(wined3d_context_tls_idx);
157 
158     /* We need our own window class for a fake window which we use to retrieve GL capabilities */
159     /* We might need CS_OWNDC in the future if we notice strange things on Windows.
160      * Various articles/posts about OpenGL problems on Windows recommend this. */
161     wc.style                = CS_HREDRAW | CS_VREDRAW;
162     wc.lpfnWndProc          = DefWindowProcA;
163     wc.cbClsExtra           = 0;
164     wc.cbWndExtra           = 0;
165     wc.hInstance            = hInstDLL;
166     wc.hIcon                = LoadIconA(NULL, (LPCSTR)IDI_WINLOGO);
167     wc.hCursor              = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
168     wc.hbrBackground        = NULL;
169     wc.lpszMenuName         = NULL;
170     wc.lpszClassName        = WINED3D_OPENGL_WINDOW_CLASS_NAME;
171 
172     if (!RegisterClassA(&wc))
173     {
174         ERR("Failed to register window class 'WineD3D_OpenGL'!\n");
175         if (!TlsFree(wined3d_context_tls_idx))
176         {
177             DWORD err = GetLastError();
178             ERR("Failed to free context TLS index, err %#x.\n", err);
179         }
180         return FALSE;
181     }
182 
183     DisableThreadLibraryCalls(hInstDLL);
184 
185     mod = GetModuleHandleA( "winex11.drv" );
186     if (mod)
187     {
188         wine_tsx11_lock_ptr   = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
189         wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
190     }
191     else /* We are most likely on Windows */
192     {
193         wine_tsx11_lock_ptr   = wined3d_do_nothing;
194         wine_tsx11_unlock_ptr = wined3d_do_nothing;
195     }
196     /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */
197     if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey ) ) hkey = 0;
198 
199     len = GetModuleFileNameA( 0, buffer, MAX_PATH );
200     if (len && len < MAX_PATH)
201     {
202         HKEY tmpkey;
203         /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */
204         if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
205         {
206             char *p, *appname = buffer;
207             if ((p = strrchr( appname, '/' ))) appname = p + 1;
208             if ((p = strrchr( appname, '\\' ))) appname = p + 1;
209             strcat( appname, "\\Direct3D" );
210             TRACE("appname = [%s]\n", appname);
211             if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
212             RegCloseKey( tmpkey );
213         }
214     }
215 
216     if (hkey || appkey)
217     {
218         if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) )
219         {
220             if (!strcmp(buffer,"none"))
221             {
222                 TRACE("Disable vertex shaders\n");
223                 wined3d_settings.vs_mode = VS_NONE;
224             }
225         }
226         if ( !get_config_key( hkey, appkey, "PixelShaderMode", buffer, size) )
227         {
228             if (!strcmp(buffer,"enabled"))
229             {
230                 TRACE("Allow pixel shaders\n");
231                 wined3d_settings.ps_mode = PS_HW;
232             }
233             if (!strcmp(buffer,"disabled"))
234             {
235                 TRACE("Disable pixel shaders\n");
236                 wined3d_settings.ps_mode = PS_NONE;
237             }
238         }
239         if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
240         {
241             if (!strcmp(buffer,"disabled"))
242             {
243                 ERR_(winediag)("The GLSL shader backend has been disabled. You get to keep all the pieces if it breaks.\n");
244                 TRACE("Use of GL Shading Language disabled\n");
245                 wined3d_settings.glslRequested = FALSE;
246             }
247         }
248         if ( !get_config_key( hkey, appkey, "OffscreenRenderingMode", buffer, size) )
249         {
250             if (!strcmp(buffer,"backbuffer"))
251             {
252                 TRACE("Using the backbuffer for offscreen rendering\n");
253                 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
254             }
255             else if (!strcmp(buffer,"fbo"))
256             {
257                 TRACE("Using FBOs for offscreen rendering\n");
258                 wined3d_settings.offscreen_rendering_mode = ORM_FBO;
259             }
260         }
261         if ( !get_config_key( hkey, appkey, "RenderTargetLockMode", buffer, size) )
262         {
263             if (!strcmp(buffer,"readdraw"))
264             {
265                 TRACE("Using glReadPixels for render target reading and glDrawPixels for writing\n");
266                 wined3d_settings.rendertargetlock_mode = RTL_READDRAW;
267             }
268             else if (!strcmp(buffer,"readtex"))
269             {
270                 TRACE("Using glReadPixels for render target reading and textures for writing\n");
271                 wined3d_settings.rendertargetlock_mode = RTL_READTEX;
272             }
273         }
274         if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) )
275         {
276             int pci_device_id = tmpvalue;
277 
278             /* A pci device id is 16-bit */
279             if(pci_device_id > 0xffff)
280             {
281                 ERR("Invalid value for VideoPciDeviceID. The value should be smaller or equal to 65535 or 0xffff\n");
282             }
283             else
284             {
285                 TRACE("Using PCI Device ID %04x\n", pci_device_id);
286                 wined3d_settings.pci_device_id = pci_device_id;
287             }
288         }
289         if ( !get_config_key_dword( hkey, appkey, "VideoPciVendorID", &tmpvalue) )
290         {
291             int pci_vendor_id = tmpvalue;
292 
293             /* A pci device id is 16-bit */
294             if(pci_vendor_id > 0xffff)
295             {
296                 ERR("Invalid value for VideoPciVendorID. The value should be smaller or equal to 65535 or 0xffff\n");
297             }
298             else
299             {
300                 TRACE("Using PCI Vendor ID %04x\n", pci_vendor_id);
301                 wined3d_settings.pci_vendor_id = pci_vendor_id;
302             }
303         }
304         if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) )
305         {
306             int TmpVideoMemorySize = atoi(buffer);
307             if(TmpVideoMemorySize > 0)
308             {
309                 wined3d_settings.emulated_textureram = TmpVideoMemorySize *1024*1024;
310                 TRACE("Use %iMB = %d byte for emulated_textureram\n",
311                         TmpVideoMemorySize,
312                         wined3d_settings.emulated_textureram);
313             }
314             else
315                 ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize);
316         }
317         if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) )
318         {
319             size_t len = strlen(buffer) + 1;
320 
321             wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, len);
322             if (!wined3d_settings.logo) ERR("Failed to allocate logo path memory.\n");
323             else memcpy(wined3d_settings.logo, buffer, len);
324         }
325         if ( !get_config_key( hkey, appkey, "Multisampling", buffer, size) )
326         {
327             if (!strcmp(buffer, "disabled"))
328             {
329                 TRACE("Multisampling disabled.\n");
330                 wined3d_settings.allow_multisampling = FALSE;
331             }
332         }
333         if (!get_config_key(hkey, appkey, "StrictDrawOrdering", buffer, size)
334                 && !strcmp(buffer,"enabled"))
335         {
336             TRACE("Enforcing strict draw ordering.\n");
337             wined3d_settings.strict_draw_ordering = TRUE;
338         }
339         if (!get_config_key(hkey, appkey, "AlwaysOffscreen", buffer, size)
340                 && !strcmp(buffer,"enabled"))
341         {
342             TRACE("Always rendering backbuffers offscreen.\n");
343             wined3d_settings.always_offscreen = TRUE;
344         }
345     }
346     if (wined3d_settings.vs_mode == VS_HW)
347         TRACE("Allow HW vertex shaders\n");
348     if (wined3d_settings.ps_mode == PS_NONE)
349         TRACE("Disable pixel shaders\n");
350     if (wined3d_settings.glslRequested)
351         TRACE("If supported by your system, GL Shading Language will be used\n");
352 
353     if (appkey) RegCloseKey( appkey );
354     if (hkey) RegCloseKey( hkey );
355 
356     return TRUE;
357 }
358 
359 static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
360 {
361     DWORD wined3d_context_tls_idx = context_get_tls_idx();
362     unsigned int i;
363 
364     if (!TlsFree(wined3d_context_tls_idx))
365     {
366         DWORD err = GetLastError();
367         ERR("Failed to free context TLS index, err %#x.\n", err);
368     }
369 
370     for (i = 0; i < wndproc_table.count; ++i)
371     {
372         /* Trying to unregister these would be futile. These entries can only
373          * exist if either we skipped them in wined3d_unregister_window() due
374          * to the application replacing the wndproc after the entry was
375          * registered, or if the application still has an active wined3d
376          * device. In the latter case the application has bigger problems than
377          * these entries. */
378         WARN("Leftover wndproc table entry %p.\n", &wndproc_table.entries[i]);
379     }
380     HeapFree(GetProcessHeap(), 0, wndproc_table.entries);
381 
382     HeapFree(GetProcessHeap(), 0, wined3d_settings.logo);
383     UnregisterClassA(WINED3D_OPENGL_WINDOW_CLASS_NAME, hInstDLL);
384 
385     DeleteCriticalSection(&wined3d_wndproc_cs);
386     DeleteCriticalSection(&wined3d_cs);
387     return TRUE;
388 }
389 
390 void WINAPI wined3d_mutex_lock(void)
391 {
392     EnterCriticalSection(&wined3d_cs);
393 }
394 
395 void WINAPI wined3d_mutex_unlock(void)
396 {
397     LeaveCriticalSection(&wined3d_cs);
398 }
399 
400 static void wined3d_wndproc_mutex_lock(void)
401 {
402     EnterCriticalSection(&wined3d_wndproc_cs);
403 }
404 
405 static void wined3d_wndproc_mutex_unlock(void)
406 {
407     LeaveCriticalSection(&wined3d_wndproc_cs);
408 }
409 
410 static struct wined3d_wndproc *wined3d_find_wndproc(HWND window)
411 {
412     unsigned int i;
413 
414     for (i = 0; i < wndproc_table.count; ++i)
415     {
416         if (wndproc_table.entries[i].window == window)
417         {
418             return &wndproc_table.entries[i];
419         }
420     }
421 
422     return NULL;
423 }
424 
425 static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
426 {
427     struct wined3d_wndproc *entry;
428     struct wined3d_device *device;
429     BOOL unicode;
430     WNDPROC proc;
431 
432     wined3d_wndproc_mutex_lock();
433     entry = wined3d_find_wndproc(window);
434 
435     if (!entry)
436     {
437         wined3d_wndproc_mutex_unlock();
438         ERR("Window %p is not registered with wined3d.\n", window);
439         return DefWindowProcW(window, message, wparam, lparam);
440     }
441 
442     device = entry->device;
443     unicode = entry->unicode;
444     proc = entry->proc;
445     wined3d_wndproc_mutex_unlock();
446 
447     if (device)
448         return device_process_message(device, window, unicode, message, wparam, lparam, proc);
449     if (unicode)
450         return CallWindowProcW(proc, window, message, wparam, lparam);
451     return CallWindowProcA(proc, window, message, wparam, lparam);
452 }
453 
454 BOOL wined3d_register_window(HWND window, struct wined3d_device *device)
455 {
456     struct wined3d_wndproc *entry;
457 
458     wined3d_wndproc_mutex_lock();
459 
460     if (wined3d_find_wndproc(window))
461     {
462         wined3d_wndproc_mutex_unlock();
463         WARN("Window %p is already registered with wined3d.\n", window);
464         return TRUE;
465     }
466 
467     if (wndproc_table.size == wndproc_table.count)
468     {
469         unsigned int new_size = max(1, wndproc_table.size * 2);
470         struct wined3d_wndproc *new_entries;
471 
472         if (!wndproc_table.entries) new_entries = HeapAlloc(GetProcessHeap(), 0, new_size * sizeof(*new_entries));
473         else new_entries = HeapReAlloc(GetProcessHeap(), 0, wndproc_table.entries, new_size * sizeof(*new_entries));
474 
475         if (!new_entries)
476         {
477             wined3d_wndproc_mutex_unlock();
478             ERR("Failed to grow table.\n");
479             return FALSE;
480         }
481 
482         wndproc_table.entries = new_entries;
483         wndproc_table.size = new_size;
484     }
485 
486     entry = &wndproc_table.entries[wndproc_table.count++];
487     entry->window = window;
488     entry->unicode = IsWindowUnicode(window);
489     /* Set a window proc that matches the window. Some applications (e.g. NoX)
490      * replace the window proc after we've set ours, and expect to be able to
491      * call the previous one (ours) directly, without using CallWindowProc(). */
492     if (entry->unicode)
493         entry->proc = (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc);
494     else
495         entry->proc = (WNDPROC)SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc);
496     entry->device = device;
497 
498     wined3d_wndproc_mutex_unlock();
499 
500     return TRUE;
501 }
502 
503 void wined3d_unregister_window(HWND window)
504 {
505     struct wined3d_wndproc *entry, *last;
506     LONG_PTR proc;
507 
508     wined3d_wndproc_mutex_lock();
509 
510     if (!(entry = wined3d_find_wndproc(window)))
511     {
512         wined3d_wndproc_mutex_unlock();
513         ERR("Window %p is not registered with wined3d.\n", window);
514         return;
515     }
516 
517     if (entry->unicode)
518     {
519         proc = GetWindowLongPtrW(window, GWLP_WNDPROC);
520         if (proc != (LONG_PTR)wined3d_wndproc)
521         {
522             entry->device = NULL;
523             wined3d_wndproc_mutex_unlock();
524             WARN("Not unregistering window %p, window proc %#lx doesn't match wined3d window proc %p.\n",
525                     window, proc, wined3d_wndproc);
526             return;
527         }
528 
529         SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)entry->proc);
530     }
531     else
532     {
533         proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
534         if (proc != (LONG_PTR)wined3d_wndproc)
535         {
536             entry->device = NULL;
537             wined3d_wndproc_mutex_unlock();
538             WARN("Not unregistering window %p, window proc %#lx doesn't match wined3d window proc %p.\n",
539                     window, proc, wined3d_wndproc);
540             return;
541         }
542 
543         SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)entry->proc);
544     }
545 
546     last = &wndproc_table.entries[--wndproc_table.count];
547     if (entry != last) *entry = *last;
548 
549     wined3d_wndproc_mutex_unlock();
550 }
551 
552 /* At process attach */
553 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
554 {
555     TRACE("WineD3D DLLMain Reason=%u\n", fdwReason);
556 
557     switch (fdwReason)
558     {
559         case DLL_PROCESS_ATTACH:
560             return wined3d_dll_init(hInstDLL);
561 
562         case DLL_PROCESS_DETACH:
563             return wined3d_dll_destroy(hInstDLL);
564 
565         case DLL_THREAD_DETACH:
566         {
567             if (!context_set_current(NULL))
568             {
569                 ERR("Failed to clear current context.\n");
570             }
571             return TRUE;
572         }
573 
574         default:
575             return TRUE;
576     }
577 }
578 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.