vcl/opengl/win/gdiimpl.cxx      |   44 +---------------------------------------
 vcl/source/gdi/salgdilayout.cxx |   33 ++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 44 deletions(-)

New commits:
commit 11e6f819122bc51b5ed58d2dbace754c00faa7c8
Author: Caolán McNamara <[email protected]>
Date:   Thu Dec 8 13:40:34 2016 +0000

    move the windows restart because of bad-opengl requirements to a better 
place
    
    because if the opengl support is such that the opengl-for-vcl requirements 
don't
    fit, then on the second run after discovering this (the first having 
restarted)
    if you try opengl slide transitions libreoffice will just exit because it
    thinks this first check of opengl-for-slideshow is the first opengl-for-vcl 
effort.
    
    so move this code into the place which I believe is the opengl-for-vcl 
entry point
    
    the return from ImplInit *is* checked
    
    bool WinOpenGLContext::init(HDC hDC, HWND hWnd)
    {
    ... return ImplInit();
    }
    
    rtl::Reference<OpenGLContext> WinOpenGLSalGraphicsImpl::CreateWinContext()
    {
    ... if (!xContext->init(mrWinParent.mhLocalDC, mrWinParent.mhWnd))
    }
    
    etc.
    
    Another problem here is ...
    
    "If we notice that OpenGL is broken the first time being called, it is not 
too
    late to call disableOpenGLAndTerminateForRestart(). The first time this 
will be
    called is from displaying the splash screen"
    
    isn't true when the first start causes opengl to be disabled, then on 
subsequent
    starts you can enter this function from launching an opengl slide 
transition.
    
    (note opengl is disabled if opengl is < 30, so all the versioning checks the
    slide transitions do is probably pointless now. The only actually useful use
    of opengl we have seems to be somewhat unloved)
    
    Change-Id: I1e159f826447520f39ea063fd4c0c83220b1385f
    (cherry picked from commit 2109e7d9a0d3dab172961ec19e75da1fa8a6cc61)
    
    this is all related to...
    
    commit 210c39dd9a6ebaa964c03c20e4b442ea36941ae9
    Date:   Fri Jun 3 09:25:13 2016 +0300
    
        tdf#100193: Check earlier and harder whether OpenGL is good enough on 
Windows
    
    Change-Id: I3f6a72efff9c533ca9a0602227fd929ac645f60b
    Reviewed-on: https://gerrit.libreoffice.org/31763
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    (cherry picked from commit d96686e482d2f2649dbd87d7ed9db2775e5d22f5)
    Reviewed-on: https://gerrit.libreoffice.org/31796
    Tested-by: Jenkins <[email protected]>

diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 6215c4c..240331f 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -10,7 +10,6 @@
 #include "opengl/win/gdiimpl.hxx"
 
 #include <comphelper/windowserrorstring.hxx>
-#include <desktop/exithelper.h>
 #include <opengl/zone.hxx>
 #include <o3tl/lru_map.hxx>
 #include <win/wincomp.hxx>
