Changeset 44860 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
- Timestamp:
- Feb 28, 2013 10:48:15 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r44813 r44860 80 80 } 81 81 82 GLboolean renderspuInitVisual(VisualInfo *pVisInfo, const char *displayName, GLbitfield visAttribs) 83 { 84 pVisInfo->displayName = crStrdup(displayName); 85 pVisInfo->visAttribs = visAttribs; 86 return renderspu_SystemInitVisual(pVisInfo); 87 } 82 88 83 89 /* … … 117 123 /* create a new visual */ 118 124 i = render_spu.numVisuals; 119 render_spu.visuals[i].displayName = crStrdup(displayName); 120 render_spu.visuals[i].visAttribs = visAttribs; 121 if (renderspu_SystemInitVisual(&(render_spu.visuals[i]))) { 125 if (renderspuInitVisual(&(render_spu.visuals[i]), displayName, visAttribs)) { 122 126 render_spu.numVisuals++; 123 127 return &(render_spu.visuals[i]); … … 315 319 } 316 320 317 318 /* 319 * Window functions 320 */ 321 322 GLint renderspuWindowCreateEx( const char *dpyName, GLint visBits, GLint id ) 323 { 324 WindowInfo *window; 325 VisualInfo *visual; 326 GLboolean showIt; 327 328 if (id <= 0) 329 { 330 id = (GLint)crHashtableAllocKeys(render_spu.windowTable, 1); 331 if (id <= 0) 332 { 333 crWarning("failed to allocate window id"); 334 return -1; 335 } 336 } 337 else 338 { 339 if (crHashtableIsKeyUsed(render_spu.windowTable, id)) 340 { 341 crWarning("the specified window key %d is in use", id); 342 return -1; 343 } 344 } 345 346 347 if (!dpyName || crStrlen(render_spu.display_string) > 0) 348 dpyName = render_spu.display_string; 349 350 visual = renderspuFindVisual( dpyName, visBits ); 351 if (!visual) 352 { 353 crWarning( "Render SPU: Couldn't create a window, renderspuFindVisual returned NULL" ); 354 return -1; 355 } 356 357 /* Allocate WindowInfo */ 358 window = (WindowInfo *) crCalloc(sizeof(WindowInfo)); 359 if (!window) 360 { 361 crWarning( "Render SPU: Couldn't create a window" ); 362 return -1; 363 } 364 321 GLboolean renderspuWindowInit( WindowInfo *window, VisualInfo *visual, GLboolean showIt, GLint id ) 322 { 365 323 RTCritSectInit(&window->CompositorLock); 366 324 window->pCompositor = NULL; 367 325 368 crHashtableAdd(render_spu.windowTable, id, window);369 326 window->BltInfo.Base.id = id; 370 327 … … 373 330 window->BltInfo.width = render_spu.defaultWidth; 374 331 window->BltInfo.height = render_spu.defaultHeight; 375 376 if (render_spu.force_hidden_wdn_create377 || ((render_spu.render_to_app_window || render_spu.render_to_crut_window) && !crGetenv("CRNEWSERVER")))378 showIt = 0;379 else380 showIt = window->BltInfo.Base.id != CR_RENDER_DEFAULT_WINDOW_ID;381 332 382 333 /* Set window->title, replacing %i with the window ID number */ … … 399 350 } 400 351 } 401 352 353 window->BltInfo.Base.visualBits = visual->visAttribs; 354 355 402 356 /* 403 357 crDebug("Render SPU: Creating window (visBits=0x%x, id=%d)", visBits, window->BltInfo.Base.id); … … 406 360 if (!renderspu_SystemVBoxCreateWindow( visual, showIt, window )) 407 361 { 362 crWarning( "Render SPU: Couldn't create a window, renderspu_SystemCreateWindow failed" ); 363 return GL_FALSE; 364 } 365 366 CRASSERT(window->visual == visual); 367 return GL_TRUE; 368 } 369 370 /* 371 * Window functions 372 */ 373 374 GLint renderspuWindowCreateEx( const char *dpyName, GLint visBits, GLint id ) 375 { 376 WindowInfo *window; 377 VisualInfo *visual; 378 GLboolean showIt; 379 380 if (id <= 0) 381 { 382 id = (GLint)crHashtableAllocKeys(render_spu.windowTable, 1); 383 if (id <= 0) 384 { 385 crWarning("failed to allocate window id"); 386 return -1; 387 } 388 } 389 else 390 { 391 if (crHashtableIsKeyUsed(render_spu.windowTable, id)) 392 { 393 crWarning("the specified window key %d is in use", id); 394 return -1; 395 } 396 } 397 398 399 if (!dpyName || crStrlen(render_spu.display_string) > 0) 400 dpyName = render_spu.display_string; 401 402 visual = renderspuFindVisual( dpyName, visBits ); 403 if (!visual) 404 { 405 crWarning( "Render SPU: Couldn't create a window, renderspuFindVisual returned NULL" ); 406 return -1; 407 } 408 409 /* Allocate WindowInfo */ 410 window = (WindowInfo *) crCalloc(sizeof(WindowInfo)); 411 if (!window) 412 { 413 crWarning( "Render SPU: Couldn't create a window" ); 414 return -1; 415 } 416 417 crHashtableAdd(render_spu.windowTable, id, window); 418 419 if (render_spu.force_hidden_wdn_create 420 || ((render_spu.render_to_app_window || render_spu.render_to_crut_window) && !crGetenv("CRNEWSERVER"))) 421 showIt = 0; 422 else 423 showIt = window->BltInfo.Base.id != CR_RENDER_DEFAULT_WINDOW_ID; 424 425 426 /* 427 crDebug("Render SPU: Creating window (visBits=0x%x, id=%d)", visBits, window->BltInfo.Base.id); 428 */ 429 /* Have GLX/WGL/AGL create the window */ 430 if (!renderspuWindowInit( window, visual, showIt, id )) 431 { 408 432 crFree(window); 409 433 crWarning( "Render SPU: Couldn't create a window, renderspu_SystemCreateWindow failed" ); 410 434 return -1; 411 435 } 412 413 CRASSERT(window->visual == visual); 414 415 window->BltInfo.Base.visualBits = visual->visAttribs; 416 436 417 437 return window->BltInfo.Base.id; 418 438 } … … 437 457 } 438 458 459 void renderspuWindowTerm( WindowInfo *window ) 460 { 461 GET_CONTEXT(pOldCtx); 462 /* ensure no concurrent draws can take place */ 463 renderspuVBoxCompositorSet(window, NULL); 464 renderspu_SystemDestroyWindow( window ); 465 RTCritSectDelete(&window->CompositorLock); 466 /* check if this window is bound to some ctx. Note: window pointer is already freed here */ 467 crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window); 468 /* restore current context */ 469 { 470 GET_CONTEXT(pNewCtx); 471 if (pNewCtx!=pOldCtx) 472 { 473 renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id:CR_RENDER_DEFAULT_WINDOW_ID, 0, 474 pOldCtx ? pOldCtx->BltInfo.Base.id:CR_RENDER_DEFAULT_CONTEXT_ID); 475 } 476 } 477 } 478 439 479 void 440 480 RENDER_APIENTRY renderspuWindowDestroy( GLint win ) 441 481 { 442 482 WindowInfo *window; 443 GET_CONTEXT(pOldCtx);444 483 445 484 CRASSERT(win >= 0); … … 452 491 if (window) { 453 492 crDebug("Render SPU: Destroy window (%d)", win); 454 renderspu_SystemDestroyWindow( window ); 455 456 RTCritSectDelete(&window->CompositorLock); 457 window->pCompositor = NULL; 493 renderspuWindowTerm( window ); 458 494 459 495 /* remove window info from hash table, and free it */ 460 496 crHashtableDelete(render_spu.windowTable, win, crFree); 461 497 462 /* check if this window is bound to some ctx. Note: window pointer is already freed here */463 crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window);464 465 /* restore current context */466 {467 GET_CONTEXT(pNewCtx);468 if (pNewCtx!=pOldCtx)469 {470 renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id:CR_RENDER_DEFAULT_WINDOW_ID, 0,471 pOldCtx ? pOldCtx->BltInfo.Base.id:CR_RENDER_DEFAULT_CONTEXT_ID);472 }473 }474 498 } 475 499 else {
Note:
See TracChangeset
for help on using the changeset viewer.