diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-08-29 23:15:54 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-08-31 19:48:14 +0000 |
commit | b27b9084c5b55f6cf6732fb9bdc253658ea612ea (patch) | |
tree | a7e4cad084a1e948a7c9cf1595f040edc0179e1f /vcl/workben | |
parent | 1ba1a21aa6b77ef8d3d59b3658dfd2aa87d0dee2 (diff) |
tdf#93772 - handle framebuffer unbinding on GL context switch.
Also start gl tests in vcldemo:
$ SAL_FORCEGL=1 vcldemo --gltests
Change-Id: I8f0022770d57cd60c830659e3f7fcc0721320a10
Reviewed-on: https://gerrit.libreoffice.org/18132
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/vcldemo.cxx | 86 |
1 files changed, 84 insertions, 2 deletions
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 9218afde7e6c..417d69fded8e 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -44,6 +44,14 @@ #include <vcldemo-debug.hxx> #include <opengl/zone.hxx> +// internal headers for OpenGLTests class. +#include "salgdi.hxx" +#include "salframe.hxx" +#include "openglgdiimpl.hxx" +#include "opengl/texture.hxx" +#include "opengl/framebuffer.hxx" +#include <vcl/opengl/OpenGLHelper.hxx> + #include <rtl/math.hxx> #define FIXME_SELF_INTERSECTING_WORKING 0 @@ -1643,6 +1651,71 @@ class DemoPopup : public FloatingWindow } }; +class OpenGLTests +{ + VclPtr<WorkWindow> mxWinA; + VclPtr<WorkWindow> mxWinB; + OpenGLSalGraphicsImpl *mpImplA; + OpenGLSalGraphicsImpl *mpImplB; + OpenGLContext *mpA; + OpenGLContext *mpB; + + OpenGLSalGraphicsImpl *getImpl(const VclPtr<WorkWindow> &xWin) + { + SalGraphics *pGraphics = xWin->GetGraphics(); + return dynamic_cast<OpenGLSalGraphicsImpl *>(pGraphics->GetImpl()); + } +public: + OpenGLTests() : + mxWinA(VclPtr<WorkWindow>::Create(nullptr, WB_APP | WB_STDWORK)), + mxWinB(VclPtr<WorkWindow>::Create(nullptr, WB_APP | WB_STDWORK)) + { + if (!OpenGLHelper::isVCLOpenGLEnabled()) + { + fprintf (stderr, "OpenGL is not enabled: try SAL_FORCEGL=1\n"); + return; + } + + mpImplA = getImpl(mxWinA); + mpImplB = getImpl(mxWinB); + assert (mpImplA && mpImplB); + mpA = mpImplA->GetOpenGLContext(); + mpB = mpImplB->GetOpenGLContext(); + + assert (mpA && mpB); + } + ~OpenGLTests() + { + mxWinB.disposeAndClear(); + mxWinA.disposeAndClear(); + } + + void testCurrentFramebuffer() + { + fprintf(stderr,"test OpenGLContext's framebuffer association.\n"); + mpA->makeCurrent(); + OpenGLFramebuffer *pBuffer; + { + OpenGLTexture aTexture(256,128); + pBuffer = mpA->AcquireFramebuffer(aTexture); + pBuffer->DetachTexture(); // TESTME - remove this line too ... + } + assert (pBuffer->IsFree()); + mpB->makeCurrent(); + assert (mpA->mpCurrentFramebuffer == NULL); + } + + int execute() + { + if (!OpenGLHelper::isVCLOpenGLEnabled()) + return 1; + + testCurrentFramebuffer(); + + return 0; + } +}; + class DemoApp : public Application { static int showHelp(DemoRenderer &rRenderer) @@ -1656,6 +1729,7 @@ class DemoApp : public Application fprintf(stderr," --test <iterCount> - create benchmark data\n"); fprintf(stderr," --widgets - launch the widget test.\n"); fprintf(stderr," --threads - render from multiple threads.\n"); + fprintf(stderr," --gltest - run openGL regression tests.\n"); fprintf(stderr, "\n"); return 0; } @@ -1667,7 +1741,8 @@ public: { try { - bool bWidgets = false, bThreads = false, bPopup = false; + bool bWidgets = false, bThreads = false; + bool bPopup = false, bGLTest = false; DemoRenderer aRenderer; for (sal_Int32 i = 0; i < GetCommandLineParamCount(); i++) @@ -1694,6 +1769,8 @@ public: bWidgets = true; else if (aArg == "--popup") bPopup = true; + else if (aArg == "--gltest") + bGLTest = true; else if (aArg == "--threads") bThreads = true; else if (aArg.startsWith("--")) @@ -1710,7 +1787,12 @@ public: aMainWin->SetText("Interactive VCL demo #1"); - if (bWidgets) + if (bGLTest) + { + OpenGLTests aTests; + return aTests.execute(); + } + else if (bWidgets) xWidgets = VclPtr< DemoWidgets >::Create (); else if (bPopup) xPopup = VclPtrInstance< DemoPopup> (); |