Changeset 39602 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.c
- Timestamp:
- Dec 14, 2011 11:12:17 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vboxext.c
r39257 r39602 15 15 */ 16 16 #include "config.h" 17 #include "wine/port.h" 17 18 #include "wined3d_private.h" 18 19 #include "vboxext.h" … … 23 24 typedef FNVBOXEXTWORKERCB *PFNVBOXEXTWORKERCB; 24 25 25 HRESULT VBoxExtDwSubmitProc(PFNVBOXEXTWORKERCB pfnCb, void *pvCb); 26 HRESULT VBoxExtDwSubmitProcSync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb); 27 HRESULT VBoxExtDwSubmitProcAsync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb); 26 28 27 29 /*******************************/ 28 #if defined(VBOX_WDDM_WOW64) 30 #ifdef VBOX_WITH_WDDM 31 # if defined(VBOX_WDDM_WOW64) 29 32 # define VBOXEXT_WINE_MODULE_NAME "wined3dwddm-x86.dll" 33 # else 34 # define VBOXEXT_WINE_MODULE_NAME "wined3dwddm.dll" 35 # endif 30 36 #else 31 # define VBOXEXT_WINE_MODULE_NAME "wined3dwddm.dll" 37 /* both 32bit and 64bit versions of xpdm wine libs are named identically */ 38 # define VBOXEXT_WINE_MODULE_NAME "wined3d.dll" 32 39 #endif 33 40 … … 61 68 static VBOXEXT_GLOBAL g_VBoxExtGlobal; 62 69 63 #define WM_VBOXEXT_CALLPROC (WM_APP+1) 70 #define WM_VBOXEXT_CALLPROC (WM_APP+1) 71 #define WM_VBOXEXT_INIT_QUIT (WM_APP+2) 64 72 65 73 typedef struct VBOXEXT_CALLPROC … … 103 111 pData->pfnCb(pData->pvCb); 104 112 SetEvent(pWorker->hEvent); 113 break; 114 } 115 case WM_VBOXEXT_INIT_QUIT: 116 case WM_CLOSE: 117 { 118 PostQuitMessage(0); 105 119 break; 106 120 } … … 165 179 HRESULT VBoxExtWorkerDestroy(PVBOXEXT_WORKER pWorker) 166 180 { 167 BOOL bResult = PostThreadMessage(pWorker->idThread, WM_ QUIT, 0, 0);181 BOOL bResult = PostThreadMessage(pWorker->idThread, WM_VBOXEXT_INIT_QUIT, 0, 0); 168 182 DWORD dwErr; 169 183 if (!bResult) … … 191 205 } 192 206 193 static HRESULT vboxExtWorkerSubmit(VBOXEXT_WORKER *pWorker, UINT Msg, LPARAM lParam )207 static HRESULT vboxExtWorkerSubmit(VBOXEXT_WORKER *pWorker, UINT Msg, LPARAM lParam, BOOL fSync) 194 208 { 195 209 HRESULT hr = E_FAIL; … … 201 215 if (bResult) 202 216 { 203 DWORD dwErr = WaitForSingleObject(pWorker->hEvent, INFINITE); 204 if (dwErr == WAIT_OBJECT_0) 205 { 217 if (fSync) 218 { 219 DWORD dwErr = WaitForSingleObject(pWorker->hEvent, INFINITE); 220 if (dwErr == WAIT_OBJECT_0) 221 { 222 hr = S_OK; 223 } 224 else 225 { 226 ERR("WaitForSingleObject returned (%d)", dwErr); 227 } 228 } 229 else 206 230 hr = S_OK; 207 }208 else209 {210 ERR("WaitForSingleObject returned (%d)", dwErr);211 }212 231 } 213 232 else … … 221 240 } 222 241 223 HRESULT VBoxExtWorkerSubmitProc (PVBOXEXT_WORKER pWorker, PFNVBOXEXTWORKERCB pfnCb, void *pvCb)242 HRESULT VBoxExtWorkerSubmitProcSync(PVBOXEXT_WORKER pWorker, PFNVBOXEXTWORKERCB pfnCb, void *pvCb) 224 243 { 225 244 VBOXEXT_CALLPROC Ctx; 226 245 Ctx.pfnCb = pfnCb; 227 246 Ctx.pvCb = pvCb; 228 return vboxExtWorkerSubmit(pWorker, WM_VBOXEXT_CALLPROC, (LPARAM)&Ctx); 229 } 247 return vboxExtWorkerSubmit(pWorker, WM_VBOXEXT_CALLPROC, (LPARAM)&Ctx, TRUE); 248 } 249 250 static DECLCALLBACK(void) vboxExtWorkerSubmitProcAsyncWorker(void *pvUser) 251 { 252 PVBOXEXT_CALLPROC pCallInfo = (PVBOXEXT_CALLPROC)pvUser; 253 pCallInfo[1].pfnCb(pCallInfo[1].pvCb); 254 HeapFree(GetProcessHeap(), 0, pCallInfo); 255 } 256 257 HRESULT VBoxExtWorkerSubmitProcAsync(PVBOXEXT_WORKER pWorker, PFNVBOXEXTWORKERCB pfnCb, void *pvCb) 258 { 259 HRESULT hr; 260 PVBOXEXT_CALLPROC pCallInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (VBOXEXT_CALLPROC) * 2); 261 if (!pCallInfo) 262 { 263 ERR("HeapAlloc failed\n"); 264 return E_OUTOFMEMORY; 265 } 266 pCallInfo[0].pfnCb = vboxExtWorkerSubmitProcAsyncWorker; 267 pCallInfo[0].pvCb = pCallInfo; 268 pCallInfo[1].pfnCb = pfnCb; 269 pCallInfo[1].pvCb = pvCb; 270 hr = vboxExtWorkerSubmit(pWorker, WM_VBOXEXT_CALLPROC, (LPARAM)pCallInfo, FALSE); 271 if (FAILED(hr)) 272 { 273 ERR("vboxExtWorkerSubmit failed, hr 0x%x\n", hr); 274 HeapFree(GetProcessHeap(), 0, pCallInfo); 275 return hr; 276 } 277 return S_OK; 278 } 279 230 280 231 281 static HRESULT vboxExtInit() … … 295 345 } 296 346 297 HRESULT VBoxExtDwSubmitProc(PFNVBOXEXTWORKERCB pfnCb, void *pvCb) 298 { 299 return VBoxExtWorkerSubmitProc(&g_VBoxExtGlobal.Worker, pfnCb, pvCb); 300 } 301 347 HRESULT VBoxExtDwSubmitProcSync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb) 348 { 349 return VBoxExtWorkerSubmitProcSync(&g_VBoxExtGlobal.Worker, pfnCb, pvCb); 350 } 351 352 HRESULT VBoxExtDwSubmitProcAsync(PFNVBOXEXTWORKERCB pfnCb, void *pvCb) 353 { 354 return VBoxExtWorkerSubmitProcAsync(&g_VBoxExtGlobal.Worker, pfnCb, pvCb); 355 } 356 357 #if defined(VBOX_WINE_WITH_SINGLE_CONTEXT) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT) 358 # ifndef VBOX_WITH_WDDM 302 359 typedef struct VBOXEXT_GETDC_CB 303 360 { … … 324 381 pData->ret = ReleaseDC(pData->hWnd, pData->hDC); 325 382 } 326 #if 0 383 327 384 HDC VBoxExtGetDC(HWND hWnd) 328 385 { 329 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT330 386 HRESULT hr; 331 387 VBOXEXT_GETDC_CB Data = {0}; … … 333 389 Data.hDC = NULL; 334 390 335 hr = VBoxExtDwSubmitProc (vboxExtGetDCWorker, &Data);391 hr = VBoxExtDwSubmitProcSync(vboxExtGetDCWorker, &Data); 336 392 if (FAILED(hr)) 337 393 { 338 ERR("VBoxExtDwSubmitProc feiled, hr (0x%x)\n", hr);394 ERR("VBoxExtDwSubmitProcSync feiled, hr (0x%x)\n", hr); 339 395 return NULL; 340 396 } 341 397 342 398 return Data.hDC; 343 #else344 return GetDC(hWnd);345 #endif346 399 } 347 400 348 401 int VBoxExtReleaseDC(HWND hWnd, HDC hDC) 349 402 { 350 #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT351 403 HRESULT hr; 352 404 VBOXEXT_RELEASEDC_CB Data = {0}; … … 355 407 Data.ret = 0; 356 408 357 hr = VBoxExtDwSubmitProc (vboxExtReleaseDCWorker, &Data);409 hr = VBoxExtDwSubmitProcSync(vboxExtReleaseDCWorker, &Data); 358 410 if (FAILED(hr)) 359 411 { 360 ERR("VBoxExtDwSubmitProc feiled, hr (0x%x)\n", hr);412 ERR("VBoxExtDwSubmitProcSync feiled, hr (0x%x)\n", hr); 361 413 return -1; 362 414 } 363 415 364 416 return Data.ret; 365 #else 366 return ReleaseDC(hWnd, hDC); 367 #endif 368 } 369 #endif 417 } 418 # endif /* #ifndef VBOX_WITH_WDDM */ 419 420 static DECLCALLBACK(void) vboxExtReleaseContextWorker(void *pvUser) 421 { 422 struct wined3d_context *context = (struct wined3d_context *)pvUser; 423 wined3d_mutex_lock(); 424 VBoxTlsRefRelease(context); 425 wined3d_mutex_unlock(); 426 } 427 428 void VBoxExtReleaseContextAsync(struct wined3d_context *context) 429 { 430 HRESULT hr; 431 432 hr = VBoxExtDwSubmitProcAsync(vboxExtReleaseContextWorker, context); 433 if (FAILED(hr)) 434 { 435 ERR("VBoxExtDwSubmitProcAsync feiled, hr (0x%x)\n", hr); 436 return; 437 } 438 } 439 440 #endif /* #if defined(VBOX_WINE_WITH_SINGLE_CONTEXT) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT) */ 370 441 371 442 /* window creation API */ … … 507 578 Info.hWnd = hWnd; 508 579 Info.hDC = hDC; 509 hr = VBoxExtDwSubmitProc (vboxExtWndDestroyWorker, &Info);580 hr = VBoxExtDwSubmitProcSync(vboxExtWndDestroyWorker, &Info); 510 581 Assert(hr == S_OK); 511 582 if (hr == S_OK) … … 524 595 Info.width = width; 525 596 Info.height = height; 526 hr = VBoxExtDwSubmitProc (vboxExtWndCreateWorker, &Info);597 hr = VBoxExtDwSubmitProcSync(vboxExtWndCreateWorker, &Info); 527 598 Assert(hr == S_OK); 528 599 if (hr == S_OK)
Note:
See TracChangeset
for help on using the changeset viewer.