Changeset 49214 in vbox
- Timestamp:
- Oct 21, 2013 2:56:51 PM (11 years ago)
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/context.c
r48999 r49214 451 451 #ifdef GLX 452 452 crFreeHashtable(context->pGLXPixmapsHash, crFree); 453 if (context->damageDpy)454 {455 XCloseDisplay(context->damageDpy);456 }457 453 #endif 458 454 … … 553 549 #ifdef GLX 554 550 context->pGLXPixmapsHash = crAllocHashtable(); 555 context->damageInitFailed = GL_FALSE; 556 context->damageDpy = NULL; 551 context->damageQueryFailed = GL_FALSE; 557 552 context->damageEventsBase = 0; 558 553 #endif -
trunk/src/VBox/Additions/common/crOpenGL/glx.c
r43837 r49214 58 58 59 59 static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect); 60 static void stub InitXDamageExtension(ContextInfo *pContext);60 static void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext); 61 61 62 62 static void … … 625 625 context->direct = direct; 626 626 627 /* This means that clients can't hold a server grab during 628 * glXCreateContext! */ 629 stubInitXDamageExtension(context); 627 stubQueryXDamageExtension(dpy, context); 630 628 631 629 return (GLXContext) context->id; … … 1784 1782 { 1785 1783 //crDebug("Destroy: Damage for drawable 0x%x, handle 0x%x", (unsigned int) pixmap, (unsigned int) parms.pGlxPixmap->damage); 1786 XDamageDestroy( parms.pCtx->damageDpy, parms.pGlxPixmap->hDamage);1784 XDamageDestroy(dpy, parms.pGlxPixmap->hDamage); 1787 1785 } 1788 1786 … … 2174 2172 } 2175 2173 2176 void stub InitXDamageExtension(ContextInfo *pContext)2174 void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext) 2177 2175 { 2178 2176 int erb, vma, vmi; … … 2180 2178 CRASSERT(pContext); 2181 2179 2182 if (pContext->damage InitFailed || pContext->damageDpy)2180 if (pContext->damageQueryFailed) 2183 2181 return; 2184 2182 2185 pContext->damageInitFailed = True; 2186 2187 /* Open second xserver connection to make sure we'd receive all the xdamage messages 2188 * and those wouldn't be eaten by application even queue */ 2189 pContext->damageDpy = XOpenDisplay(DisplayString(pContext->dpy)); 2190 2191 if (!pContext->damageDpy) 2192 { 2193 crWarning("XDamage: Can't connect to display %s", DisplayString(pContext->dpy)); 2183 pContext->damageQueryFailed = True; 2184 2185 if (!XDamageQueryExtension(dpy, &pContext->damageEventsBase, &erb) 2186 || !XDamageQueryVersion(dpy, &vma, &vmi)) 2187 { 2188 crWarning("XDamage not found or old version (%i.%i), going to run *very* slow", vma, vmi); 2194 2189 return; 2195 2190 } 2196 2191 2197 if (!XDamageQueryExtension(pContext->damageDpy, &pContext->damageEventsBase, &erb)2198 || !XDamageQueryVersion(pContext->damageDpy, &vma, &vmi))2199 {2200 crWarning("XDamage not found or old version (%i.%i), going to run *very* slow", vma, vmi);2201 XCloseDisplay(pContext->damageDpy);2202 pContext->damageDpy = NULL;2203 return;2204 }2205 2206 2192 crDebug("XDamage %i.%i", vma, vmi); 2207 pContext->damageInitFailed = False; 2208 } 2209 2210 static void stubCheckXDamageCB(unsigned long key, void *data1, void *data2) 2211 { 2212 GLX_Pixmap_t *pGlxPixmap = (GLX_Pixmap_t *) data1; 2213 XDamageNotifyEvent *e = (XDamageNotifyEvent *) data2; 2214 2215 if (pGlxPixmap->hDamage==e->damage) 2216 { 2217 /*crDebug("Event: Damage for pixmap 0x%lx(drawable 0x%x), handle 0x%x (level=%i) [%i,%i,%i,%i]", 2218 key, (unsigned int) e->drawable, (unsigned int) e->damage, (int) e->level, 2219 e->area.x, e->area.y, e->area.width, e->area.height);*/ 2193 pContext->damageQueryFailed = False; 2194 } 2195 2196 static void stubFetchDamageOnDrawable(Display *dpy, GLX_Pixmap_t *pGlxPixmap) 2197 { 2198 Damage damage = pGlxPixmap->hDamage; 2199 2200 if (damage) 2201 { 2202 XRectangle *returnRects; 2203 int nReturnRects; 2204 2205 /* Get the damage region as a server region */ 2206 XserverRegion serverDamageRegion = XFixesCreateRegion (dpy, NULL, 0); 2207 2208 /* Unite damage region with server region and clear damage region */ 2209 XDamageSubtract (dpy, 2210 damage, 2211 None, /* subtract all damage from this region */ 2212 serverDamageRegion /* save in serverDamageRegion */); 2213 2214 /* Fetch damage rectangles */ 2215 returnRects = XFixesFetchRegion (dpy, serverDamageRegion, &nReturnRects); 2216 2217 /* Delete region */ 2218 XFixesDestroyRegion (dpy, serverDamageRegion); 2220 2219 2221 2220 if (pGlxPixmap->pDamageRegion) … … 2224 2223 if (!pGlxPixmap->bPixmapImageDirty || !XEmptyRegion(pGlxPixmap->pDamageRegion)) 2225 2224 { 2226 if (CR_MAX_DAMAGE_REGIONS_TRACKED <= pGlxPixmap->pDamageRegion->numRects) 2225 int i = 0; 2226 for (; i < nReturnRects; ++i) 2227 2227 { 2228 /* Mark for full update */ 2229 EMPTY_REGION(pGlxPixmap->pDamageRegion); 2230 } 2231 else 2232 { 2233 /* Add to damage regions */ 2234 XUnionRectWithRegion(&e->area, pGlxPixmap->pDamageRegion, pGlxPixmap->pDamageRegion); 2228 if (CR_MAX_DAMAGE_REGIONS_TRACKED <= pGlxPixmap->pDamageRegion->numRects) 2229 { 2230 /* Mark for full update */ 2231 EMPTY_REGION(pGlxPixmap->pDamageRegion); 2232 } 2233 else 2234 { 2235 /* Add to damage regions */ 2236 XUnionRectWithRegion(&returnRects[i], pGlxPixmap->pDamageRegion, pGlxPixmap->pDamageRegion); 2237 } 2235 2238 } 2236 2239 } 2237 2240 } 2241 2242 XFree(returnRects); 2238 2243 2239 2244 pGlxPixmap->bPixmapImageDirty = True; … … 2340 2345 2341 2346 /* If there's damage extension, then get handle for damage events related to this pixmap */ 2342 if ( pContext->damageDpy)2343 { 2344 pGlxPixmap->hDamage = XDamageCreate( pContext->damageDpy, (Pixmap)draw, XDamageReportRawRectangles);2347 if (!pContext->damageQueryFailed) 2348 { 2349 pGlxPixmap->hDamage = XDamageCreate(dpy, (Pixmap)draw, XDamageReportNonEmpty); 2345 2350 /*crDebug("Create: Damage for drawable 0x%x, handle 0x%x (level=%i)", 2346 2351 (unsigned int) draw, (unsigned int) pGlxPixmap->damage, (int) XDamageReportRawRectangles);*/ … … 2534 2539 2535 2540 /* If there's damage extension, then process incoming events as we need the information right now */ 2536 if (context->damageDpy) 2537 { 2538 /* Sync connections, note that order of syncs is important here. 2539 * First make sure client commands are finished, then make sure we get all the damage events back*/ 2541 if (!context->damageQueryFailed) 2542 { 2543 /* Sync connection */ 2540 2544 XLOCK(dpy); 2541 2545 XSync(dpy, False); 2542 2546 XUNLOCK(dpy); 2543 XSync(context->damageDpy, False); 2544 2545 while (XPending(context->damageDpy)) 2546 { 2547 XEvent event; 2548 XNextEvent(context->damageDpy, &event); 2549 if (event.type==context->damageEventsBase+XDamageNotify) 2550 { 2551 crHashtableWalk(context->pGLXPixmapsHash, stubCheckXDamageCB, &event); 2552 } 2553 } 2547 2548 stubFetchDamageOnDrawable(dpy, pGlxPixmap); 2554 2549 } 2555 2550 … … 2599 2594 { 2600 2595 /* Check if we have damage extension */ 2601 if ( context->damageDpy)2596 if (!context->damageQueryFailed) 2602 2597 { 2603 2598 if (pGlxPixmap->bPixmapImageDirty) -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r49005 r49214 147 147 GLXContext glxContext; 148 148 CRHashTable *pGLXPixmapsHash; 149 Bool damageInitFailed; 150 Display *damageDpy; /* second display connection to read xdamage extension data */ 149 Bool damageQueryFailed; 151 150 int damageEventsBase; 152 151 #endif
Note:
See TracChangeset
for help on using the changeset viewer.