[Libreoffice-commits] core.git: vcl/opengl vcl/source
Caolán McNamara
caolanm at redhat.com
Fri Dec 9 13:07:56 UTC 2016
vcl/opengl/win/gdiimpl.cxx | 43 +---------------------------------------
vcl/source/gdi/salgdilayout.cxx | 33 ++++++++++++++++++++++++++++--
2 files changed, 33 insertions(+), 43 deletions(-)
New commits:
commit d96686e482d2f2649dbd87d7ed9db2775e5d22f5
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Dec 8 14:16:41 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
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 <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 483a233..1704a19 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,13 +466,6 @@ bool compiledShaderBinariesWork()
bool WinOpenGLContext::ImplInit()
{
- // Failures here typically means that OpenGL can't be used.
- // 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;
@@ -538,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;
}
@@ -557,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;
}
@@ -588,9 +561,6 @@ bool WinOpenGLContext::ImplInit()
{
wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(hTempRC);
- if (bFirstCall)
- disableOpenGLAndTerminateForRestart();
- bFirstCall = false;
return false;
}
@@ -609,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;
}
@@ -619,9 +586,6 @@ bool WinOpenGLContext::ImplInit()
{
wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(hTempRC);
- if (bFirstCall)
- disableOpenGLAndTerminateForRestart();
- bFirstCall = false;
return false;
}
@@ -631,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 28e19b0..f16d513 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
More information about the Libreoffice-commits
mailing list