[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx vcl/win

Michael Meeks michael.meeks at collabora.com
Mon Nov 10 08:50:39 PST 2014


 include/vcl/opengl/OpenGLHelper.hxx |    5 +++++
 vcl/source/opengl/OpenGLHelper.cxx  |   17 +++++++++++++++--
 vcl/unx/generic/gdi/salbmp.cxx      |    5 +----
 vcl/unx/generic/gdi/salgdi.cxx      |    6 +-----
 vcl/win/source/gdi/salgdi.cxx       |    4 +---
 5 files changed, 23 insertions(+), 14 deletions(-)

New commits:
commit 45c6cb5f083934f311561599d34ce771bbabf835
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 10 16:02:31 2014 +0000

    vcl: cleanup the opengl selection API.
    
    Change-Id: Icebf3c7d2911b27e29d2259b780a04048b293b3c

diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index d49f579..ee5a9f8 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -58,6 +58,11 @@ public:
      */
     static bool supportsVCLOpenGL();
 
+    /**
+     * Returns true if VCL has OpenGL rendering enabled
+     */
+    static bool isVCLOpenGLEnabled();
+
 #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
     static bool GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI);
     static GLXFBConfig GetPixmapFBConfig( Display* pDisplay, bool& bInverted );
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 5823b80..d9f445d 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -18,6 +18,7 @@
 #include <boost/scoped_array.hpp>
 #include <vcl/pngwrite.hxx>
 #include <vcl/graph.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <vector>
 
@@ -360,8 +361,20 @@ void OpenGLHelper::checkGLError(const char* pFile, size_t nLine)
 
 bool OpenGLHelper::supportsVCLOpenGL()
 {
-    static bool bDisableGL = !getenv("SAL_DISABLEGL");
-    return bDisableGL;
+    static bool bDisableGL = !!getenv("SAL_DISABLEGL");
+
+    if (bDisableGL)
+        return false;
+    else
+        return true;
+}
+
+bool OpenGLHelper::isVCLOpenGLEnabled()
+{
+    if (!supportsVCLOpenGL())
+        return false;
+    bool bEnable = officecfg::Office::Common::VCL::UseOpenGL::get();
+    return bEnable;
 }
 
 #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 6b2042c..f36795a 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -45,7 +45,6 @@
 
 #include <opengl/salbmp.hxx>
 #include <vcl/opengl/OpenGLHelper.hxx>
-#include <officecfg/Office/Common.hxx>
 
 #if defined HAVE_VALGRIND_HEADERS
 #include <valgrind/memcheck.h>
@@ -57,9 +56,7 @@
 
 SalBitmap* X11SalInstance::CreateSalBitmap()
 {
-    static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
-    bool bUseOpenGL = bOpenGLPossible ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
-    if (bUseOpenGL)
+    if (OpenGLHelper::isVCLOpenGLEnabled())
         return new OpenGLSalBitmap();
     else
         return new X11SalBitmap();
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 47b20bc..9609ec8 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -62,8 +62,6 @@
 #include "generic/printergfx.hxx"
 #include "xrender_peer.hxx"
 
-#include <officecfg/Office/Common.hxx>
-
 #include <vcl/opengl/OpenGLHelper.hxx>
 
 X11SalGraphics::X11SalGraphics():
@@ -84,9 +82,7 @@ X11SalGraphics::X11SalGraphics():
     bPrinter_(false),
     bVirDev_(false)
 {
-    static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
-    bool bUseOpenGL = bOpenGLPossible ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
-    if (bUseOpenGL)
+    if (OpenGLHelper::isVCLOpenGLEnabled())
     {
         mpImpl.reset(new X11OpenGLSalGraphicsImpl(*this));
         mpTextRenderImpl.reset((new OpenGLX11CairoTextRender(false, *this)));
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 4e3b76f..549a02f 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -589,9 +589,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
     mbFontKernInit(false),
     mnPenWidth(GSL_PEN_WIDTH)
 {
-    static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
-    bool bUseOpenGL = bOpenGLPossible && mbWindow ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
-    if (bUseOpenGL)
+    if (OpenGLHelper::isVCLOpenGLEnabled())
         mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
     else
         mpImpl.reset(new WinSalGraphicsImpl(*this));


More information about the Libreoffice-commits mailing list