Ticket #11503: Remove-the-second-damage-display-connection-and-inst-adjusted-1.patch
| File Remove-the-second-damage-display-connection-and-inst-adjusted-1.patch, 8.4 KB (added by , 12 years ago) |
|---|
-
src/VBox/Additions/common/crOpenGL/glx.c
57 57 static struct VisualInfo *VisualInfoList = NULL; 58 58 59 59 static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect); 60 static void stubInitXDamageExtension( ContextInfo *pContext);60 static void stubInitXDamageExtension(Display *dpy, ContextInfo *pContext); 61 61 62 62 static void 63 63 AddVisualInfo(Display *dpy, int screen, VisualID visualid, int visBits) … … 626 626 627 627 /* This means that clients can't hold a server grab during 628 628 * glXCreateContext! */ 629 stubInitXDamageExtension( context);629 stubInitXDamageExtension(dpy, context); 630 630 631 631 return (GLXContext) context->id; 632 632 } … … 1783 1783 if (parms.pGlxPixmap->hDamage>0) 1784 1784 { 1785 1785 //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);1786 XDamageDestroy(dpy, parms.pGlxPixmap->hDamage); 1787 1787 } 1788 1788 1789 1789 if (parms.pGlxPixmap->pDamageRegion) … … 2173 2173 #endif 2174 2174 } 2175 2175 2176 void stubInitXDamageExtension( ContextInfo *pContext)2176 void stubInitXDamageExtension(Display *dpy, ContextInfo *pContext) 2177 2177 { 2178 2178 int erb, vma, vmi; 2179 2179 2180 2180 CRASSERT(pContext); 2181 2181 2182 if (pContext->damageInitFailed || pContext->damageDpy)2182 if (pContext->damageInitFailed) 2183 2183 return; 2184 2184 2185 2185 pContext->damageInitFailed = True; 2186 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) 2187 if (!XDamageQueryExtension(dpy, &pContext->damageEventsBase, &erb) 2188 || !XDamageQueryVersion(dpy, &vma, &vmi)) 2192 2189 { 2193 crWarning("XDamage: Can't connect to display %s", DisplayString(pContext->dpy));2194 return;2195 }2196 2197 if (!XDamageQueryExtension(pContext->damageDpy, &pContext->damageEventsBase, &erb)2198 || !XDamageQueryVersion(pContext->damageDpy, &vma, &vmi))2199 {2200 2190 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 2191 return; 2204 2192 } 2205 2193 … … 2207 2195 pContext->damageInitFailed = False; 2208 2196 } 2209 2197 2210 static void stub CheckXDamageCB(unsigned long key, void *data1, void *data2)2198 static void stubFetchDamageOnDrawable(Display *dpy, GLX_Pixmap_t *pGlxPixmap) 2211 2199 { 2212 GLX_Pixmap_t *pGlxPixmap = (GLX_Pixmap_t *) data1; 2213 XDamageNotifyEvent *e = (XDamageNotifyEvent *) data2; 2200 Damage damage = pGlxPixmap->hDamage; 2214 2201 2215 if ( pGlxPixmap->hDamage==e->damage)2202 if (damage) 2216 2203 { 2204 XRectangle *returnRects; 2205 int nReturnRects; 2217 2206 /*crDebug("Event: Damage for pixmap 0x%lx(drawable 0x%x), handle 0x%x (level=%i) [%i,%i,%i,%i]", 2218 2207 key, (unsigned int) e->drawable, (unsigned int) e->damage, (int) e->level, 2219 2208 e->area.x, e->area.y, e->area.width, e->area.height);*/ 2220 2209 2210 /* Get the damage region as a server region */ 2211 XserverRegion serverDamageRegion = XFixesCreateRegion (dpy, NULL, 0); 2212 2213 /* Unite damage region with server region and clear damage region */ 2214 XDamageSubtract (dpy, 2215 damage, 2216 None, /* subtract all damage from this region */ 2217 serverDamageRegion /* save in serverDamageRegion */); 2218 2219 /* Fetch damage rectangles */ 2220 returnRects = XFixesFetchRegion (dpy, serverDamageRegion, &nReturnRects); 2221 2222 /* Delete region */ 2223 XFixesDestroyRegion (dpy, serverDamageRegion); 2224 2221 2225 if (pGlxPixmap->pDamageRegion) 2222 2226 { 2223 2227 /* If it's dirty and regions are empty, it marked for full update, so do nothing.*/ 2224 2228 if (!pGlxPixmap->bPixmapImageDirty || !XEmptyRegion(pGlxPixmap->pDamageRegion)) 2225 2229 { 2226 if (CR_MAX_DAMAGE_REGIONS_TRACKED <= pGlxPixmap->pDamageRegion->numRects) 2230 int i = 0; 2231 for (; i < nReturnRects; ++i) 2227 2232 { 2228 /* Mark for full update */ 2229 EMPTY_REGION(pGlxPixmap->pDamageRegion); 2233 if (CR_MAX_DAMAGE_REGIONS_TRACKED <= pGlxPixmap->pDamageRegion->numRects) 2234 { 2235 /* Mark for full update */ 2236 EMPTY_REGION(pGlxPixmap->pDamageRegion); 2237 } 2238 else 2239 { 2240 /* Add to damage regions */ 2241 XUnionRectWithRegion(&returnRects[i], pGlxPixmap->pDamageRegion, pGlxPixmap->pDamageRegion); 2242 } 2230 2243 } 2231 else2232 {2233 /* Add to damage regions */2234 XUnionRectWithRegion(&e->area, pGlxPixmap->pDamageRegion, pGlxPixmap->pDamageRegion);2235 }2236 2244 } 2237 2245 } 2238 2246 … … 2339 2347 XUNLOCK(dpy); 2340 2348 2341 2349 /* If there's damage extension, then get handle for damage events related to this pixmap */ 2342 if ( pContext->damageDpy)2350 if (!pContext->damageInitFailed) 2343 2351 { 2344 pGlxPixmap->hDamage = XDamageCreate( pContext->damageDpy, (Pixmap)draw, XDamageReportRawRectangles);2352 pGlxPixmap->hDamage = XDamageCreate(dpy, (Pixmap)draw, XDamageReportRawRectangles); 2345 2353 /*crDebug("Create: Damage for drawable 0x%x, handle 0x%x (level=%i)", 2346 2354 (unsigned int) draw, (unsigned int) pGlxPixmap->damage, (int) XDamageReportRawRectangles);*/ 2347 2355 pGlxPixmap->pDamageRegion = XCreateRegion(); … … 2533 2541 } 2534 2542 2535 2543 /* 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*/ 2540 XLOCK(dpy); 2541 XSync(dpy, False); 2542 XUNLOCK(dpy); 2543 XSync(context->damageDpy, False); 2544 /* Sync connections, note that order of syncs is important here. 2545 * First make sure client commands are finished, then make sure we get all the damage events back*/ 2546 XLOCK(dpy); 2547 XSync(dpy, False); 2548 XUNLOCK(dpy); 2544 2549 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 } 2554 } 2550 stubFetchDamageOnDrawable(dpy, pGlxPixmap); 2555 2551 2556 2552 /* No shared memory? Rollback to use slow x protocol then */ 2557 2553 if (stub.xshmSI.shmid<0) … … 2598 2594 else /* Use shm to get pixmap data */ 2599 2595 { 2600 2596 /* Check if we have damage extension */ 2601 if ( context->damageDpy)2597 if (!context->damageInitFailed) 2602 2598 { 2603 2599 if (pGlxPixmap->bPixmapImageDirty) 2604 2600 { -
src/VBox/Additions/common/crOpenGL/stub.h
147 147 GLXContext glxContext; 148 148 CRHashTable *pGLXPixmapsHash; 149 149 Bool damageInitFailed; 150 Display *damageDpy; /* second display connection to read xdamage extension data */151 150 int damageEventsBase; 152 151 #endif 153 152 }; -
src/VBox/Additions/common/crOpenGL/context.c
441 441 442 442 #ifdef GLX 443 443 crFreeHashtable(context->pGLXPixmapsHash, crFree); 444 if (context->damageDpy)445 {446 XCloseDisplay(context->damageDpy);447 }448 444 #endif 449 445 450 446 crHashtableDelete(stub.contextTable, contextId, NULL); … … 544 540 #ifdef GLX 545 541 context->pGLXPixmapsHash = crAllocHashtable(); 546 542 context->damageInitFailed = GL_FALSE; 547 context->damageDpy = NULL;548 543 context->damageEventsBase = 0; 549 544 #endif 550 545

