[Libreoffice-commits] core.git: 7 commits - include/vcl slideshow/source vcl/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Sep 3 06:10:31 PDT 2014


 include/vcl/opengl/OpenGLContext.hxx                                   |    1 
 slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx |    2 
 vcl/source/opengl/OpenGLContext.cxx                                    |  151 ++++++----
 3 files changed, 93 insertions(+), 61 deletions(-)

New commits:
commit c49f0575505a15087107e6eed9b54cf1450352fb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 3 14:51:15 2014 +0200

    don't crash if the new create context method is not available
    
    Change-Id: I50a8b89f83e095e5d8a110dfbf81ccadea4b39a5

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index ffd0e28..70ac761 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -487,7 +487,7 @@ bool OpenGLContext::ImplInit()
 #elif defined( UNX )
 #if DBG_UTIL
 
-    if (!mbRequestLegacyContext)
+    if (glXCreateContextAttribsARB && !mbRequestLegacyContext)
     {
         int best_fbc = -1;
         const SystemEnvData* sysData(m_pChildWindow->GetSystemData());
commit 6f5b639d4af0618cbb071a30a66aa5b9581f315c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 3 14:25:57 2014 +0200

    don't create a core context if we need a legacy one
    
    Change-Id: Ieb8a26e0495f537ca78898e6d49df2c1271537a0

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b1efb89..ffd0e28 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -487,16 +487,20 @@ bool OpenGLContext::ImplInit()
 #elif defined( UNX )
 #if DBG_UTIL
 
-    int best_fbc = -1;
-    const SystemEnvData* sysData(m_pChildWindow->GetSystemData());
-    GLXFBConfig* pFBC = getFBConfig(sysData, best_fbc);
-    int nContextAttribs[] =
+    if (!mbRequestLegacyContext)
     {
-        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
-        GLX_CONTEXT_MINOR_VERSION_ARB, 2,
-        None
-    };
-    m_aGLWin.ctx = glXCreateContextAttribsARB(m_aGLWin.dpy, pFBC[best_fbc], 0, GL_TRUE, nContextAttribs);
+        int best_fbc = -1;
+        const SystemEnvData* sysData(m_pChildWindow->GetSystemData());
+        GLXFBConfig* pFBC = getFBConfig(sysData, best_fbc);
+        int nContextAttribs[] =
+        {
+            GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+            GLX_CONTEXT_MINOR_VERSION_ARB, 2,
+            None
+        };
+        m_aGLWin.ctx = glXCreateContextAttribsARB(m_aGLWin.dpy, pFBC[best_fbc], 0, GL_TRUE, nContextAttribs);
+
+    }
 #endif
     if (!m_aGLWin.ctx)
     {
commit 2b1ad741d736896dd8c6de5efee808a3b8ef1625
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 3 14:21:19 2014 +0200

    create a 3.2 core context if supported in dbgutil mode
    
    Change-Id: I2ef951590d23e8b805301b2ffc1b82213b898400

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 93babc1..b1efb89 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -369,6 +369,69 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ )
     return 0;
 }
 
