Changeset 26909 in vbox for trunk/src/VBox/Additions/common/crOpenGL
- Timestamp:
- Mar 1, 2010 1:20:27 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 58193
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/context.c
r26545 r26909 220 220 winInfo->spuWindow = -1; 221 221 winInfo->mapped = -1; /* don't know */ 222 winInfo->pOwner = NULL; 222 223 #ifndef WINDOWS 223 224 crHashtableAdd(stub.windowTable, (unsigned int) drawable, winInfo); … … 271 272 context->visBits = visBits; 272 273 context->currentDrawable = NULL; 273 context->pOwnWindow = NULL;274 274 crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME); 275 275 context->dpyName[MAX_DPY_NAME-1] = 0; … … 790 790 } 791 791 792 static void stub CtxCheckCurrentDrawableCB(unsigned long key, void *data1, void *data2)793 { 794 ContextInfo *pCtx = (ContextInfo *) data1;795 C txCheckCurrentDrawableParams_t *pParams = (CtxCheckCurrentDrawableParams_t*) data2;796 797 if (p Ctx->currentDrawable == pParams->window)792 static void stubWindowCheckOwnerCB(unsigned long key, void *data1, void *data2) 793 { 794 WindowInfo *pWindow = (WindowInfo *) data1; 795 ContextInfo *pCtx = (ContextInfo *) data2; 796 797 if (pWindow->pOwner == pCtx) 798 798 { 799 pParams->windowInUse = GL_TRUE; 799 #ifdef WINDOWS 800 /* Note: can't use WindowFromDC(context->pOwnWindow->drawable) here 801 because GL context is already released from DC and actual guest window 802 could be destroyed. 803 */ 804 crWindowDestroy((GLint)pWindow->hWnd); 805 #else 806 crWindowDestroy((GLint)pWindow->drawable); 807 #endif 800 808 } 801 809 } … … 851 859 /*crDebug("(1)stubMakeCurrent ctx=%p(%i) window=%p(%i)", context, context->spuContext, window, window->spuWindow);*/ 852 860 window->spuWindow = stub.spu->dispatch_table.WindowCreate( window->dpyName, context->visBits ); 853 CRASSERT(!context->pOwnWindow);854 context->pOwnWindow = window;855 861 } 856 862 } … … 896 902 CRASSERT(context->spuContext >= 0); 897 903 898 if (context->currentDrawable && context->currentDrawable != window)899 cr Warning("Rebinding context %p to a different window", context);904 /*if (context->currentDrawable && context->currentDrawable != window) 905 crDebug("Rebinding context %p to a different window", context);*/ 900 906 901 907 if (window->type == NATIVE) { … … 908 914 /*crDebug("(2)stubMakeCurrent ctx=%p(%i) window=%p(%i)", context, context->spuContext, window, window->spuWindow);*/ 909 915 window->spuWindow = stub.spu->dispatch_table.WindowCreate( window->dpyName, context->visBits ); 910 if (context->pOwnWindow) 916 if (context->currentDrawable && context->currentDrawable->type==CHROMIUM 917 && context->currentDrawable->pOwner==context) 911 918 { 912 WindowInfo *pOwnWindow = context->pOwnWindow;913 CtxCheckCurrentDrawableParams_t params;914 915 context->pOwnWindow = NULL;916 context->currentDrawable=NULL;917 918 params.window = pOwnWindow;919 params.windowInUse = GL_FALSE;920 921 crHashtableWalk(stub.contextTable, stubCtxCheckCurrentDrawableCB, ¶ms);922 923 if (!params.windowInUse)924 {925 919 #ifdef WINDOWS 926 crWindowDestroy((GLint)pOwnWindow->hWnd); 920 if (!WindowFromDC(context->currentDrawable->drawable)) 921 { 922 crWindowDestroy((GLint)context->currentDrawable->hWnd); 923 } 927 924 #else 928 crWindowDestroy((GLint)pOwnWindow->drawable); 929 #endif 930 } 925 Window root; 926 int x, y; 927 unsigned int border, depth, w, h; 928 929 if (!XGetGeometry(context->currentDrawable->dpy, context->currentDrawable->drawable, &root, &x, &y, &w, &h, &border, &depth)) 930 { 931 crWindowDestroy((GLint)context->currentDrawable->drawable); 932 } 933 #endif 934 931 935 } 932 context->pOwnWindow = window;933 936 } 934 937 … … 943 946 944 947 window->type = context->type; 948 window->pOwner = context; 945 949 context->currentDrawable = window; 946 950 stub.currentContext = context; … … 1002 1006 } 1003 1007 1004 1005 1006 1008 void 1007 1009 stubDestroyContext( unsigned long contextId ) … … 1029 1031 CRASSERT(context->spuContext >= 0); 1030 1032 stub.spu->dispatch_table.DestroyContext( context->spuContext ); 1031 if (context->pOwnWindow) 1032 { 1033 /* Note: can't use WindowFromDC(context->pOwnWindow->drawable) here 1034 because GL context is already released from DC and actual guest window 1035 could be destroyed. 1036 */ 1037 #ifdef WINDOWS 1038 crWindowDestroy((GLint)context->pOwnWindow->hWnd); 1039 #else 1040 crWindowDestroy((GLint)context->pOwnWindow->drawable); 1041 #endif 1042 } 1033 crHashtableWalk(stub.windowTable, stubWindowCheckOwnerCB, context); 1043 1034 } 1044 1035 -
trunk/src/VBox/Additions/common/crOpenGL/load.c
r26117 r26909 80 80 static ScissorFunc_t origScissor; 81 81 82 static void stubCheckWindowState(void) 83 { 84 WindowInfo *window; 82 static void stubCheckWindowState(WindowInfo *window) 83 { 85 84 bool bForceUpdate = false; 86 87 CRASSERT(stub.trackWindowSize || stub.trackWindowPos);88 89 if (!stub.currentContext)90 return;91 92 window = stub.currentContext->currentDrawable;93 85 94 86 #ifdef WINDOWS … … 129 121 } 130 122 123 static bool stubSystemWindowExist(WindowInfo *pWindow) 124 { 125 #ifdef WINDOWS 126 if (!WindowFromDC(pWindow->drawable)) 127 { 128 return false; 129 } 130 #else 131 Window root; 132 int x, y; 133 unsigned int border, depth, w, h; 134 135 if (!XGetGeometry(pWindow->dpy, pWindow->drawable, &root, &x, &y, &w, &h, &border, &depth)) 136 { 137 return false; 138 } 139 #endif 140 141 return true; 142 } 143 144 static void stubCheckWindowsCB(unsigned long key, void *data1, void *data2) 145 { 146 WindowInfo *pWindow = (WindowInfo *) data1; 147 ContextInfo *pCtx = (ContextInfo *) data2; 148 149 if (pWindow == pCtx->currentDrawable 150 || pWindow->type!=CHROMIUM 151 || pWindow->pOwner!=pCtx) 152 { 153 return; 154 } 155 156 if (!stubSystemWindowExist(pWindow)) 157 { 158 #ifdef WINDOWS 159 crWindowDestroy((GLint)pWindow->hWnd); 160 #else 161 crWindowDestroy((GLint)pWindow->drawable); 162 #endif 163 return; 164 } 165 166 stubCheckWindowState(pWindow); 167 } 168 169 static void stubCheckWindowsState(void) 170 { 171 CRASSERT(stub.trackWindowSize || stub.trackWindowPos); 172 173 if (!stub.currentContext) 174 return; 175 176 stubCheckWindowState(stub.currentContext->currentDrawable); 177 178 crHashtableWalk(stub.windowTable, stubCheckWindowsCB, stub.currentContext); 179 } 180 131 181 132 182 /** … … 137 187 static void SPU_APIENTRY trapClear(GLbitfield mask) 138 188 { 139 stubCheckWindow State();189 stubCheckWindowsState(); 140 190 /* call the original SPU glClear function */ 141 191 origClear(mask); … … 148 198 static void SPU_APIENTRY trapViewport(GLint x, GLint y, GLsizei w, GLsizei h) 149 199 { 150 stubCheckWindow State();200 stubCheckWindowsState(); 151 201 /* call the original SPU glViewport function */ 152 202 if (!stub.viewportHack) … … 167 217 static void SPU_APIENTRY trapSwapBuffers(GLint window, GLint flags) 168 218 { 169 stubCheckWindow State();219 stubCheckWindowsState(); 170 220 origSwapBuffers(window, flags); 171 221 } … … 173 223 static void SPU_APIENTRY trapDrawBuffer(GLenum buf) 174 224 { 175 stubCheckWindow State();225 stubCheckWindowsState(); 176 226 origDrawBuffer(buf); 177 227 } -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r25383 r26909 92 92 GLint visBits; 93 93 WindowInfo *currentDrawable; 94 WindowInfo *pOwnWindow; /* window created by first call to MakeCurrent with this context */ 94 95 95 #ifdef WINDOWS 96 96 HGLRC hglrc; … … 137 137 ContextType type; 138 138 GLint spuWindow; /* returned by head SPU's WindowCreate() */ 139 ContextInfo *pOwner; /* ctx which created this window */ 139 140 GLboolean mapped; 140 141 #ifdef WINDOWS
Note:
See TracChangeset
for help on using the changeset viewer.