summaryrefslogtreecommitdiff
path: root/vcl/source/opengl
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-16 09:17:37 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-09-16 09:50:43 +0000
commitbfceb557efcd607ef018ae35fc73f8d61a9b9a4e (patch)
tree7f46254e93f12bc3b96cb49fa52afa97a855c2e3 /vcl/source/opengl
parent4af40495b7dcdac3add67c634dde75c896e370d9 (diff)
GL paint-flushing guard re-work.
Unfortunately, since we can have 2x SalGraphics' on a OutputDevice, and one of these can be a printer - things got very confused around which context to glFlush. This de-tangles the various reference-counts. Change-Id: I1062be0b02a91fc9009deaa3ec29c5dbb227df20 Reviewed-on: https://gerrit.libreoffice.org/18604 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/source/opengl')
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx46
1 files changed, 45 insertions, 1 deletions
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 5d4b8f77a9c1..114251ce24f4 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -32,7 +32,7 @@
#include <unordered_map>
#include "svdata.hxx"
-
+#include "salgdi.hxx"
#include "salinst.hxx"
#include "opengl/zone.hxx"
#include "opengl/watchdog.hxx"
@@ -1070,4 +1070,48 @@ GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted
#endif
+OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
+ : pHandle( NULL )
+{
+ if( pDev->mpGraphics || pDev->AcquireGraphics() )
+ {
+ OpenGLContext *pContext = pDev->mpGraphics->BeginPaint();
+ if( pContext )
+ {
+ assert( pContext->mnPainting >= 0 );
+ pContext->mnPainting++;
+ pContext->acquire();
+ pHandle = static_cast<void *>( pContext );
+ }
+ }
+}
+
+/**
+ * Flush all the queued rendering commands to the screen for this context.
+ */
+void OutputDevice::PaintScope::flush()
+{
+ if( pHandle )
+ {
+ OpenGLContext *pContext = static_cast<OpenGLContext *>( pHandle );
+ pHandle = NULL;
+ pContext->mnPainting--;
+ assert( pContext->mnPainting >= 0 );
+ if( pContext->mnPainting == 0 )
+ {
+ pContext->makeCurrent();
+ pContext->AcquireDefaultFramebuffer();
+ glFlush();
+ pContext->swapBuffers();
+ CHECK_GL_ERROR();
+ }
+ pContext->release();
+ }
+}
+
+OutputDevice::PaintScope::~PaintScope()
+{
+ flush();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */