[Libreoffice-commits] core.git: include/vcl vcl/source
Michael Meeks
michael.meeks at collabora.com
Wed Sep 2 10:37:32 PDT 2015
include/vcl/opengl/OpenGLContext.hxx | 4 ++-
vcl/source/opengl/OpenGLContext.cxx | 11 ++++++++++
vcl/source/opengl/OpenGLHelper.cxx | 38 +++++++++++++++++++++--------------
3 files changed, 37 insertions(+), 16 deletions(-)
New commits:
commit 7164ec07ca50a9faba85cb73bcd8a734d058ec34
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Wed Sep 2 17:28:39 2015 +0100
Don't call GL debugging methods if there is no context.
Change-Id: Ie6b824953b8ad19fd1b6a146cb6bf52bbb152ef7
Reviewed-on: https://gerrit.libreoffice.org/18276
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index cb45973..cf8bd6d 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -208,9 +208,11 @@ public:
OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
+ /// Is this GL context the current context ?
bool isCurrent();
static void clearCurrent();
-
+ /// Is there a current GL context ?
+ static bool hasCurrent();
/// make this GL context current - so it is implicit in subsequent GL calls
void makeCurrent();
/// reset the GL context so this context is not implicit in subsequent GL calls.
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index f3eeb7c..49feb75 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1314,6 +1314,17 @@ bool OpenGLContext::isCurrent()
#endif
}
+bool OpenGLContext::hasCurrent()
+{
+#if defined( WNT )
+ return wglGetCurrentContext() != NULL;
+#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS)
+ return false;
+#elif defined( UNX )
+ return glXGetCurrentContext() != None;
+#endif
+}
+
void OpenGLContext::clearCurrent()
{
ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 4065ce0..6019850 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -32,6 +32,7 @@
#include "opengl/zone.hxx"
#include "opengl/watchdog.hxx"
#include <osl/conditn.h>
+#include <vcl/opengl/OpenGLContext.hxx>
#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
#include "opengl/x11/X11DeviceInfo.hxx"
@@ -686,29 +687,36 @@ void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...)
va_list aArgs;
va_start (aArgs, pFormat);
- char pStr[1024];
+ char pStr[1044];
#ifdef _WIN32
#define vsnprintf _vsnprintf
#endif
vsnprintf(pStr, sizeof(pStr), pFormat, aArgs);
- pStr[sizeof(pStr)-1] = '\0';
+ pStr[sizeof(pStr)-20] = '\0';
+
+ bool bHasContext = !OpenGLContext::hasCurrent();
+ if (!bHasContext)
+ strcat(pStr, "- no GL context");
SAL_INFO(pArea, pStr);
- OpenGLZone aZone;
+ if (bHasContext)
+ {
+ OpenGLZone aZone;
- if (GLEW_KHR_debug)
- glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
- GL_DEBUG_TYPE_OTHER,
- 1, // one[sic] id is as good as another ?
- // GL_DEBUG_SEVERITY_NOTIFICATION for >= GL4.3 ?
- GL_DEBUG_SEVERITY_LOW,
- strlen(pStr), pStr);
- else if (GLEW_AMD_debug_output)
- glDebugMessageInsertAMD(GL_DEBUG_CATEGORY_APPLICATION_AMD,
- GL_DEBUG_SEVERITY_LOW_AMD,
- 1, // one[sic] id is as good as another ?
- strlen(pStr), pStr);
+ if (GLEW_KHR_debug)
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
+ GL_DEBUG_TYPE_OTHER,
+ 1, // one[sic] id is as good as another ?
+ // GL_DEBUG_SEVERITY_NOTIFICATION for >= GL4.3 ?
+ GL_DEBUG_SEVERITY_LOW,
+ strlen(pStr), pStr);
+ else if (GLEW_AMD_debug_output)
+ glDebugMessageInsertAMD(GL_DEBUG_CATEGORY_APPLICATION_AMD,
+ GL_DEBUG_SEVERITY_LOW_AMD,
+ 1, // one[sic] id is as good as another ?
+ strlen(pStr), pStr);
+ }
va_end (aArgs);
}
More information about the Libreoffice-commits
mailing list