vcl/workben/vcldemo.cxx | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-)
New commits: commit 4d841e5f616a117956eaeecf74835efaa5973a7f Author: Michael Meeks <michael.me...@collabora.com> Date: Mon Aug 31 21:42:54 2015 +0100 Add another vcldemo OpenGL test to try to catch another Windows nasty. Change-Id: I43e48617617e89f5aa089ef1487215c5b81c50bc diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 7ff45e0..043c062 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits