VirtualBox

Changeset 49214 in vbox


Ignore:
Timestamp:
Oct 21, 2013 2:56:51 PM (11 years ago)
Author:
vboxsync
Message:

Additions/linux/3d: do not use a separate display connection to get damage information - thank you Sam Spilsbury.

Location:
trunk/src/VBox/Additions/common/crOpenGL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/context.c

    r48999 r49214  
    451451#ifdef GLX
    452452    crFreeHashtable(context->pGLXPixmapsHash, crFree);
    453     if (context->damageDpy)
    454     {
    455         XCloseDisplay(context->damageDpy);
    456     }
    457453#endif
    458454
     
    553549#ifdef GLX
    554550    context->pGLXPixmapsHash = crAllocHashtable();
    555     context->damageInitFailed = GL_FALSE;
    556     context->damageDpy = NULL;
     551    context->damageQueryFailed = GL_FALSE;
    557552    context->damageEventsBase = 0;
    558553#endif
  • trunk/src/VBox/Additions/common/crOpenGL/glx.c

    r43837 r49214  
    5858
    5959static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect);
    60 static void stubInitXDamageExtension(ContextInfo *pContext);
     60static void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext);
    6161
    6262static void
     
    625625    context->direct = direct;
    626626
    627     /* This means that clients can't hold a server grab during
    628      * glXCreateContext! */
    629     stubInitXDamageExtension(context);
     627    stubQueryXDamageExtension(dpy, context);
    630628
    631629    return (GLXContext) context->id;
     
    17841782    {
    17851783        //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);
    17871785    }
    17881786
     
    21742172}
    21752173
    2176 void stubInitXDamageExtension(ContextInfo *pContext)
     2174void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext)
    21772175{
    21782176    int erb, vma, vmi;
     
    21802178    CRASSERT(pContext);
    21812179   
    2182     if (pContext->damageInitFailed || pContext->damageDpy)
     2180    if (pContext->damageQueryFailed)
    21832181        return;
    21842182
    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);
    21942189        return;
    21952190    }
    21962191
    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 
    22062192    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
     2196static 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);
    22202219
    22212220        if (pGlxPixmap->pDamageRegion)
     
    22242223            if (!pGlxPixmap->bPixmapImageDirty || !XEmptyRegion(pGlxPixmap->pDamageRegion))
    22252224            {
    2226                 if (CR_MAX_DAMAGE_REGIONS_TRACKED <= pGlxPixmap->pDamageRegion->numRects)
     2225                int i = 0;
     2226                for (; i < nReturnRects; ++i)
    22272227                {
    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                    }
    22352238                }
    22362239            }
    22372240        }
     2241
     2242        XFree(returnRects);
    22382243
    22392244        pGlxPixmap->bPixmapImageDirty = True;
     
    23402345
    23412346    /* 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);
    23452350        /*crDebug("Create: Damage for drawable 0x%x, handle 0x%x (level=%i)",
    23462351                 (unsigned int) draw, (unsigned int) pGlxPixmap->damage, (int) XDamageReportRawRectangles);*/
     
    25342539
    25352540    /* 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 */
    25402544        XLOCK(dpy);
    25412545        XSync(dpy, False);
    25422546        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);
    25542549    }
    25552550
     
    25992594    {
    26002595        /* Check if we have damage extension */
    2601         if (context->damageDpy)
     2596        if (!context->damageQueryFailed)
    26022597        {
    26032598            if (pGlxPixmap->bPixmapImageDirty)
  • trunk/src/VBox/Additions/common/crOpenGL/stub.h

    r49005 r49214  
    147147    GLXContext glxContext;
    148148    CRHashTable *pGLXPixmapsHash;
    149     Bool     damageInitFailed;
    150     Display *damageDpy; /* second display connection to read xdamage extension data */
     149    Bool     damageQueryFailed;
    151150    int      damageEventsBase;
    152151#endif
Note: See TracChangeset for help on using the changeset viewer.

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