@@ -373,12 +372,6 @@ bool InitMultisample(const PIXELFORMATDESCRIPTOR& pfd, 
int& rPixelFormat,
 namespace
 {
 
-void disableOpenGLAndTerminateForRestart()
-{
-    OpenGLZone::hardDisable();
-    TerminateProcess(GetCurrentProcess(), EXITHELPER_NORMAL_RESTART);
-}
-
 bool tryShaders(const OUString& rVertexShader, const OUString& 
rFragmentShader, const OUString& rGeometryShader = "", const OString& rPreamble 
= "")
 {
     GLint nId;
@@ -473,14 +466,6 @@ bool compiledShaderBinariesWork()
 
 bool WinOpenGLContext::ImplInit()
 {
-    // Failures here typically means that OpenGL can't be used. Returning 
false is fairly pointless
-    // as the calling code doesn't even check, but oh well. If we notice that 
OpenGL is broken the
-    // first time being called, it is not too late to call
-    // disableOpenGLAndTerminateForRestart(). The first time this will be 
called is from displaying
-    // the splash screen, so if OpenGL is broken, it is "early enough" for us 
to be able to disable
-    // OpenGL and terminate bluntly with EXITHELPER_NORMAL_RESTART, thus 
causing the wrapper process
-    // to restart us, then without using OpenGL.
-
     static bool bFirstCall = true;
 
     OpenGLZone aZone;
@@ -539,18 +524,12 @@ bool WinOpenGLContext::ImplInit()
     if (WindowPix == 0)
     {
         SAL_WARN("vcl.opengl", "Invalid pixelformat");
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
     if (!SetPixelFormat(m_aGLWin.hDC, WindowPix, &PixelFormatFront))
     {
         SAL_WARN("vcl.opengl", "SetPixelFormat failed: " << 
WindowsErrorString(GetLastError()));
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
@@ -558,26 +537,19 @@ bool WinOpenGLContext::ImplInit()
     if (hTempRC == nullptr)
     {
         SAL_WARN("vcl.opengl", "wglCreateContext failed: "<< 
WindowsErrorString(GetLastError()));
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
     if (!wglMakeCurrent(m_aGLWin.hDC, hTempRC))
     {
         SAL_WARN("vcl.opengl", "wglMakeCurrent failed: "<< 
WindowsErrorString(GetLastError()));
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
     if (!InitGLEW())
     {
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
+        wglMakeCurrent(NULL, NULL);
+        wglDeleteContext(hTempRC);
         return false;
     }
 
@@ -589,9 +561,6 @@ bool WinOpenGLContext::ImplInit()
     {
         wglMakeCurrent(nullptr, nullptr);
         wglDeleteContext(hTempRC);
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
@@ -610,9 +579,6 @@ bool WinOpenGLContext::ImplInit()
         SAL_WARN("vcl.opengl", "wglCreateContextAttribsARB failed: "<< 
WindowsErrorString(GetLastError()));
         wglMakeCurrent(nullptr, nullptr);
         wglDeleteContext(hTempRC);
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
@@ -620,9 +586,6 @@ bool WinOpenGLContext::ImplInit()
     {
         wglMakeCurrent(nullptr, nullptr);
         wglDeleteContext(hTempRC);
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
@@ -632,9 +595,6 @@ bool WinOpenGLContext::ImplInit()
     if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
     {
         SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << 
WindowsErrorString(GetLastError()));
-        if (bFirstCall)
-            disableOpenGLAndTerminateForRestart();
-        bFirstCall = false;
         return false;
     }
 
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 4d0746f..ccc832f 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -20,6 +20,11 @@
 #include <config_features.h>
 #if HAVE_FEATURE_OPENGL
 #include "openglgdiimpl.hxx"
+#include <opengl/zone.hxx>
+#include <desktop/exithelper.h>
+#ifdef _WIN32
+#include <svsys.h>
+#endif
 #endif
 #include "salgdi.hxx"
 #include "salframe.hxx"
@@ -54,13 +59,37 @@ SalGraphics::SalGraphics()
 SalGraphics::~SalGraphics()
 {
 }
+
 #if HAVE_FEATURE_OPENGL
+
+namespace
+{
+    void disableOpenGLAndTerminateForRestart()
+    {
+        OpenGLZone::hardDisable();
+#ifdef _WIN32
+        TerminateProcess(GetCurrentProcess(), EXITHELPER_NORMAL_RESTART);
+#endif
+    }
+}
+
 rtl::Reference<OpenGLContext> SalGraphics::GetOpenGLContext() const
 {
     OpenGLSalGraphicsImpl *pImpl = 
dynamic_cast<OpenGLSalGraphicsImpl*>(GetImpl());
     if (pImpl)
-        return pImpl->GetOpenGLContext();
-
+    {
+        // If we notice that OpenGL is broken the first time being called, it 
is not too late to call
+        // disableOpenGLAndTerminateForRestart(). The first time this will be 
called is from displaying
+        // the splash screen, so if OpenGL is broken, it is "early enough" for 
us to be able to disable
+        // OpenGL and terminate bluntly with EXITHELPER_NORMAL_RESTART, thus 
causing the wrapper process
+        // to restart us, then without using OpenGL.
+        static bool bFirstCall = true;
+        rtl::Reference<OpenGLContext> xRet(pImpl->GetOpenGLContext());
+        if (!xRet.is() && bFirstCall)
+            disableOpenGLAndTerminateForRestart();
+        bFirstCall = false;
+        return xRet;
+    }
     return nullptr;
 }
 #endif
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to