diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-08-31 21:42:54 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-09-02 22:57:45 +0100 |
commit | 4d841e5f616a117956eaeecf74835efaa5973a7f (patch) | |
tree | 7b85b0ce80dc09c92f9b19ad9fdcd29f80058517 /vcl/workben | |
parent | 16b0e217c1f67948374ff050496e5d4ffb8ceb90 (diff) |
Add another vcldemo OpenGL test to try to catch another Windows nasty.
Change-Id: I43e48617617e89f5aa089ef1487215c5b81c50bc
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/vcldemo.cxx | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 7ff45e02b46b..043c0624523a 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -1660,9 +1660,9 @@ class OpenGLTests OpenGLContext *mpA; OpenGLContext *mpB; - static OpenGLSalGraphicsImpl *getImpl(const VclPtr<WorkWindow> &xWin) + static OpenGLSalGraphicsImpl *getImpl(const VclPtr<WorkWindow> &xOut) { - SalGraphics *pGraphics = xWin->GetGraphics(); + SalGraphics *pGraphics = xOut->GetGraphics(); return dynamic_cast<OpenGLSalGraphicsImpl *>(pGraphics->GetImpl()); } public: @@ -1683,6 +1683,7 @@ public: mpB = mpImplB->GetOpenGLContext(); assert (mpA && mpB); + assert (mpA != mpB); } ~OpenGLTests() { @@ -1698,19 +1699,57 @@ public: { OpenGLTexture aTexture(256,128); pBuffer = mpA->AcquireFramebuffer(aTexture); - pBuffer->DetachTexture(); // TESTME - remove this line too ... } - assert (pBuffer->IsFree()); + assert (pBuffer->IsFree()); (void)pBuffer; mpB->makeCurrent(); assert (mpA->mpCurrentFramebuffer == NULL); } + void testVirtualDevice() + { + fprintf(stderr, "test sharing OpenGLContexts with virtual-devices reference counting\n"); + VclPtrInstance<WorkWindow> xTempWin(nullptr, WB_STDWORK); + xTempWin->Show(); + // forcibly make this context current by rendering + xTempWin->DrawPixel(Point(0, 0), COL_RED); + + // get some other guys to leach off this context + VclPtrInstance<VirtualDevice> xVDev; + OpenGLContext *pContext = getImpl(xVDev)->GetOpenGLContext(); + VclPtrInstance<VirtualDevice> xVDev2; + OpenGLContext *pContext2 = getImpl(xVDev)->GetOpenGLContext(); + + // sharing the same off-screen context. + assert(pContext == pContext2); + assert(pContext == getImpl(xTempWin)->GetOpenGLContext()); + assert(pContext != mpA && pContext != mpB); + (void)pContext; (void)pContext2; + + // Kill the parent we free-ride on ... + xTempWin.disposeAndClear(); + + // This appears to continue working; fun. + Point aPt(0, 0); + xVDev->DrawPixel(aPt, COL_GREEN); + assert(xVDev->GetPixel(aPt) == COL_GREEN); + xVDev.disposeAndClear(); + + // Switch context to see if we can switch back. + mxWinA->DrawPixel(aPt, COL_WHITE); + + // Now try switching back to this guy ... + xVDev2->DrawPixel(aPt, COL_BLUE); + assert(xVDev2->GetPixel(aPt) == COL_BLUE); + xVDev2.disposeAndClear(); + } + int execute() { if (!OpenGLHelper::isVCLOpenGLEnabled()) return 1; testCurrentFramebuffer(); + testVirtualDevice(); return 0; } |