+GLXFBConfig* getFBConfig(const SystemEnvData* sysData, int& nBestFBC)
+{
+    Display *dpy = reinterpret_cast<Display*>(sysData->pDisplay);
+
+    if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
+        return NULL;
+
+    XLIB_Window win = sysData->aWindow;
+
+    SAL_INFO("vcl.opengl", "parent window: " << win);
+
+    XWindowAttributes xattr;
+    XGetWindowAttributes( dpy, win, &xattr );
+
+    int screen = XScreenNumberOfScreen( xattr.screen );
+
+    static int visual_attribs[] =
+    {
+        GLX_DOUBLEBUFFER,       True,
+        GLX_X_RENDERABLE,       True,
+        GLX_RED_SIZE,           8,
+        GLX_GREEN_SIZE,         8,
+        GLX_BLUE_SIZE,          8,
+        GLX_ALPHA_SIZE,         8,
+        GLX_DEPTH_SIZE,         24,
+        GLX_X_VISUAL_TYPE,      GLX_TRUE_COLOR,
+        None
+    };
+    int fbCount = 0;
+    GLXFBConfig* pFBC = glXChooseFBConfig( dpy,
+            screen,
+            visual_attribs, &fbCount );
+
+    if(!pFBC)
+    {
+        SAL_WARN("vcl.opengl", "no suitable fb format found");
+        return NULL;
+    }
+
+    int best_num_samp = -1;
+    for(int i = 0; i < fbCount; ++i)
+    {
+        XVisualInfo* pVi = glXGetVisualFromFBConfig( dpy, pFBC[i] );
+        if(pVi)
+        {
+            // pick the one with the most samples per pixel
+            int nSampleBuf = 0;
+            int nSamples = 0;
+            glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLE_BUFFERS, &nSampleBuf );
+            glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLES       , &nSamples  );
+
+            if ( nBestFBC < 0 || (nSampleBuf && ( nSamples > best_num_samp )) )
+            {
+                nBestFBC = i;
+                best_num_samp = nSamples;
+            }
+        }
+        XFree( pVi );
+    }
+
+    return pFBC;
+}
+
 }
 
 #endif
@@ -422,10 +485,26 @@ bool OpenGLContext::ImplInit()
     return false;
 
 #elif defined( UNX )
-    m_aGLWin.ctx = m_aGLWin.dpy == 0 ? 0 : glXCreateContext(m_aGLWin.dpy,
-                                 m_aGLWin.vi,
-                                 0,
-                                 GL_TRUE);
+#if DBG_UTIL
+
+    int best_fbc = -1;
+    const SystemEnvData* sysData(m_pChildWindow->GetSystemData());
+    GLXFBConfig* pFBC = getFBConfig(sysData, best_fbc);
+    int nContextAttribs[] =
+    {
+        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+        GLX_CONTEXT_MINOR_VERSION_ARB, 2,
+        None
+    };
+    m_aGLWin.ctx = glXCreateContextAttribsARB(m_aGLWin.dpy, pFBC[best_fbc], 0, GL_TRUE, nContextAttribs);
+#endif
+    if (!m_aGLWin.ctx)
+    {
+        m_aGLWin.ctx = m_aGLWin.dpy == 0 ? 0 : glXCreateContext(m_aGLWin.dpy,
+                m_aGLWin.vi,
+                0,
+                GL_TRUE);
+    }
     if( m_aGLWin.ctx == NULL )
     {
         SAL_WARN("vcl.opengl", "unable to create GLX context");
@@ -748,6 +827,7 @@ void initOpenGLFunctionPointers()
     glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
     glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig");    // try to find a visual for the current set of attributes
     glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib");
+    glXCreateContextAttribsARB = (GLXContext(*) (Display*, GLXFBConfig, GLXContext, Bool, const int*)) glXGetProcAddressARB((const GLubyte *) "glXCreateContextAttribsARB");;
 }
 
 }
@@ -765,61 +845,10 @@ SystemWindowData OpenGLContext::generateWinData(Window* pParent, bool)
     if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
         return aWinData;
 
-    XLIB_Window win = sysData->aWindow;
-
-    SAL_INFO("vcl.opengl", "parent window: " << win);
-
-    XWindowAttributes xattr;
-    XGetWindowAttributes( dpy, win, &xattr );
-
-    int screen = XScreenNumberOfScreen( xattr.screen );
-
-    static int visual_attribs[] =
-    {
-        GLX_DOUBLEBUFFER,       True,
-        GLX_X_RENDERABLE,       True,
-        GLX_RED_SIZE,           8,
-        GLX_GREEN_SIZE,         8,
-        GLX_BLUE_SIZE,          8,
-        GLX_ALPHA_SIZE,         8,
-        GLX_DEPTH_SIZE,         24,
-        GLX_X_VISUAL_TYPE,      GLX_TRUE_COLOR,
-        None
-    };
-
     initOpenGLFunctionPointers();
 
