[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - 2 commits - vcl/source

Daniel Stone daniels at collabora.com
Wed Oct 29 05:22:19 PDT 2014


 vcl/source/opengl/OpenGLContext.cxx |   40 ++++++++++++++----------------------
 1 file changed, 16 insertions(+), 24 deletions(-)

New commits:
commit fb855f217f2af336090b3ebe40732eee1c3d5c99
Author: Daniel Stone <daniels at collabora.com>
Date:   Wed Oct 29 13:20:52 2014 +0100

    OpenGLContext: Consistently select the window's visual
    
    When using an FBConfig, make sure we use a config compatible with the
    visual we've already created our child window for.
    
    Also remove FBConfigs from the non-debug path, as these are only used
    when creating a 3.2 context.
    
    Change-Id: I7350f961781bdfcd2e5ca740a38f6d1b0b5474aa

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 787e5e5..9748270 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -369,6 +369,7 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ )
     return 0;
 }
 
+#ifdef DBG_UTIL
 GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
 {
     if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
@@ -381,6 +382,7 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
 
     int screen = XScreenNumberOfScreen( xattr.screen );
 
+    // TODO: moggi: Select colour channel depth based on visual attributes, not hardcoded */
     static int visual_attribs[] =
     {
         GLX_DOUBLEBUFFER,       True,
@@ -408,7 +410,7 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
     for(int i = 0; i < fbCount; ++i)
     {
         XVisualInfo* pVi = glXGetVisualFromFBConfig( dpy, pFBC[i] );
-        if(pVi)
+        if(pVi && pVi->visualid == xattr.visual->visualid)
         {
             // pick the one with the most samples per pixel
             int nSampleBuf = 0;
@@ -427,6 +429,7 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC)
 
     return pFBC;
 }
+#endif
 
 // we need them before glew can initialize them
 // glew needs an OpenGL context so we need to get the address manually
@@ -438,18 +441,14 @@ void initOpenGLFunctionPointers()
     glXCreateContextAttribsARB = (GLXContext(*) (Display*, GLXFBConfig, GLXContext, Bool, const int*)) glXGetProcAddressARB((const GLubyte *) "glXCreateContextAttribsARB");;
 }
 
-XVisualInfo* getVisualInfo(Display* dpy, Window win)
+Visual* getVisual(Display* dpy, Window win)
 {
     initOpenGLFunctionPointers();
 
-    int best_fbc = -1;
-    GLXFBConfig* pFBC = getFBConfig(dpy, win, best_fbc);
-
-    XVisualInfo* vi = glXGetVisualFromFBConfig( dpy, pFBC[best_fbc] );
-
-    XFree(pFBC);
-
-    return vi;
+    XWindowAttributes xattr;
+    XGetWindowAttributes( dpy, win, &xattr );
+    SAL_INFO("vcl.opengl", "using VisualID " << xattr.visual);
+    return xattr.visual;
 }
 
 }
@@ -495,14 +494,8 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen)
     m_aGLWin.win = win;
     m_aGLWin.screen = screen;
 
-    XVisualInfo* vi = getVisualInfo(dpy, win);
-    Visual* pVisual = NULL;
+    Visual* pVisual = getVisual(dpy, win);
 
-    if( vi )
-    {
-        SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid);
-        pVisual = vi->visual;
-    }
     initGLWindow(pVisual);
 
     return ImplInit();
@@ -855,6 +848,8 @@ void OpenGLContext::initGLWindow(Visual* pVisual)
     }
 
     // Check multi sample support
+    /* TODO: moggi: This is not necessarily correct in the DBG_UTIL path, as it picks
+     *      an FBConfig instead ... */
     int nSamples = 0;
     glXGetConfig(m_aGLWin.dpy, m_aGLWin.vi, GLX_SAMPLES, &nSamples);
     if( nSamples > 0 )
@@ -896,13 +891,7 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool)
     if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
         return aWinData;
 
-    XVisualInfo* vi = getVisualInfo(dpy, win);
-
-    if( vi )
-    {
-        SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid);
-        aWinData.pVisual = (void*)(vi->visual);
-    }
+    aWinData.pVisual = getVisual(dpy, win);
 
     return aWinData;
 }
commit 363f27a942aaf9b291721512fce4c0b75f85e82b
Author: Daniel Stone <daniels at collabora.com>
Date:   Wed Oct 29 13:05:07 2014 +0100

    OpenGLContext: Add locking/sync around X errors
    
    In order to manipulate the (global) X error handler without races, we
    need to lock the X11 display, and also push an XSync through between
    locking and changing the error handler, so we don't catch unrelated
    errors.
    
    Change-Id: Ic970224c98c05c6e13aadd781f8275cde5f37dd0

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index e5b5c6f..787e5e5 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -656,6 +656,8 @@ bool OpenGLContext::ImplInit()
         if( glXSwapInterval ) {
         int (*oldHandler)(Display* /*dpy*/, XErrorEvent* /*evnt*/);
 
+        XLockDisplay(m_aGLWin.dpy);
+        XSync(m_aGLWin.dpy, false);
         // replace error handler temporarily
         oldHandler = XSetErrorHandler( oglErrorHandler );
 
@@ -674,6 +676,7 @@ bool OpenGLContext::ImplInit()
 
         // restore the error handler
         XSetErrorHandler( oldHandler );
+        XUnlockDisplay(m_aGLWin.dpy);
         }
     }
 


More information about the Libreoffice-commits mailing list