VirtualBox

Changeset 30474 in vbox


Ignore:
Timestamp:
Jun 28, 2010 3:58:12 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63157
Message:

crOpenGL: enable new window tracking code for linux

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

Legend:

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

    r30440 r30474  
    152152
    153153GLboolean
    154 stubIsWindowVisible( const WindowInfo *win )
     154stubIsWindowVisible(WindowInfo *win)
    155155{
    156156#if defined(WINDOWS)
     
    159159    return GL_TRUE;
    160160#elif defined(GLX)
    161     if (win->dpy) {
    162     XWindowAttributes attr;
    163     XLOCK(win->dpy);
    164     XGetWindowAttributes(win->dpy, win->drawable, &attr);
    165     XUNLOCK(win->dpy);
    166     return (attr.map_state != IsUnmapped);
     161    Display *dpy = stubGetWindowDisplay(win);
     162    if (dpy)
     163    {
     164        XWindowAttributes attr;
     165        XLOCK(dpy);
     166        XGetWindowAttributes(dpy, win->drawable, &attr);
     167        XUNLOCK(dpy);
     168        return (attr.map_state != IsUnmapped);
    167169    }
    168170    else {
    169     /* probably created by crWindowCreate() */
    170     return win->mapped;
     171        /* probably created by crWindowCreate() */
     172        return win->mapped;
    171173    }
    172174#endif
     
    461463
    462464static void
    463 GetCursorPosition( const WindowInfo *window, int pos[2] )
     465GetCursorPosition(WindowInfo *window, int pos[2])
    464466{
    465467    RECT rect;
     
    569571
    570572void
    571 stubGetWindowGeometry( const WindowInfo *window, int *x, int *y,
    572                                              unsigned int *w, unsigned int *h )
     573stubGetWindowGeometry(WindowInfo *window, int *x, int *y, unsigned int *w, unsigned int *h)
    573574{
    574575    Window root, child;
    575576    unsigned int border, depth;
     577    Display *dpy;
     578
     579    dpy = stubGetWindowDisplay(window);
    576580
    577581    //@todo: Performing those checks is expensive operation, especially for simple apps with high FPS.
    578582    //       Disabling those tripples glxgears fps, thus using xevens instead of per frame polling is much more preffered.
    579583    //@todo: Check similiar on windows guests, though doubtfull as there're no XSync like calls on windows.
    580     if (window && window->dpy)
     584    if (window && dpy)
    581585    {
    582         XLOCK(window->dpy);
     586        XLOCK(dpy);
    583587    }
    584588
    585589    if (!window
    586         || !window->dpy
     590        || !dpy
    587591        || !window->drawable
    588         || !XGetGeometry(window->dpy, window->drawable, &root,
    589                          x, y, w, h, &border, &depth)
    590         || !XTranslateCoordinates(window->dpy, window->drawable, root,
    591                                   0, 0, x, y, &child))
     592        || !XGetGeometry(dpy, window->drawable, &root, x, y, w, h, &border, &depth)
     593        || !XTranslateCoordinates(dpy, window->drawable, root, 0, 0, x, y, &child))
    592594    {
    593595        crWarning("Failed to get windows geometry for %p, try xwininfo", window);
     
    596598    }
    597599
    598     if (window && window->dpy)
     600    if (window && dpy)
    599601    {
    600         XUNLOCK(window->dpy);
     602        XUNLOCK(dpy);
    601603    }
    602604}
     
    650652 */
    651653static void
    652 GetCursorPosition( const WindowInfo *window, int pos[2] )
     654GetCursorPosition(WindowInfo *window, int pos[2] )
    653655{
    654656    int rootX, rootY;
     
    10781080
    10791081void
    1080 stubSwapBuffers( const WindowInfo *window, GLint flags )
     1082stubSwapBuffers(WindowInfo *window, GLint flags)
    10811083{
    10821084    if (!window)
  • trunk/src/VBox/Additions/common/crOpenGL/glx.c

    r30440 r30474  
    10341034DECLEXPORT(void) VBOXGLXTAG(glXSwapBuffers)( Display *dpy, GLXDrawable drawable )
    10351035{
    1036     const WindowInfo *window = stubGetWindowInfo(dpy, drawable);
     1036    WindowInfo *window = stubGetWindowInfo(dpy, drawable);
    10371037    stubSwapBuffers( window, 0 );
    10381038}
  • trunk/src/VBox/Additions/common/crOpenGL/load.c

    r30440 r30474  
    143143    int x, y;
    144144    unsigned int border, depth, w, h;
    145 
    146     XLOCK(pWindow->dpy);
    147     if (!XGetGeometry(pWindow->dpy, pWindow->drawable, &root, &x, &y, &w, &h, &border, &depth))
    148     {
    149         XUNLOCK(pWindow->dpy);
     145    Display *dpy;
     146
     147    dpy = stubGetWindowDisplay(pWindow);
     148
     149    XLOCK(dpy);
     150    if (!XGetGeometry(dpy, pWindow->drawable, &root, &x, &y, &w, &h, &border, &depth))
     151    {
     152        XUNLOCK(dpy);
    150153        return false;
    151154    }
    152     XUNLOCK(pWindow->dpy);
     155    XUNLOCK(dpy);
    153156#endif
    154157
     
    782785            crNetFreeConnection(ns.conn);
    783786        }
    784 #ifdef CR_NEWWINTRACK
     787#if 0 && defined(CR_NEWWINTRACK)
    785788        {
    786789            Status st = XInitThreads();
  • trunk/src/VBox/Additions/common/crOpenGL/stub.c

    r30440 r30474  
    99#include "cr_mem.h"
    1010#include "stub.h"
     11#include <iprt/thread.h>
    1112
    1213#ifdef GLX
     
    2829}
    2930
     31Display* stubGetWindowDisplay(WindowInfo *pWindow)
     32{
     33#ifdef CR_NEWWINTRACK
     34    if (RTThreadNativeSelf()==RTThreadGetNative(stub.hSyncThread))
     35    {
     36        if (pWindow && pWindow->dpy && !pWindow->syncDpy)
     37        {
     38            crDebug("going to XOpenDisplay(%s)", pWindow->dpyName);
     39            pWindow->syncDpy = XOpenDisplay(pWindow->dpyName);
     40            if (!pWindow->syncDpy)
     41            {
     42                crWarning("Failed to open display %s", pWindow->dpyName);
     43            }
     44            return pWindow->syncDpy;
     45        }
     46        else
     47        {
     48            return pWindow ? pWindow->syncDpy:NULL;
     49        }
     50    }
     51    else
     52#endif
     53    {
     54        return pWindow ? pWindow->dpy:NULL;
     55    }
     56}
     57
    3058/**
    3159 * Returns -1 on error
     
    81109void APIENTRY crSwapBuffers( GLint window, GLint flags )
    82110{
    83     const WindowInfo *winInfo = (const WindowInfo *)
     111    WindowInfo *winInfo = (WindowInfo *)
    84112        crHashtableSearch(stub.windowTable, (unsigned int) window);
    85113    if (winInfo)
     
    100128    WindowInfo *winInfo = (WindowInfo *)
    101129        crHashtableSearch(stub.windowTable, (unsigned int) window);
    102     if (winInfo && winInfo->type == CHROMIUM && stub.spu) {
     130    if (winInfo && winInfo->type == CHROMIUM && stub.spu)
     131    {
    103132        stub.spu->dispatch_table.WindowDestroy( winInfo->spuWindow );
     133#ifdef CR_NEWWINTRACK
     134        crLockMutex(&stub.mutex);
     135#endif
    104136#ifdef WINDOWS
    105137        if (winInfo->hVisibleRegion != INVALID_HANDLE_VALUE)
     
    112144            XFree(winInfo->pVisibleRegions);
    113145        }
     146# ifdef CR_NEWWINTRACK
     147        if (winInfo->syncDpy)
     148        {
     149            XCloseDisplay(winInfo->syncDpy);
     150        }
     151# endif
     152#endif
     153#ifdef CR_NEWWINTRACK
     154        crUnlockMutex(&stub.mutex);
    114155#endif
    115156        crForcedFlush();
    116 
    117157        crHashtableDelete(stub.windowTable, window, crFree);
    118158    }
     
    446486    XRectangle *pXRects;
    447487    GLint* pGLRects;
     488    Display *dpy;
    448489
    449490    if (bExtensionsChecked || stubCheckXExtensions(pWindow))
     
    456497        return GL_FALSE;
    457498    }
     499
     500    dpy = stubGetWindowDisplay(pWindow);
    458501
    459502    /*@todo see comment regarding size/position updates and XSync, same applies to those functions but
    460503    * it seems there's no way to get even based updates for this. Or I've failed to find the appropriate extension.
    461504    */
    462     XLOCK(pWindow->dpy);
    463     xreg = XCompositeCreateRegionFromBorderClip(pWindow->dpy, pWindow->drawable);
    464     pXRects = XFixesFetchRegion(pWindow->dpy, xreg, &cRects);
    465     XFixesDestroyRegion(pWindow->dpy, xreg);
    466     XUNLOCK(pWindow->dpy);
     505    XLOCK(dpy);
     506    xreg = XCompositeCreateRegionFromBorderClip(dpy, pWindow->drawable);
     507    pXRects = XFixesFetchRegion(dpy, xreg, &cRects);
     508    XFixesDestroyRegion(dpy, xreg);
     509    XUNLOCK(dpy);
    467510
    468511    /* @todo For some odd reason *first* run of compiz on freshly booted VM gives us 0 cRects all the time.
  • trunk/src/VBox/Additions/common/crOpenGL/stub.h

    r30440 r30474  
    4646#endif
    4747
    48 #ifdef WINDOWS
    49 #define CR_NEWWINTRACK
     48#if defined(WINDOWS) || defined(Linux)
     49# define CR_NEWWINTRACK
    5050#endif
    5151
     
    5454#endif
    5555
    56 #if defined(CR_NEWWINTRACK) && !defined(WINDOWS)
     56#if 0 && defined(CR_NEWWINTRACK) && !defined(WINDOWS)
    5757#define XLOCK(dpy) XLockDisplay(dpy)
    5858#define XUNLOCK(dpy) XUnlockDisplay(dpy)
     
    166166#elif defined(GLX)
    167167    Display *dpy;
     168# ifdef CR_NEWWINTRACK
     169    Display *syncDpy;
     170# endif
    168171    GLXDrawable drawable;
    169172    XRectangle *pVisibleRegions;
     
    279282extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
    280283extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
     284extern Display* stubGetWindowDisplay(WindowInfo *pWindow);
    281285
    282286#endif
     
    287291extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
    288292extern GLint stubNewWindow( const char *dpyName, GLint visBits );
    289 extern void stubSwapBuffers( const WindowInfo *window, GLint flags );
    290 extern void stubGetWindowGeometry( const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h );
     293extern void stubSwapBuffers(WindowInfo *window, GLint flags);
     294extern void stubGetWindowGeometry(WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h);
    291295extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
    292 extern GLboolean stubIsWindowVisible( const WindowInfo *win );
     296extern GLboolean stubIsWindowVisible(WindowInfo *win);
    293297extern bool stubInit(void);
    294298
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