VirtualBox

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 Michael Thayer, 12 years ago)

Adjusted patch

  • src/VBox/Additions/common/crOpenGL/glx.c

     
    5757static struct VisualInfo *VisualInfoList = NULL;
    5858
    5959static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect);
    60 static void stubInitXDamageExtension(ContextInfo *pContext);
     60static void stubInitXDamageExtension(Display *dpy, ContextInfo *pContext);
    6161
    6262static void
    6363AddVisualInfo(Display *dpy, int screen, VisualID visualid, int visBits)
     
    626626
    627627    /* This means that clients can't hold a server grab during
    628628     * glXCreateContext! */
    629     stubInitXDamageExtension(context);
     629    stubInitXDamageExtension(dpy, context);
    630630
    631631    return (GLXContext) context->id;
    632632}
     
    17831783    if (parms.pGlxPixmap->hDamage>0)
    17841784    {
    17851785        //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);
    17871787    }
    17881788
    17891789    if (parms.pGlxPixmap->pDamageRegion)
     
    21732173#endif
    21742174}
    21752175
    2176 void stubInitXDamageExtension(ContextInfo *pContext)
     2176void stubInitXDamageExtension(Display *dpy, ContextInfo *pContext)
    21772177{
    21782178    int erb, vma, vmi;
    21792179
    21802180    CRASSERT(pContext);
    21812181   
    2182     if (pContext->damageInitFailed || pContext->damageDpy)
     2182    if (pContext->damageInitFailed)
    21832183        return;
    21842184
    21852185    pContext->damageInitFailed = True;
    21862186
    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))
    21922189    {
    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     {
    22002190        crWarning("XDamage not found or old version (%i.%i), going to run *very* slow", vma, vmi);
    2201         XCloseDisplay(pContext->damageDpy);
    2202         pContext->damageDpy = NULL;
    22032191        return;
    22042192    }
    22052193
     
    22072195    pContext->damageInitFailed = False;
    22082196}
    22092197
    2210 static void stubCheckXDamageCB(unsigned long key, void *data1, void *data2)
     2198static void stubFetchDamageOnDrawable(Display *dpy, GLX_Pixmap_t *pGlxPixmap)
    22112199{
    2212     GLX_Pixmap_t *pGlxPixmap = (GLX_Pixmap_t *) data1;
    2213     XDamageNotifyEvent *e = (XDamageNotifyEvent *) data2;
     2200    Damage damage = pGlxPixmap->hDamage;
    22142201
    2215     if (pGlxPixmap->hDamage==e->damage)
     2202    if (damage)
    22162203    {
     2204        XRectangle *returnRects;
     2205        int        nReturnRects;
    22172206        /*crDebug("Event: Damage for pixmap 0x%lx(drawable 0x%x), handle 0x%x (level=%i) [%i,%i,%i,%i]",
    22182207                key, (unsigned int) e->drawable, (unsigned int) e->damage, (int) e->level,
    22192208                e->area.x, e->area.y, e->area.width, e->area.height);*/
    22202209
     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
    22212225        if (pGlxPixmap->pDamageRegion)
    22222226        {
    22232227            /* If it's dirty and regions are empty, it marked for full update, so do nothing.*/
    22242228            if (!pGlxPixmap->bPixmapImageDirty || !XEmptyRegion(pGlxPixmap->pDamageRegion))
    22252229            {
    2226                 if (CR_MAX_DAMAGE_REGIONS_TRACKED <= pGlxPixmap->pDamageRegion->numRects)
     2230                int i = 0;
     2231                for (; i < nReturnRects; ++i)
    22272232                {
    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                    }
    22302243                }
    2231                 else
    2232                 {
    2233                     /* Add to damage regions */
    2234                     XUnionRectWithRegion(&e->area, pGlxPixmap->pDamageRegion, pGlxPixmap->pDamageRegion);
    2235                 }
    22362244            }
    22372245        }
    22382246
     
    23392347    XUNLOCK(dpy);
    23402348
    23412349    /* If there's damage extension, then get handle for damage events related to this pixmap */
    2342     if (pContext->damageDpy)
     2350    if (!pContext->damageInitFailed)
    23432351    {
    2344         pGlxPixmap->hDamage = XDamageCreate(pContext->damageDpy, (Pixmap)draw, XDamageReportRawRectangles);
     2352        pGlxPixmap->hDamage = XDamageCreate(dpy, (Pixmap)draw, XDamageReportRawRectangles);
    23452353        /*crDebug("Create: Damage for drawable 0x%x, handle 0x%x (level=%i)",
    23462354                 (unsigned int) draw, (unsigned int) pGlxPixmap->damage, (int) XDamageReportRawRectangles);*/
    23472355        pGlxPixmap->pDamageRegion = XCreateRegion();
     
    25332541    }
    25342542
    25352543    /* 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);
    25442549
    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);
    25552551
    25562552    /* No shared memory? Rollback to use slow x protocol then */
    25572553    if (stub.xshmSI.shmid<0)
     
    25982594    else /* Use shm to get pixmap data */
    25992595    {
    26002596        /* Check if we have damage extension */
    2601         if (context->damageDpy)
     2597        if (!context->damageInitFailed)
    26022598        {
    26032599            if (pGlxPixmap->bPixmapImageDirty)
    26042600            {
  • src/VBox/Additions/common/crOpenGL/stub.h

     
    147147    GLXContext glxContext;
    148148    CRHashTable *pGLXPixmapsHash;
    149149    Bool     damageInitFailed;
    150     Display *damageDpy; /* second display connection to read xdamage extension data */
    151150    int      damageEventsBase;
    152151#endif
    153152};
  • src/VBox/Additions/common/crOpenGL/context.c

     
    441441
    442442#ifdef GLX
    443443    crFreeHashtable(context->pGLXPixmapsHash, crFree);
    444     if (context->damageDpy)
    445     {
    446         XCloseDisplay(context->damageDpy);
    447     }
    448444#endif
    449445
    450446    crHashtableDelete(stub.contextTable, contextId, NULL);
     
    544540#ifdef GLX
    545541    context->pGLXPixmapsHash = crAllocHashtable();
    546542    context->damageInitFailed = GL_FALSE;
    547     context->damageDpy = NULL;
    548543    context->damageEventsBase = 0;
    549544#endif
    550545

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy