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

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sat Nov 8 06:24:23 PST 2014


 include/vcl/opengl/OpenGLContext.hxx |    1 
 vcl/opengl/gdiimpl.cxx               |    2 
 vcl/source/opengl/OpenGLContext.cxx  |  185 +++++++++++++++++------------------
 vcl/unx/generic/gdi/salvd.cxx        |    6 -
 4 files changed, 96 insertions(+), 98 deletions(-)

New commits:
commit 62648ad2cf7d64ab2dd2e8511a1874c5524149f0
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Nov 8 15:00:30 2014 +0100

    fix bug around wrong number of vertices
    
    Change-Id: I52c6c0b5d815266a254a75eabfe8947ccc44bfb5

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 2d520ea..a4f5592 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -307,7 +307,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
     }
 
     glEnableVertexAttribArray( GL_ATTRIB_POS );
-    glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
+    glVertexAttribPointer( GL_ATTRIB_POS, nPoints * 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
     glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
     glDisableVertexAttribArray( GL_ATTRIB_POS );
 }
commit 42baae783944ef7940f2b4da3f0638db576bbc97
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Nov 8 15:00:05 2014 +0100

    improve log messages
    
    Change-Id: Ibf7d134be982122f403473380cff3b82efef8b71

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index d5cfd94..d499db1 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -979,7 +979,8 @@ void OpenGLContext::makeCurrent()
 #elif defined( IOS ) || defined( ANDROID )
     // nothing
 #elif defined( UNX )
-    glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx );
+    if (!glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ))
+        SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed");
 #endif
 }
 
commit 28cb366d426a34e04cb1233593678e42c9a24860
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Fri Nov 7 06:13:05 2014 +0100

    split the OpenGLContext::ImplInit method into its platform parts
    
    Change-Id: I2fb8a85748497f2e9c361764e094ebf83ebeabe8

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 8e4c257..b9c03c3 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -194,6 +194,7 @@ public:
     static SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext);
 
 private:
+    SAL_DLLPRIVATE bool InitGLEW();
     SAL_DLLPRIVATE bool initWindow();
     SAL_DLLPRIVATE bool ImplInit();
 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index ce954bb..d5cfd94 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -493,6 +493,8 @@ bool OpenGLContext::init( vcl::Window* pParent )
 
     m_pWindow.reset(pParent ? NULL : new vcl::Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
     mpWindow = pParent ? pParent : m_pWindow.get();
+    if(m_pWindow)
+        m_pWindow->setPosSizePixel(0,0,0,0);
     m_pChildWindow = 0;
     initWindow();
     return ImplInit();
@@ -531,42 +533,11 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen)
 
     return ImplInit();
 }
-#elif defined( _WIN32 )
-bool OpenGLContext::init(HDC hDC, HWND hWnd)
-{
-    if (mbInitialized)
-        return false;
-
-    m_aGLWin.hDC = hDC;
-    m_aGLWin.hWnd = hWnd;
-    return ImplInit();
-}
-#endif
 
 bool OpenGLContext::ImplInit()
 {
     SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
-    if(m_pWindow)
-        m_pWindow->setPosSizePixel(0,0,0,0);
-    m_aGLWin.Width = 0;
-    m_aGLWin.Height = 0;
-
-#if defined( WNT )
-#elif defined( MACOSX )
-
-#elif defined( IOS )
-
-    SAL_INFO("vcl.opengl", "OpenGLContext not implemented yet for iOS");
-    return false;
-
-#elif defined( ANDROID )
-
-    SAL_INFO("vcl.opengl", "OpenGLContext not implemented yet for Android");
-    return false;
-
-#elif defined( UNX )
 #ifdef DBG_UTIL
-
     if (glXCreateContextAttribsARB && !mbRequestLegacyContext)
     {
         int best_fbc = -1;
@@ -613,10 +584,78 @@ bool OpenGLContext::ImplInit()
         SAL_WARN("vcl.opengl", "unable to create GLX context");
         return false;
     }
-#endif
 
-#if defined( WNT )
-    PIXELFORMATDESCRIPTOR PixelFormatFront =                    // PixelFormat Tells Windows How We Want Things To Be
+    if( !glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ) )
+    {
+        SAL_WARN("vcl.opengl", "unable to select current GLX context");
+        return false;
+    }
+
+    int glxMinor, glxMajor;
+    double nGLXVersion = 0;
+    if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) )
+      nGLXVersion = glxMajor + 0.1*glxMinor;
+    SAL_INFO("vcl.opengl", "available GLX version: " << nGLXVersion);
+
+    m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS );
+    SAL_INFO("vcl.opengl", "available GL  extensions: " << m_aGLWin.GLExtensions);
+
+    XWindowAttributes xWinAttr;
+    XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr );
+    m_aGLWin.Width = xWinAttr.width;
+    m_aGLWin.Height = xWinAttr.height;
+
+    if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) )
+    {
+        // enable vsync
+        typedef GLint (*glXSwapIntervalProc)(GLint);
+        glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" );
+        if( glXSwapInterval )
+        {
+            int (*oldHandler)(Display* /*dpy*/, XErrorEvent* /*evnt*/);
+
+            XLockDisplay(m_aGLWin.dpy);
+            XSync(m_aGLWin.dpy, false);
+            // replace error handler temporarily
+            oldHandler = XSetErrorHandler( oglErrorHandler );
+
+            errorTriggered = false;
+
+            glXSwapInterval( 1 );
+
+            // sync so that we possibly get an XError
+            glXWaitGL();
+            XSync(m_aGLWin.dpy, false);
+
+            if( errorTriggered )
+                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)");
+
+            // restore the error handler
+            XSetErrorHandler( oldHandler );
+            XUnlockDisplay(m_aGLWin.dpy);
+        }
+    }
+    return InitGLEW();
+}
+
+#elif defined( _WIN32 )
+
+bool OpenGLContext::init(HDC hDC, HWND hWnd)
+{
+    if (mbInitialized)
+        return false;
+
+    m_aGLWin.hDC = hDC;
+    m_aGLWin.hWnd = hWnd;
+    return ImplInit();
+}
+
+bool OpenGLContext::ImplInit()
+{
+    SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
+    PIXELFORMATDESCRIPTOR PixelFormatFront = // PixelFormat Tells Windows How We Want Things To Be
     {
         sizeof(PIXELFORMATDESCRIPTOR),
         1,                              // Version Number
@@ -677,76 +716,35 @@ bool OpenGLContext::ImplInit()
         return false;
     }
 
-    RECT clientRect;
-    GetClientRect(WindowFromDC(m_aGLWin.hDC), &clientRect);
     m_aGLWin.Width = clientRect.right - clientRect.left;
     m_aGLWin.Height = clientRect.bottom - clientRect.top;
 
+    return InitGLEW();
+}
+
 #elif defined( MACOSX )
 
