summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-12-08 16:44:19 +0200
committerTor Lillqvist <tml@collabora.com>2016-01-07 06:17:45 +0000
commit342930aaa26ec1a66f432435c7b0f962007b44a8 (patch)
treef9c97ed903abf7f8bd11260013a4cd80a3e07050 /vcl/source
parentf1d55069f1997e40fa20a5251d450eefe9171268 (diff)
vcl: opengl - Kill the last glErrors on common paths.
Re-work the makeSomeOpenGLContextCurrent logic into a shared function with the existing AcquireContext logic in the SalOpenGLGraphics impl. Use an OpenGLVCLContextZone placeholder to do both context and zone management - to include destructors into the zone. Fix a number of error cases around SalBitmaps where we did not have a GL context associated when allocating, and/or freeing textures.. Don't drag a (potentially) slower context around in the OpenGLSalBitmap when we're going to check / fetch a better VCL context anyway. Remove ScaleOp pieces to synchronize with master for maintenance. Change-Id: Ibbb2358c47156cd078ad28b6aad4f03af36aaf23 Reviewed-on: https://gerrit.libreoffice.org/21149 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx38
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx5
2 files changed, 43 insertions, 0 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 771b548f1eb8..80c01732618a 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -31,6 +31,7 @@
#endif
#include "svdata.hxx"
+#include "salgdi.hxx"
#include <opengl/framebuffer.hxx>
#include <opengl/program.hxx>
@@ -1434,6 +1435,43 @@ void OpenGLContext::makeCurrent()
registerAsCurrent();
}
+rtl::Reference<OpenGLContext> OpenGLContext::getVCLContext(bool bMakeIfNecessary)
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ OpenGLContext *pContext = pSVData->maGDIData.mpLastContext;
+ while( pContext )
+ {
+ // check if this context is usable
+ if( pContext->isInitialized() && pContext->isVCLOnly() )
+ break;
+ pContext = pContext->mpPrevContext;
+ }
+ rtl::Reference<OpenGLContext> xContext;
+ if( !pContext && bMakeIfNecessary )
+ {
+ // create our magic fallback window context.
+ xContext = ImplGetDefaultContextWindow()->GetGraphics()->GetOpenGLContext();
+ assert(xContext.is());
+ }
+ else
+ xContext = pContext;
+
+ if( xContext.is() )
+ xContext->makeCurrent();
+
+ return xContext;
+}
+
+/*
+ * We don't care what context we have, but we want one that is live,
+ * ie. not reset underneath us, and is setup for VCL usage - ideally
+ * not swapping context at all.
+ */
+void OpenGLContext::makeVCLCurrent()
+{
+ getVCLContext(true);
+}
+
void OpenGLContext::registerAsCurrent()
{
ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index f1e1660beaaf..ee3e1b6e06ba 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -943,6 +943,11 @@ void OpenGLZone::hardDisable()
}
}
+OpenGLVCLContextZone::OpenGLVCLContextZone()
+{
+ OpenGLContext::makeVCLCurrent();
+}
+
bool OpenGLHelper::isVCLOpenGLEnabled()
{
/**