-    int fbCount = 0;
-    GLXFBConfig* pFBC = glXChooseFBConfig( dpy,
-            screen,
-            visual_attribs, &fbCount );
-
-    if(!pFBC)
-    {
-        SAL_WARN("vcl.opengl", "no suitable fb format found");
-        return aWinData;
-    }
-
-    int best_fbc = -1, best_num_samp = -1;
-    for(int i = 0; i < fbCount; ++i)
-    {
-        XVisualInfo* pVi = glXGetVisualFromFBConfig( dpy, pFBC[i] );
-        if(pVi)
-        {
-            // pick the one with the most samples per pixel
-            int nSampleBuf = 0;
-            int nSamples = 0;
-            glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLE_BUFFERS, &nSampleBuf );
-            glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLES       , &nSamples  );
-
-            if ( best_fbc < 0 || (nSampleBuf && ( nSamples > best_num_samp )) )
-            {
-                best_fbc = i;
-                best_num_samp = nSamples;
-            }
-        }
-        XFree( pVi );
-    }
+    int best_fbc = -1;
+    GLXFBConfig* pFBC = getFBConfig(sysData, best_fbc);
 
     XVisualInfo* vi = glXGetVisualFromFBConfig( dpy, pFBC[best_fbc] );
     if( vi )
commit 979f918a879a711eded5f7b19c521e6f0f6e5a67
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 3 14:20:36 2014 +0200

    SAL_INFO -> SAL_WARN for important error message
    
    Change-Id: I204ca62f77d580b9ebdf9e7d41c28e3f2675ef94

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index ab2bea7..93babc1 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -428,7 +428,7 @@ bool OpenGLContext::ImplInit()
                                  GL_TRUE);
     if( m_aGLWin.ctx == NULL )
     {
-        SAL_INFO("vcl.opengl", "unable to create GLX context");
+        SAL_WARN("vcl.opengl", "unable to create GLX context");
         return false;
     }
 #endif
commit 6f479a32070767b2353cdef819de2596c5d4ce15
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 3 10:24:42 2014 +0200

    SAL_INFO -> SAL_WARN for important error message
    
    Change-Id: I52cf416286801c5eebc1dd395fb7cf592b985e92

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 18e0a02..ab2bea7 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -533,7 +533,7 @@ bool OpenGLContext::ImplInit()
         XSync(m_aGLWin.dpy, false);
 
         if( errorTriggered )
-            SAL_INFO("vcl.opengl", "error when trying to set swap interval, NVIDIA or Mesa bug?");
+            SAL_WARN("vcl.opengl", "error when trying to set swap interval, NVIDIA or Mesa bug?");
         else
             SAL_INFO("vcl.opengl", "set swap interval to 1 (enable vsync)");
 
commit 671da1975845e41fb2c7ebaf63a52a712954eb15
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Sep 2 17:55:08 2014 +0200

    I thought I killed all traces of CGL
    
    Change-Id: I2ab1c4af301869e895628859fef0845e9f16cd10

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 79f97fc..4d8436d 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -96,7 +96,6 @@ struct GLWindow
     HDC                     hDC;
     HGLRC                   hRC;
 #elif defined( MACOSX )
-    CGLContextObj context;
 #elif defined( IOS )
 #elif defined( ANDROID )
 #elif defined( UNX )
commit f60bc85f6b1d175565e2f4abf3b2cfe8614f52ee
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Sep 2 10:32:22 2014 +0200

    SAL_WARN to SAL_INFO
    
    Change-Id: I390a6d3c730bf26c87184e2d4d373692ccc98493

diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
index 8faa728..b28c0f1 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
@@ -368,12 +368,12 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta
     sal_Int64 aVal = 0;
     aDeviceParams[1] >>= aVal;
 
-    SAL_WARN("slideshow", "created the context");
     mpContext = boost::make_shared<OpenGLContext>();
     mpContext->requestLegacyContext();
 
     if( !mpContext->init( reinterpret_cast< Window* >( aVal ) ) )
         return false;
+    SAL_INFO("slideshow", "created the context");
 
     CHECK_GL_ERROR();
     awt::Rectangle aCanvasArea = mxView->getCanvasArea();


More information about the Libreoffice-commits mailing list