+bool OpenGLContext::ImplInit()
+{
+    SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
     NSOpenGLView* pView = getOpenGLView();
     OpenGLWrapper::makeCurrent(pView);
 
-#elif defined( IOS )
-
-#elif defined( ANDROID )
-
-#elif defined( UNX )
-    if( !glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ) )
-    {
-        SAL_WARN("vcl.opengl", "unable to select current GLX context");
-        return false;
-    }
-
-    int glxMinor, glxMajor;
-    double nGLXVersion = 0;
-    if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) )
-      nGLXVersion = glxMajor + 0.1*glxMinor;
-    SAL_INFO("vcl.opengl", "available GLX version: " << nGLXVersion);
-
-    m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS );
-    SAL_INFO("vcl.opengl", "available GL  extensions: " << m_aGLWin.GLExtensions);
-
-    XWindowAttributes xWinAttr;
-    XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr );
-    m_aGLWin.Width = xWinAttr.width;
-    m_aGLWin.Height = xWinAttr.height;
-
-    if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) )
-    {
-        // enable vsync
-        typedef GLint (*glXSwapIntervalProc)(GLint);
-        glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" );
-        if( glXSwapInterval )
-        {
-            int (*oldHandler)(Display* /*dpy*/, XErrorEvent* /*evnt*/);
-
-            XLockDisplay(m_aGLWin.dpy);
-            XSync(m_aGLWin.dpy, false);
-            // replace error handler temporarily
-            oldHandler = XSetErrorHandler( oglErrorHandler );
-
-            errorTriggered = false;
-
-            glXSwapInterval( 1 );
-
-            // sync so that we possibly get an XError
-            glXWaitGL();
-            XSync(m_aGLWin.dpy, false);
+    return InitGLEW();
+}
 
-            if( errorTriggered )
-                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)");
+#else
 
-            // restore the error handler
-            XSetErrorHandler( oldHandler );
-            XUnlockDisplay(m_aGLWin.dpy);
-        }
-    }
+bool OpenGLContext::ImplInit()
+{
+    SAL_INFO("vcl.opengl", "OpenGLContext not implemented for this platform");
+    return false;
+}
 
 #endif
 
+bool OpenGLContext::InitGLEW()
+{
     static bool bGlewInit = false;
     if(!bGlewInit)
     {
commit 8fe72c340e6c6b023f89ea803eabb56e4da603b3
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Fri Nov 7 05:46:33 2014 +0100

    remove old uncommented code
    
    Change-Id: I27bf3b6c812419b1a6dbaa1abb890ba89f4549ff

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b5a1898..ce954bb 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -747,8 +747,6 @@ bool OpenGLContext::ImplInit()
 
 #endif
 
-    //rGLRender.InitOpenGL(m_aGLWin);
-
     static bool bGlewInit = false;
     if(!bGlewInit)
     {
commit 00ea305db1adaf813b200aa1e426b7f4d556e3ff
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Fri Nov 7 01:32:11 2014 +0100

    change order of calls
    
    Change-Id: I1c45ff7ba09972c20af0c28a5c3e1514171504ff

diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx
index 83925d9..8e08cc2 100644
--- a/vcl/unx/generic/gdi/salvd.cxx
+++ b/vcl/unx/generic/gdi/salvd.cxx
@@ -102,14 +102,14 @@ void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap,
     if (m_pDeleteColormap != pOrigDeleteColormap)
         delete pOrigDeleteColormap;
 
-    const Drawable aVdevDrawable = pDevice->GetDrawable();
-    SetDrawable( aVdevDrawable, m_nXScreen );
-
     m_pVDev      = pDevice;
     m_pFrame     = NULL;
 
     bWindow_     = pDisplay->IsDisplay();
     bVirDev_     = true;
+
+    const Drawable aVdevDrawable = pDevice->GetDrawable();
+    SetDrawable( aVdevDrawable, m_nXScreen );
 }
 
 bool X11SalVirtualDevice::Init( SalDisplay *pDisplay,


More information about the Libreoffice-commits mailing list