[Libreoffice-commits] core.git: Branch 'private/mmeeks/opengl-backbuffer' - 93 commits - accessibility/inc accessibility/source animations/source avmedia/source basctl/inc basctl/source basegfx/inc basegfx/source basic/inc bin/lo-all-static-libs bin/rename-sw-abbreviations.sh bin/update_pch bin/update_pch_autotune.sh bin/update_pch_bisect bin/update_pch.sh bridges/test canvas/source chart2/inc chart2/source comphelper/inc comphelper/source compilerplugins/clang configmgr/inc configure.ac connectivity/inc connectivity/source cppcanvas/inc cppuhelper/inc cppuhelper/qa cppuhelper/source cppuhelper/test cui/inc cui/source cui/uiconfig dbaccess/inc dbaccess/source desktop/CppunitTest_desktop_lib.mk desktop/inc desktop/qa desktop/source download.lst drawinglayer/inc dtrans/source editeng/inc embeddedobj/test embedserv/source extensions/Library_updatecheckui.mk extensions/Library_updatefeed.mk extensions/Library_updchk.mk extensions/source extensions/test external/cairo external/libpng external/poppler filter/source forms/inc forms/source formula/source fpicker/source framework/inc framework/source .gitignore helpcompiler/source helpcontent2 hwpfilter/inc hwpfilter/source i18npool/source include/connectivity include/formula include/sfx2 include/svx include/ucbhelper include/vcl io/source io/test l10ntools/inc l10ntools/source libreofficekit/qa lingucomponent/source linguistic/source linguistic/workben lotuswordpro/inc odk/examples officecfg/registry oox/inc oox/source package/inc package/source remotebridges/source reportdesign/inc reportdesign/source RepositoryExternal.mk sal/inc sax/source sax/test sccomp/source sc/inc sc/qa scripting/source sc/source sdext/inc sdext/source sd/inc sd/source sfx2/inc sfx2/Library_sfx.mk sfx2/source shell/source slideshow/inc sot/inc sot/source starmath/inc stoc/source svgio/inc svl/inc svl/source svtools/inc svtools/source svx/inc svx/sdi svx/source sw/inc sw/Library_sw.mk sw/Module_sw.mk sw/qa sw/sdi sw/source sw/uiconfig testtools/source toolki t/source tools/inc ucbhelper/source ucb/source UnoControls/source unotools/inc unotools/source unoxml/inc unoxml/source uui/inc uui/source vbahelper/inc vbahelper/source vcl/android vcl/Executable_xid_fullscreen_on_all_monitors.mk vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_gtk3.mk vcl/Library_vclplug_gtk.mk vcl/opengl vcl/source vcl/unx vcl/win vcl/workben winaccessibility/source wizards/source writerfilter/inc writerfilter/source writerperfect/source xmlhelp/source xmloff/inc xmloff/source xmlscript/inc xmlscript/source xmlsecurity/inc xmlsecurity/source

Michael Meeks michael.meeks at collabora.com
Mon Nov 16 10:10:20 PST 2015


Rebased ref, commits from common ancestor:
commit a444aa3fff21b69ca20ae3218882ce170d07f04a
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 18:18:36 2015 +0000

    Get Double-buffered context creation working on linux.
    
    Change-Id: I3db1d6792fcd51577f047b82029124ec825ea319

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 8a083a1..0b51fac 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -166,6 +166,7 @@ void OpenGLSalGraphicsImpl::DeInit()
     // get a shiny new context in AcquireContext:: next PreDraw.
     if( mpContext.is() && !IsOffscreen() )
         mpContext->reset();
+    mpContext.clear();
 }
 
 void OpenGLSalGraphicsImpl::PreDraw()
@@ -1950,7 +1951,6 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
     glViewport( 0, 0, GetWidth(), GetHeight() );
     CHECK_GL_ERROR();
 
-    glDrawBuffer(GL_BACK);
     glClearColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX,
                  (float)rand()/RAND_MAX, 1.0);
     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
@@ -1962,50 +1962,54 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     OpenGLProgram *pProgram =
         mpWindowContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
-    pProgram->Use(); // FIXME: paranoia ...
-    VCL_GL_INFO( "vcl.opengl", "done paranoid re-use." );
-    pProgram->SetTexture( "sampler", maOffscreenTex );
-    maOffscreenTex.Bind(); // FIXME: paranoia ...
+    if( !pProgram )
+        VCL_GL_INFO( "vcl.opengl", "Can't compile simple copying shader !" );
+    else
+    {
+        pProgram->Use(); // FIXME: paranoia ...
+        VCL_GL_INFO( "vcl.opengl", "done paranoid re-use." );
+        pProgram->SetTexture( "sampler", maOffscreenTex );
+        maOffscreenTex.Bind(); // FIXME: paranoia ...
 
-    VCL_GL_INFO( "vcl.opengl", "bound bits etc." );
+        VCL_GL_INFO( "vcl.opengl", "bound bits etc." );
 
-    GLfloat aTexCoord[8];
-    maOffscreenTex.GetCoord( aTexCoord, aPosAry, false );
-    pProgram->SetTextureCoord( aTexCoord );
+        GLfloat aTexCoord[8];
+        maOffscreenTex.GetCoord( aTexCoord, aPosAry, false );
+        pProgram->SetTextureCoord( aTexCoord );
 
-    long nX1( aPosAry.mnDestX );
-    long nY1( aPosAry.mnDestY );
-    long nX2( nX1 + aPosAry.mnDestWidth );
-    long nY2( nY1 + aPosAry.mnDestHeight );
-    const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
-                                 { nX2, nY1 }, { nX2, nY2 }};
+        long nX1( aPosAry.mnDestX );
+        long nY1( aPosAry.mnDestY );
+        long nX2( nX1 + aPosAry.mnDestWidth );
+        long nY2( nY1 + aPosAry.mnDestHeight );
+        const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
+                                     { nX2, nY1 }, { nX2, nY2 }};
 
-    sal_uInt32 nPoints = 4;
-    std::vector<GLfloat> aVertices(nPoints * 2);
-    sal_uInt32 i, j;
+        sal_uInt32 nPoints = 4;
+        std::vector<GLfloat> aVertices(nPoints * 2);
+        sal_uInt32 i, j;
 
-    for( i = 0, j = 0; i < nPoints; i++, j += 2 )
-    {
-        aVertices[j]   = GLfloat(aPoints[i].mnX);
-        aVertices[j+1] = GLfloat(aPoints[i].mnY);
-    }
+        for( i = 0, j = 0; i < nPoints; i++, j += 2 )
+        {
+            aVertices[j]   = GLfloat(aPoints[i].mnX);
+            aVertices[j+1] = GLfloat(aPoints[i].mnY);
+        }
 
-    pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
-    pProgram->SetVertices( &aVertices[0] );
-    if (!getenv("NO_COPY"))
-        glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+        pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
+        pProgram->SetVertices( &aVertices[0] );
+        if (!getenv("NO_COPY"))
+            glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
 
-    pProgram->Clean();
+        pProgram->Clean();
 
-    glBindTexture( GL_TEXTURE_2D, 0 );
+        glBindTexture( GL_TEXTURE_2D, 0 );
 
-    if (!getenv("NO_SWAP"))
-    {
-        mpWindowContext->swapBuffers();
-        if (!getenv("NO_SLEEP"))
-            usleep(500 * 1000);
+        if (!getenv("NO_SWAP"))
+        {
+            mpWindowContext->swapBuffers();
+            if (!getenv("NO_SLEEP"))
+                usleep(500 * 1000);
+        }
     }
-
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap - end." );
 }
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 7b81e66..e94e726 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -701,9 +701,7 @@ bool GLWindow::HasGLXExtension( const char* name ) const
 bool OpenGLContext::ImplInit()
 {
     if (!m_aGLWin.dpy)
-    {
         return false;
-    }
 
     OpenGLZone aZone;
 
@@ -717,11 +715,10 @@ bool OpenGLContext::ImplInit()
     if (!g_vShareList.empty())
         pSharedCtx = g_vShareList.front();
 
-#ifdef DBG_UTIL
     if (glXCreateContextAttribsARB && !mbRequestLegacyContext)
     {
         int best_fbc = -1;
-        GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc, mbUseDoubleBufferedRendering, true);
+        GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc, mbUseDoubleBufferedRendering, false);
         if (!pFBC)
             return false;
 
@@ -729,24 +726,28 @@ bool OpenGLContext::ImplInit()
         {
             int pContextAttribs[] =
             {
+#if 0 // defined(DBG_UTIL)
                 GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
                 GLX_CONTEXT_MINOR_VERSION_ARB, 2,
+#endif
                 None
+
             };
             m_aGLWin.ctx = glXCreateContextAttribsARB(m_aGLWin.dpy, pFBC[best_fbc], pSharedCtx, /* direct, not via X */ GL_TRUE, pContextAttribs);
             SAL_INFO_IF(m_aGLWin.ctx, "vcl.opengl", "created a 3.2 core context");
         }
         else
             SAL_WARN("vcl.opengl", "unable to find correct FBC");
-
     }
-#endif
 
     if (!m_aGLWin.ctx)
     {
         if (!m_aGLWin.vi)
            return false;
 
+        SAL_WARN("vcl.opengl", "attempting to create a non-double-buffered "
+                               "visual matching the context");
+
         m_aGLWin.ctx = glXCreateContext(m_aGLWin.dpy,
                 m_aGLWin.vi,
                 pSharedCtx,
commit a314a63469c44f42cf59a7882d72a5508465ac23
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 18:18:10 2015 +0000

    Attempt to get text wrapping on the UserAgent rendering
    
    Change-Id: Iec3a68d75bfe124f0c10f190ed84fd6858c4b5f5

diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index 174825c..496be01 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -82,6 +82,9 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt
     m_aLastCheckedTemplate = m_pLastChecked->GetText();
     m_aUserAgentTemplate = m_pUserAgentLabel->GetText();
 
+    m_pUserAgentLabel->SetStyle(
+        (m_pUserAgentLabel->GetStyle() | WB_WORDBREAK) & ~WB_NOMULTILINE );
+
     UpdateLastCheckedText();
     UpdateUserAgent();
 }
commit 782d4b5eef3733d53bac2a200a0063cea47b8bda
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 13:42:28 2015 +0000

    Try to de-bong horrors around vdev creation.
    
    This used to create multiple GL Contexts' for the same drawable [!]
    And then release them again, etc. a flicker frenzy for vdevs.
    
    Change-Id: Ia2d79fea3db6ded75e278b8dda80da7d91186c8e

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 0e83d4f..8a083a1 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -121,6 +121,11 @@ bool OpenGLSalGraphicsImpl::ReleaseContext()
 
 void OpenGLSalGraphicsImpl::Init()
 {
+    // Our init phase is strange ::Init is called twice for vdevs.
+    // the first time around with a NULL geometry provider.
+    if( !mpProvider )
+        return;
+
     // check if we can simply re-use the same context
     if( mpContext.is() )
     {
@@ -142,11 +147,12 @@ void OpenGLSalGraphicsImpl::Init()
         VCL_GL_INFO("vcl.opengl", "::Init - re-size offscreen texture");
     }
 
-    if( mpWindowContext.is() )
-        mpWindowContext->reset();
-
     if( !IsOffscreen() )
+    {
+        if( mpWindowContext.is() )
+            mpWindowContext->reset();
         mpWindowContext = CreateWinContext();
+    }
 }
 
 // Currently only used to get windows ordering right.
@@ -201,6 +207,11 @@ void OpenGLSalGraphicsImpl::PostDraw()
 
     assert (maOffscreenTex);
 
+    if( IsOffscreen() )
+        assert( !mpWindowContext.is() );
+    else
+        assert( mpWindowContext.is() );
+
     if( mpContext->mnPainting == 0 )
     {
         if (!IsOffscreen())
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 6f2c9f5..8ddc745 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -156,6 +156,7 @@ void X11SalGraphics::SetDrawable( Drawable aDrawable, SalX11Screen nXScreen )
     // TODO: moggi: FIXME nTextPixel_     = GetPixel( nTextColor_ );
 }
 
+// Initialize the SalGraphics, if @pFrame is NULL - this is a vdev.
 void X11SalGraphics::Init( SalFrame *pFrame, Drawable aTarget,
                            SalX11Screen nXScreen )
 {
@@ -165,8 +166,8 @@ void X11SalGraphics::Init( SalFrame *pFrame, Drawable aTarget,
     m_pFrame    = pFrame;
     m_pVDev     = nullptr;
 
-    bWindow_    = true;
-    bVirDev_    = false;
+    bWindow_    = pFrame;
+    bVirDev_    = !pFrame;
 
     SetDrawable( aTarget, nXScreen );
     mxImpl->Init();
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index eeb75de..dd4b8e9 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -328,7 +328,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
     GtkSalGraphics *pGtkSalGraphics = dynamic_cast<GtkSalGraphics*>(pG);
     assert(pGtkSalGraphics);
     return CreateX11VirtualDevice(pG, nDX, nDY, nBitCount, pGd,
-            new GtkSalGraphics(pGtkSalGraphics->GetGtkFrame(), pGtkSalGraphics->GetGtkWidget()));
+            new GtkSalGraphics(NULL, pGtkSalGraphics->GetGtkWidget()));
 #endif
 }
 
commit 2860e8da613f2c80f49d018f946b8a92b48b0682
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 12:21:47 2015 +0000

    More debugging work; potentially multiple contexts created for same window.
    
    Change-Id: Ibb785f87122980bbc259590c193bbf01e64a285b

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 49a8ee1..0e83d4f 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -144,7 +144,9 @@ void OpenGLSalGraphicsImpl::Init()
 
     if( mpWindowContext.is() )
         mpWindowContext->reset();
-    mpWindowContext = CreateWinContext();
+
+    if( !IsOffscreen() )
+        mpWindowContext = CreateWinContext();
 }
 
 // Currently only used to get windows ordering right.
@@ -197,6 +199,8 @@ void OpenGLSalGraphicsImpl::PostDraw()
 #endif
     }
 
+    assert (maOffscreenTex);
+
     if( mpContext->mnPainting == 0 )
     {
         if (!IsOffscreen())
@@ -375,8 +379,22 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
 
     VCL_GL_INFO( "vcl.opengl", "Check Offscreen texture" );
 
+    // Always create the offscreen texture
+    if( maOffscreenTex )
+    {
+        if( maOffscreenTex.GetWidth()  != GetWidth() ||
+            maOffscreenTex.GetHeight() != GetHeight() )
+        {
+            mpContext->ReleaseFramebuffer( maOffscreenTex );
+            maOffscreenTex = OpenGLTexture();
+            VCL_GL_INFO( "vcl.opengl", "re-size offscreen texture" );
+        }
+    }
+
     if( !maOffscreenTex )
     {
+        VCL_GL_INFO( "vcl.opengl", "create texture of size "
+                     << GetWidth() << " x " << GetHeight() );
         maOffscreenTex = OpenGLTexture( GetWidth(), GetHeight() );
         bClearTexture = true;
     }
@@ -401,8 +419,8 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
         if( bClearTexture )
         {
             glDrawBuffer( GL_COLOR_ATTACHMENT0 );
-            GLuint clearColor[4] = { 0, 0, 0, 0 };
-            glClearBufferuiv( GL_COLOR, 0, clearColor );
+            GLfloat clearColor[4] = { 1.0, 0, 0, 0 };
+            glClearBufferfv( GL_COLOR, 0, clearColor );
             // FIXME: use glClearTexImage if we have it ?
         }
     }
@@ -1888,6 +1906,7 @@ OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
 void OpenGLSalGraphicsImpl::flushAndSwap()
 {
     assert( !IsOffscreen() );
+    assert( mpWindowContext.is() );
     assert( mpContext.is() );
 
     if( !maOffscreenTex )
@@ -1900,7 +1919,6 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap" );
 
-    glFlush();
     // Interesting ! -> this destroys a context [ somehow ] ...
     mpWindowContext->makeCurrent();
     CHECK_GL_ERROR();
@@ -1921,6 +1939,7 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
     glViewport( 0, 0, GetWidth(), GetHeight() );
     CHECK_GL_ERROR();
 
+    glDrawBuffer(GL_BACK);
     glClearColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX,
                  (float)rand()/RAND_MAX, 1.0);
     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
@@ -1928,6 +1947,7 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     SalTwoRect aPosAry( 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
                         0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight() );
+    VCL_GL_INFO( "vcl.opengl", "Texture height " << maOffscreenTex.GetHeight() << " vs. window height " << GetHeight() );
 
     OpenGLProgram *pProgram =
         mpWindowContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
@@ -1970,16 +1990,11 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     if (!getenv("NO_SWAP"))
     {
-        glFlush();
         mpWindowContext->swapBuffers();
-        glFlush();
         if (!getenv("NO_SLEEP"))
-            usleep(500000);
+            usleep(500 * 1000);
     }
 
-    // Should get a more sensible context (this one) next time.
-    mpContext.clear();
-
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap - end." );
 }
 
commit 9f74b1f93c9b929b50757db5000e244eae5f0193
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 09:52:53 2015 +0000

    Revert "OpenGL error codes are defined in hex, so show them as such"
    
    This reverts commit 38357ee010e9f22bc00080e603880cf82c74da48.

diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 945b662..3bce96f 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -695,10 +695,11 @@ void OpenGLHelper::checkGLError(const char* pFile, size_t nLine)
             break;
         }
         const char* sError = OpenGLHelper::GLErrorString(glErr);
-        if (!sError)
-            sError = "no message available";
 
-        SAL_WARN("vcl.opengl", "GL Error " << std::hex << std::setw(4) << std::setfill('0') << glErr << std::dec << std::setw(0) << std::setfill(' ') << " (" << sError << ") in file " << pFile << " at line " << nLine);
+        if (sError)
+            SAL_WARN("vcl.opengl", "GL Error #" << glErr << "(" << sError << ") in File " << pFile << " at line: " << nLine);
+        else
+            SAL_WARN("vcl.opengl", "GL Error #" << glErr << " (no message available) in File " << pFile << " at line: " << nLine);
 
         // tdf#93798 - apitrace appears to sometimes cause issues with an infinite loop here.
         if (++nErrors >= 8)
commit b9fa5ea368ff3b90d980d23b1ec79ff136ecc026
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Nov 14 22:11:26 2015 +0000

    Cleanup while reading extensions.
    
    Change-Id: I99c630c2b497b695365728ce5a2497ff64ff9f1a

diff --git a/extensions/Library_updatecheckui.mk b/extensions/Library_updatecheckui.mk
index 75d0f66..2b98794 100644
--- a/extensions/Library_updatecheckui.mk
+++ b/extensions/Library_updatecheckui.mk
@@ -1,13 +1,11 @@
 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
 #
-#
 # This file is part of the LibreOffice project.
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#
 
 $(eval $(call gb_Library_Library,updatecheckui))
 
diff --git a/extensions/Library_updatefeed.mk b/extensions/Library_updatefeed.mk
index 0024240..5c5a5cb 100644
--- a/extensions/Library_updatefeed.mk
+++ b/extensions/Library_updatefeed.mk
@@ -1,13 +1,11 @@
 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
 #
-#
 # This file is part of the LibreOffice project.
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#
 
 $(eval $(call gb_Library_Library,updatefeed))
 
diff --git a/extensions/Library_updchk.mk b/extensions/Library_updchk.mk
index c7299d3..7647805 100644
--- a/extensions/Library_updchk.mk
+++ b/extensions/Library_updchk.mk
@@ -1,13 +1,11 @@
 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
 #
-#
 # This file is part of the LibreOffice project.
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#
 
 $(eval $(call gb_Library_Library,updchk))
 
diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx
index f0254c5..60aa6a7 100644
--- a/extensions/source/update/check/updatecheckconfig.cxx
+++ b/extensions/source/update/check/updatecheckconfig.cxx
@@ -80,14 +80,10 @@ static const sal_Char * const aUpdateEntryProperties[] = {
 
 static const sal_uInt32 nUpdateEntryProperties = SAL_N_ELEMENTS(aUpdateEntryProperties);
 
-
-
 NamedValueByNameAccess::~NamedValueByNameAccess()
 {
 }
 
-
-
 css::uno::Any NamedValueByNameAccess::getValue(const sal_Char * pName)
 {
     const sal_Int32 nLen = m_rValues.getLength();
@@ -99,25 +95,18 @@ css::uno::Any NamedValueByNameAccess::getValue(const sal_Char * pName)
     return css::uno::Any();
 }
 
-
-
-
 bool
 UpdateCheckROModel::isAutoCheckEnabled() const
 {
     return m_aNameAccess.getValue(AUTOCHECK_ENABLED).get<bool>();
 }
 
-
-
 bool
 UpdateCheckROModel::isDownloadPaused() const
 {
     return m_aNameAccess.getValue(DOWNLOAD_PAUSED).get<bool>();
 }
 
-
-
 OUString
 UpdateCheckROModel::getStringValue(const sal_Char * pStr) const
 {
@@ -129,15 +118,11 @@ UpdateCheckROModel::getStringValue(const sal_Char * pStr) const
     return aRet;
 }
 
-
-
 OUString UpdateCheckROModel::getLocalFileName() const
 {
     return getStringValue(LOCAL_FILE);
 };
 
-
-
 sal_Int64 UpdateCheckROModel::getDownloadSize() const
 {
     uno::Any aAny( m_aNameAccess.getValue(DOWNLOAD_SIZE) );
@@ -147,16 +132,12 @@ sal_Int64 UpdateCheckROModel::getDownloadSize() const
     return nRet;
 };
 
-
-
 OUString
 UpdateCheckROModel::getUpdateEntryVersion() const
 {
     return getStringValue(OLD_VERSION);
 }
 
-
-
 void
 UpdateCheckROModel::getUpdateEntry(UpdateInfo& rInfo) const
 {
@@ -179,9 +160,6 @@ UpdateCheckROModel::getUpdateEntry(UpdateInfo& rInfo) const
     }
 }
 
-
-
-
 OUString UpdateCheckConfig::getDesktopDirectory()
 {
     OUString aRet;
@@ -209,8 +187,6 @@ OUString UpdateCheckConfig::getDesktopDirectory()
     return aRet;
 }
 
-
-
 OUString UpdateCheckConfig::getAllUsersDirectory()
 {
     OUString aRet;
@@ -230,7 +206,6 @@ OUString UpdateCheckConfig::getAllUsersDirectory()
     return aRet;
 }
 
-
 UpdateCheckConfig::UpdateCheckConfig( const uno::Reference<container::XNameContainer>& xContainer,
                                       const uno::Reference<container::XNameContainer>& xAvailableUpdates,
                                       const uno::Reference<container::XNameContainer>& xIgnoredUpdates,
@@ -241,12 +216,9 @@ UpdateCheckConfig::UpdateCheckConfig( const uno::Reference<container::XNameConta
     m_rListener( rListener )
 {}
 
-
 UpdateCheckConfig::~UpdateCheckConfig()
 {}
 
-
-
 ::rtl::Reference< UpdateCheckConfig >
 UpdateCheckConfig::get(
     const uno::Reference<uno::XComponentContext>& xContext,
@@ -278,8 +250,6 @@ UpdateCheckConfig::get(
     return new UpdateCheckConfig( xContainer, xUpdateAvail, xIgnoredExt, rListener );
 }
 
-
-
 bool
 UpdateCheckConfig::isAutoCheckEnabled() const
 {
@@ -288,8 +258,6 @@ UpdateCheckConfig::isAutoCheckEnabled() const
     return nValue;
 }
 
-
-
 bool
 UpdateCheckConfig::isAutoDownloadEnabled() const
 {
@@ -298,8 +266,6 @@ UpdateCheckConfig::isAutoDownloadEnabled() const
     return nValue;
 }
 
-
-
 OUString
 UpdateCheckConfig::getUpdateEntryVersion() const
 {
@@ -311,8 +277,6 @@ UpdateCheckConfig::getUpdateEntryVersion() const
     return aValue;
 }
 
-
-
 sal_Int64
 UpdateCheckConfig::getLastChecked() const
 {
@@ -324,8 +288,6 @@ UpdateCheckConfig::getLastChecked() const
     return nValue;
 }
 
-
-
 sal_Int64
 UpdateCheckConfig::getCheckInterval() const
 {
@@ -337,8 +299,6 @@ UpdateCheckConfig::getCheckInterval() const
     return nValue;
 }
 
-
-
 OUString
 UpdateCheckConfig::getLocalFileName() const
 {
@@ -351,8 +311,6 @@ UpdateCheckConfig::getLocalFileName() const
     return aRet;
 }
 
-
-
 OUString
 UpdateCheckConfig::getDownloadDestination() const
 {
@@ -364,8 +322,6 @@ UpdateCheckConfig::getDownloadDestination() const
     return aRet;
 }
 
-
-
 void
 UpdateCheckConfig::storeLocalFileName(const OUString& rLocalFileName, sal_Int64 nFileSize)
 {
@@ -384,8 +340,6 @@ UpdateCheckConfig::storeLocalFileName(const OUString& rLocalFileName, sal_Int64
     commitChanges();
 }
 
-
-
 void
 UpdateCheckConfig::clearLocalFileName()
 {
@@ -401,8 +355,6 @@ UpdateCheckConfig::clearLocalFileName()
     commitChanges();
 }
 
-
-
 void
 UpdateCheckConfig::storeDownloadPaused(bool paused)
 {
@@ -410,8 +362,6 @@ UpdateCheckConfig::storeDownloadPaused(bool paused)
     commitChanges();
 }
 
-
-
 void
 UpdateCheckConfig::updateLastChecked()
 {
@@ -423,8 +373,6 @@ UpdateCheckConfig::updateLastChecked()
     replaceByName(LAST_CHECK, uno::makeAny(lastCheck));
 }
 
-
-
 void
 UpdateCheckConfig::storeUpdateFound( const UpdateInfo& rInfo, const OUString& aCurrentBuild)
 
@@ -460,8 +408,6 @@ UpdateCheckConfig::storeUpdateFound( const UpdateInfo& rInfo, const OUString& aC
     commitChanges();
 }
 
-
-
 void
 UpdateCheckConfig::clearUpdateFound()
 {
@@ -489,8 +435,6 @@ UpdateCheckConfig::clearUpdateFound()
     commitChanges();
 }
 
-
-
 uno::Sequence< OUString >
 UpdateCheckConfig::getServiceNames()
 {
@@ -498,32 +442,24 @@ UpdateCheckConfig::getServiceNames()
     return aServiceList;
 }
 
-
-
 OUString
 UpdateCheckConfig::getImplName()
 {
     return OUString("vnd.sun.UpdateCheckConfig");
 }
 
-
-
 uno::Type SAL_CALL
 UpdateCheckConfig::getElementType() throw (uno::RuntimeException, std::exception)
 {
     return m_xContainer->getElementType();
 }
 
-
-
 sal_Bool SAL_CALL
 UpdateCheckConfig::hasElements() throw (uno::RuntimeException, std::exception)
 {
     return m_xContainer->hasElements();
 }
 
-
-
 uno::Any SAL_CALL
 UpdateCheckConfig::getByName( const OUString& aName )
     throw (container::NoSuchElementException, lang::WrappedTargetException,  uno::RuntimeException, std::exception)
@@ -539,28 +475,21 @@ UpdateCheckConfig::getByName( const OUString& aName )
         if( aStr.isEmpty() )
             aValue = uno::makeAny(getDesktopDirectory());
     }
-
     return aValue;
 }
 
-
-
 uno::Sequence< OUString > SAL_CALL
-UpdateCheckConfig::getElementNames(  ) throw (uno::RuntimeException, std::exception)
+UpdateCheckConfig::getElementNames() throw (uno::RuntimeException, std::exception)
 {
     return m_xContainer->getElementNames();
 }
 
-
-
 sal_Bool SAL_CALL
 UpdateCheckConfig::hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception)
 {
     return m_xContainer->hasByName( aName );
 }
 
-
-
 void SAL_CALL
 UpdateCheckConfig::replaceByName( const OUString& aName, const uno::Any& aElement )
     throw (lang::IllegalArgumentException, container::NoSuchElementException,
@@ -569,7 +498,6 @@ UpdateCheckConfig::replaceByName( const OUString& aName, const uno::Any& aElemen
     return m_xContainer->replaceByName( aName, aElement );
 }
 
-
 // XChangesBatch
 
 void SAL_CALL
@@ -616,8 +544,6 @@ UpdateCheckConfig::commitChanges()
     }
 }
 
-
-
 sal_Bool SAL_CALL
 UpdateCheckConfig::hasPendingChanges(  ) throw (uno::RuntimeException, std::exception)
 {
@@ -628,8 +554,6 @@ UpdateCheckConfig::hasPendingChanges(  ) throw (uno::RuntimeException, std::exce
     return sal_False;
 }
 
-
-
 uno::Sequence< util::ElementChange > SAL_CALL
 UpdateCheckConfig::getPendingChanges(  ) throw (uno::RuntimeException, std::exception)
 {
@@ -640,7 +564,6 @@ UpdateCheckConfig::getPendingChanges(  ) throw (uno::RuntimeException, std::exce
     return uno::Sequence< util::ElementChange >();
 }
 
-
 bool UpdateCheckConfig::storeExtensionVersion( const OUString& rExtensionName,
                                                const OUString& rVersion )
 {
@@ -671,7 +594,6 @@ bool UpdateCheckConfig::storeExtensionVersion( const OUString& rExtensionName,
     return bNotify;
 }
 
-
 bool UpdateCheckConfig::checkExtensionVersion( const OUString& rExtensionName,
                                                const OUString& rVersion )
 {
@@ -704,7 +626,6 @@ bool UpdateCheckConfig::checkExtensionVersion( const OUString& rExtensionName,
     return false;
 }
 
-
 OUString UpdateCheckConfig::getSubVersion( const OUString& rVersion,
                                                 sal_Int32 *nIndex )
 {
@@ -716,9 +637,7 @@ OUString UpdateCheckConfig::getSubVersion( const OUString& rVersion,
     return rVersion.getToken( 0, '.', *nIndex );
 }
 
-
-// checks if the second version string is greater than the first one
-
+/// checks if the second version string is greater than the first one
 bool UpdateCheckConfig::isVersionGreater( const OUString& rVersion1,
                                           const OUString& rVersion2 )
 {
@@ -740,10 +659,6 @@ bool UpdateCheckConfig::isVersionGreater( const OUString& rVersion1,
     return false;
 }
 
-
-
-
-
 OUString SAL_CALL
 UpdateCheckConfig::getImplementationName()  throw (uno::RuntimeException, std::exception)
 {
@@ -757,13 +672,10 @@ UpdateCheckConfig::supportsService(OUString const & serviceName)
     return cppu::supportsService(this, serviceName);
 }
 
-
-
 uno::Sequence< OUString > SAL_CALL
 UpdateCheckConfig::getSupportedServiceNames()  throw (uno::RuntimeException, std::exception)
 {
     return getServiceNames();
 }
 
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx
index 47b23c7..8bb9277 100644
--- a/extensions/source/update/feed/updatefeed.cxx
+++ b/extensions/source/update/feed/updatefeed.cxx
@@ -367,7 +367,6 @@ UpdateInformationProvider::UpdateInformationProvider(
     }
 }
 
-
 uno::Reference< uno::XInterface >
 UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentContext>& xContext)
 {
commit ecdd0e8e52dafe7a5889cb20c78972f31ff5670f
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Nov 14 17:23:00 2015 +0000

    Update-check, expand it to allow reporting of H/W and OS versions.
    
    Off by default.
    
    Change-Id: I1044116ef9beeb341a537c0f4451dca54e198f67

diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index 6ca3f1f..174825c 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -29,6 +29,8 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
+#include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/util/XChangesBatch.hpp>
@@ -38,9 +40,7 @@
 #include <osl/file.hxx>
 #include <osl/security.hxx>
 
-using namespace ::com::sun::star;
-
-// class SvxOnlineUpdateTabPage --------------------------------------------------
+using namespace ::css;
 
 SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
     : SfxTabPage(pParent, "OptOnlineUpdatePage", "cui/ui/optonlineupdatepage.ui", &rSet)
@@ -56,6 +56,8 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt
     get(m_pDestPath, "destpath");
     get(m_pChangePathButton, "changepath");
     get(m_pLastChecked, "lastchecked");
+    get(m_pExtrasCheckBox, "extrabits");
+    get(m_pUserAgentLabel, "useragent");
 
     m_pAutoCheckCheckBox->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, AutoCheckHdl_Impl ) );
     m_pCheckNowButton->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, CheckNowHdl_Impl ) );
@@ -78,8 +80,10 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt
     m_pChangePathButton->Show(bDownloadSupported);
 
     m_aLastCheckedTemplate = m_pLastChecked->GetText();
+    m_aUserAgentTemplate = m_pUserAgentLabel->GetText();
 
     UpdateLastCheckedText();
+    UpdateUserAgent();
 }
 
 SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage()
@@ -99,10 +103,12 @@ void SvxOnlineUpdateTabPage::dispose()
     m_pDestPath.clear();
     m_pChangePathButton.clear();
     m_pLastChecked.clear();
+    m_pExtrasCheckBox.clear();
+    m_pUserAgentLabel.clear();
+
     SfxTabPage::dispose();
 }
 
-
 void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
 {
     OUString aDateStr;
@@ -160,6 +166,34 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
     m_pLastChecked->SetText( aText );
 }
 
+void SvxOnlineUpdateTabPage::UpdateUserAgent()
+{
+    try {
+        uno::Reference< ucb::XWebDAVCommandEnvironment > xDav(
+            css::deployment::UpdateInformationProvider::create(
+                ::comphelper::getProcessComponentContext() ),
+            css::uno::UNO_QUERY_THROW );
+
+        uno::Sequence< beans::StringPair > aHeaders
+            = xDav->getUserRequestHeaders( OUString(), ucb::WebDAVHTTPMethod(0) );
+
+        for ( auto i = aHeaders.begin(); i != aHeaders.end(); ++i )
+        {
+            if ( i->First == "User-Agent" )
+            {
+                OUString aText = m_aUserAgentTemplate;
+                sal_Int32 nIndex = aText.indexOf( "%USERAGENT%" );
+                if ( nIndex != -1 )
+                    aText = aText.replaceAt( nIndex, 11, i->Second );
+                m_pUserAgentLabel->SetText( aText );
+                break;
+            }
+        }
+    } catch (const uno::Exception &) {
+        SAL_WARN( "cui.options", "Unexpected exception fetching User Agent" );
+    }
+}
+
 VclPtr<SfxTabPage>
 SvxOnlineUpdateTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
 {
@@ -220,6 +254,13 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* )
         bModified = true;
     }
 
+    if( m_pExtrasCheckBox->IsValueChangedFromSaved() )
+    {
+        bValue = m_pExtrasCheckBox->IsChecked();
+        m_xUpdateAccess->replaceByName( "ExtendedUserAgent", uno::makeAny( bValue ) );
+        bModified = true;
+    }
+
     uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY);
     if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
         xChangesBatch->commitChanges();
@@ -227,8 +268,6 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* )
     return bModified;
 }
 
-
-
 void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* )
 {
     bool bValue = false;
@@ -266,17 +305,17 @@ void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* )
     if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) )
         m_pDestPath->SetText(aPath);
 
+    m_xUpdateAccess->getByName( "ExtendedUserAgent" ) >>= bValue;
+    m_pExtrasCheckBox->Check(bValue);
+    m_pExtrasCheckBox->SaveValue();
+
     m_pAutoDownloadCheckBox->SaveValue();
 }
 
-
-
 void SvxOnlineUpdateTabPage::FillUserData()
 {
 }
 
-
-
 IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, Button*, pBox, void )
 {
     bool bEnabled = static_cast<CheckBox*>(pBox)->IsChecked();
@@ -286,8 +325,6 @@ IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, Button*, pBox, void
     m_pEveryMonthButton->Enable(bEnabled);
 }
 
-
-
 IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, FileDialogHdl_Impl, Button*, void)
 {
     uno::Reference < uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
@@ -308,8 +345,6 @@ IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, FileDialogHdl_Impl, Button*, void)
     }
 }
 
-
-
 IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, CheckNowHdl_Impl, Button*, void)
 {
     uno::Reference < uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
diff --git a/cui/source/options/optupdt.hxx b/cui/source/options/optupdt.hxx
index 8844826c..37a45cf 100644
--- a/cui/source/options/optupdt.hxx
+++ b/cui/source/options/optupdt.hxx
@@ -39,16 +39,21 @@ private:
     VclPtr<FixedText>          m_pDestPath;
     VclPtr<PushButton>         m_pChangePathButton;
     VclPtr<FixedText>          m_pLastChecked;
+    VclPtr<CheckBox>           m_pExtrasCheckBox;
+    VclPtr<FixedText>          m_pUserAgentLabel;
     OUString       m_aNeverChecked;
     OUString       m_aLastCheckedTemplate;
+    OUString       m_aUserAgentTemplate;
 
     DECL_LINK_TYPED(FileDialogHdl_Impl, Button*, void);
     DECL_LINK_TYPED(CheckNowHdl_Impl, Button*, void);
     DECL_LINK_TYPED(AutoCheckHdl_Impl, Button*, void);
+    DECL_LINK_TYPED(ExtrasCheckHdl_Impl, Button*, void);
 
     css::uno::Reference< css::container::XNameReplace > m_xUpdateAccess;
 
     void                    UpdateLastCheckedText();
+    void                    UpdateUserAgent();
 
 public:
     SvxOnlineUpdateTabPage( vcl::Window* pParent, const SfxItemSet& rSet );
diff --git a/cui/uiconfig/ui/optonlineupdatepage.ui b/cui/uiconfig/ui/optonlineupdatepage.ui
index cf4c4ae..186d88a 100644
--- a/cui/uiconfig/ui/optonlineupdatepage.ui
+++ b/cui/uiconfig/ui/optonlineupdatepage.ui
@@ -216,6 +216,36 @@
               </packing>
             </child>
             <child>
+              <object class="GtkCheckButton" id="extrabits">
+                <property name="label" translatable="yes">_Send OS version & simple hardware info.</property>
+		<property name="tooltip_text" translatable="yes">This information lets us optimize for your hardware & OS.</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">7</property>
+                <property name="width">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="useragent">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">User Agent: %USERAGENT%</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">8</property>
+                <property name="width">2</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkLabel" id="neverchecked">
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
diff --git a/extensions/source/update/check/org/openoffice/Office/Jobs.xcu b/extensions/source/update/check/org/openoffice/Office/Jobs.xcu
index f11c14e..0127678 100644
--- a/extensions/source/update/check/org/openoffice/Office/Jobs.xcu
+++ b/extensions/source/update/check/org/openoffice/Office/Jobs.xcu
@@ -49,6 +49,9 @@
                 <prop oor:name="DownloadPaused" oor:type="xs:boolean" oor:op="replace">
                     <value>false</value>
                 </prop>
+                <prop oor:name="ExtendedUserAgent" oor:type="xs:boolean" oor:op="replace">
+                    <value>true</value>
+                </prop>
             </node>
         </node>
     </node>
commit f3ee170f6c5cf552ac89534abdba191f44efc1f2
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 22:57:43 2015 +0000

    More horrific debugging experience ...
    
    Change-Id: Iaf703f5297e20de24ca748571bb12b708b5a252a

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 71a11fa..49a8ee1 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -139,6 +139,7 @@ void OpenGLSalGraphicsImpl::Init()
             mpContext->ReleaseFramebuffer( maOffscreenTex );
         }
         maOffscreenTex = OpenGLTexture();
+        VCL_GL_INFO("vcl.opengl", "::Init - re-size offscreen texture");
     }
 
     if( mpWindowContext.is() )
@@ -216,6 +217,7 @@ void OpenGLSalGraphicsImpl::freeResources()
     // TODO Delete shaders, programs and textures if not shared
     if( mpContext.is() && mpContext->isInitialized() )
     {
+        VCL_GL_INFO( "vcl.opengl", "freeResources" );
         mpContext->makeCurrent();
         mpContext->ReleaseFramebuffer( maOffscreenTex );
     }
@@ -371,6 +373,8 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
 {
     bool bClearTexture = false;
 
+    VCL_GL_INFO( "vcl.opengl", "Check Offscreen texture" );
+
     if( !maOffscreenTex )
     {
         maOffscreenTex = OpenGLTexture( GetWidth(), GetHeight() );
@@ -392,6 +396,8 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
     else
     {
         mpFramebuffer = mpContext->AcquireFramebuffer( maOffscreenTex );
+        CHECK_GL_ERROR();
+
         if( bClearTexture )
         {
             glDrawBuffer( GL_COLOR_ATTACHMENT0 );
@@ -401,6 +407,8 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
         }
     }
 
+    assert( maOffscreenTex );
+
     CHECK_GL_ERROR();
     return true;
 }
@@ -1882,22 +1890,32 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
     assert( !IsOffscreen() );
     assert( mpContext.is() );
 
+    if( !maOffscreenTex )
+    {
+        VCL_GL_INFO( "vcl.opengl", "flushAndSwap - odd no texture !" );
+        return;
+    }
+
     OpenGLZone aZone;
 
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap" );
 
-    glBindTexture( GL_TEXTURE_2D, 0 );
-
     glFlush();
+    // Interesting ! -> this destroys a context [ somehow ] ...
     mpWindowContext->makeCurrent();
     CHECK_GL_ERROR();
 
+    VCL_GL_INFO( "vcl.opengl", "flushAndSwap - acquire default frame buffer" );
+
     mpWindowContext->AcquireDefaultFramebuffer();
+    glBindFramebuffer( GL_FRAMEBUFFER, 0 ); // FIXME: paranoid double check.
     CHECK_GL_ERROR();
 
-    glDisable( GL_SCISSOR_TEST );
+    VCL_GL_INFO( "vcl.opengl", "flushAndSwap - acquired default frame buffer" );
+
+    glDisable( GL_SCISSOR_TEST ); // FIXME: paranoia ...
     CHECK_GL_ERROR();
-    glDisable( GL_STENCIL_TEST );
+    glDisable( GL_STENCIL_TEST ); // FIXME: paranoia ...
     CHECK_GL_ERROR();
 
     glViewport( 0, 0, GetWidth(), GetHeight() );
@@ -1913,8 +1931,12 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     OpenGLProgram *pProgram =
         mpWindowContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
-
+    pProgram->Use(); // FIXME: paranoia ...
+    VCL_GL_INFO( "vcl.opengl", "done paranoid re-use." );
     pProgram->SetTexture( "sampler", maOffscreenTex );
+    maOffscreenTex.Bind(); // FIXME: paranoia ...
+
+    VCL_GL_INFO( "vcl.opengl", "bound bits etc." );
 
     GLfloat aTexCoord[8];
     maOffscreenTex.GetCoord( aTexCoord, aPosAry, false );
@@ -1944,6 +1966,8 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     pProgram->Clean();
 
+    glBindTexture( GL_TEXTURE_2D, 0 );
+
     if (!getenv("NO_SWAP"))
     {
         glFlush();
@@ -1953,6 +1977,9 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
             usleep(500000);
     }
 
+    // Should get a more sensible context (this one) next time.
+    mpContext.clear();
+
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap - end." );
 }
 
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 9095326..6dfa882 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -321,6 +321,8 @@ void OpenGLTexture::Bind()
 {
     if( mpImpl )
         glBindTexture( GL_TEXTURE_2D, mpImpl->mnTexture );
+    else
+        VCL_GL_INFO("vcl.opengl", "OpenGLTexture::Binding invalid texture");
 
     CHECK_GL_ERROR();
 }
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 9d840d7..7b81e66 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1372,6 +1372,8 @@ void OpenGLContext::prepareForYield()
 {
     ImplSVData* pSVData = ImplGetSVData();
 
+    VCL_GL_INFO("vcl.opengl", "clearCurrent - detachframebuffers");
+
     // release all framebuffers from the old context so we can re-attach the
     // texture in the new context
     rtl::Reference<OpenGLContext> pCurrentCtx = pSVData->maGDIData.mpLastContext;
@@ -1538,7 +1540,10 @@ bool OpenGLContext::BindFramebuffer( OpenGLFramebuffer* pFramebuffer )
             pFramebuffer->Bind();
         else
             OpenGLFramebuffer::Unbind();
+
+        VCL_GL_INFO( "vcl.opengl", "before assign pFramebuffer" );
         mpCurrentFramebuffer = pFramebuffer;
+        VCL_GL_INFO( "vcl.opengl", "after assign pFramebuffer" );
     }
 
     return true;
commit 90ba8427d623d1c1b7d1d761bfa462df281a846d
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 21:25:44 2015 +0000

    More tweakables ... no joy.
    
    Change-Id: I994023668a9251809ec10520829a3df5e6e3a819

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index f2867c5..71a11fa 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1872,6 +1872,8 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
 OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
 {
     AcquireContext();
+    if( mpContext.is() )
+        mpContext->mnPainting++;
     return mpContext.get();
 }
 
@@ -1937,15 +1939,18 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
     pProgram->SetVertices( &aVertices[0] );
-    glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+    if (!getenv("NO_COPY"))
+        glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
 
     pProgram->Clean();
 
     if (!getenv("NO_SWAP"))
     {
+        glFlush();
         mpWindowContext->swapBuffers();
         glFlush();
-        usleep(500000);
+        if (!getenv("NO_SLEEP"))
+            usleep(500000);
     }
 
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap - end." );
@@ -1956,9 +1961,12 @@ void OpenGLSalGraphicsImpl::endPaint()
     assert( !IsOffscreen() );
 
     AcquireContext();
-    if( mpContext.is() &&
-        mpContext->mnPainting == 0 )
-        flushAndSwap();
+    if( mpContext.is() )
+    {
+        mpContext->mnPainting--;
+        if( mpContext->mnPainting == 0 )
+            flushAndSwap();
+    }
 }
 
 bool OpenGLSalGraphicsImpl::IsForeignContext(const rtl::Reference<OpenGLContext> &xContext)
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 76ec17d..da007bf 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1105,10 +1105,17 @@ public:
             {
                 mnStartTime = getTimeNow();
                 for (int i = 0; i < r->getTestRepeatCount(); i++)
+                {
+                    OutputDevice::PaintScope aScope(&rDev);
                     r->RenderRegion(rDev, aWholeWin, aCtx);
+                }
                 addTime(mnSelectedRenderer, getTimeNow() - mnStartTime);
-            } else
+            }
+            else
+            {
+                OutputDevice::PaintScope aScope(&rDev);
                 r->RenderRegion(rDev, aWholeWin, aCtx);
+            }
         }
         else
         {
@@ -1128,11 +1135,20 @@ public:
                     {
                         mnStartTime = getTimeNow();
                         for (int j = 0; j < r->getTestRepeatCount() * THUMB_REPEAT_FACTOR; j++)
+                        {
+                            OutputDevice::PaintScope aScope(&rDev);
                             r->RenderRegion(rDev, aRegions[i], aCtx);
+                        }
                         addTime(i, (getTimeNow() - mnStartTime) / THUMB_REPEAT_FACTOR);
-                    } else
+                    }
+                    else
+                    {
                         for (int j = 0; j < r->getTestRepeatCount(); j++)
+                        {
+                            OutputDevice::PaintScope aScope(&rDev);
                             r->RenderRegion(rDev, aRegions[i], aCtx);
+                        }
+                    }
                 }
                 else
                 {
commit 34462fd0b2046ff4d5a27b48e6d05448d37790b5
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 21:11:18 2015 +0000

    STAGE <N> - starting to see something.
    
    Change-Id: Iee7261e724e7ec3f834ae246cdf94f6a46605fec

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index e0256105..f2867c5 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -37,6 +37,8 @@
 
 #include <vector>
 
+#include <stdlib.h>
+
 OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvider *pProvider)
     : mpContext(nullptr)
     , mrParent(rParent)
@@ -100,7 +102,12 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
         pContext = pContext->mpPrevContext;
     }
 
-    mpContext = pContext ? pContext : GetDefaultContext();
+    if( mpContext.is() )
+        mpContext = pContext;
+    else if( mpWindowContext.is() )
+        mpContext = mpWindowContext;
+    else
+        mpContext = GetDefaultContext();
 
     return mpContext.is();
 }
@@ -192,10 +199,7 @@ void OpenGLSalGraphicsImpl::PostDraw()
     if( mpContext->mnPainting == 0 )
     {
         if (!IsOffscreen())
-        {
-            SAL_DEBUG("PostDraw flush ?");
             flushAndSwap();
-        }
     }
 
     CHECK_GL_ERROR();
@@ -365,8 +369,13 @@ void OpenGLSalGraphicsImpl::SetROPFillColor( SalROPColor /*nROPColor*/ )
 
 bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
 {
+    bool bClearTexture = false;
+
     if( !maOffscreenTex )
+    {
         maOffscreenTex = OpenGLTexture( GetWidth(), GetHeight() );
+        bClearTexture = true;
+    }
 
     if( !maOffscreenTex.IsUnique() )
     {
@@ -383,6 +392,13 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
     else
     {
         mpFramebuffer = mpContext->AcquireFramebuffer( maOffscreenTex );
+        if( bClearTexture )
+        {
+            glDrawBuffer( GL_COLOR_ATTACHMENT0 );
+            GLuint clearColor[4] = { 0, 0, 0, 0 };
+            glClearBufferuiv( GL_COLOR, 0, clearColor );
+            // FIXME: use glClearTexImage if we have it ?
+        }
     }
 
     CHECK_GL_ERROR();
@@ -1855,7 +1871,6 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
 
 OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
 {
-    SAL_DEBUG( "want to rid ourselves of this method" );
     AcquireContext();
     return mpContext.get();
 }
@@ -1869,22 +1884,33 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     VCL_GL_INFO( "vcl.opengl", "flushAndSwap" );
 
-//    glFlush(); - not needed
+    glBindTexture( GL_TEXTURE_2D, 0 );
+
+    glFlush();
     mpWindowContext->makeCurrent();
     CHECK_GL_ERROR();
 
     mpWindowContext->AcquireDefaultFramebuffer();
     CHECK_GL_ERROR();
 
+    glDisable( GL_SCISSOR_TEST );
+    CHECK_GL_ERROR();
+    glDisable( GL_STENCIL_TEST );
+    CHECK_GL_ERROR();
+
     glViewport( 0, 0, GetWidth(), GetHeight() );
-    ImplInitClipRegion();
     CHECK_GL_ERROR();
 
-    SalTwoRect aPosAry(0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
-                       0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight());
+    glClearColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX,
+                 (float)rand()/RAND_MAX, 1.0);
+    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
+    CHECK_GL_ERROR();
+
+    SalTwoRect aPosAry( 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
+                        0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight() );
 
     OpenGLProgram *pProgram =
-        mpContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
+        mpWindowContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
 
     pProgram->SetTexture( "sampler", maOffscreenTex );
 
@@ -1915,7 +1941,14 @@ void OpenGLSalGraphicsImpl::flushAndSwap()
 
     pProgram->Clean();
 
-    mpContext->swapBuffers();
+    if (!getenv("NO_SWAP"))
+    {
+        mpWindowContext->swapBuffers();
+        glFlush();
+        usleep(500000);
+    }
+
+    VCL_GL_INFO( "vcl.opengl", "flushAndSwap - end." );
 }
 
 void OpenGLSalGraphicsImpl::endPaint()
commit fcdc9eba364d79ca86edf5a1945e90580c773604
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 15:50:39 2015 +0000

    STEP #4 - paint guards & compilation.
    
    Change-Id: I57addc1d7d948f7e614526f24cf32181313bda1e

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index a146c86..2bf3f07 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -609,13 +609,9 @@ public:
     /**
      * Instantiate across a paint operation to defer flushing
      * to the end.
-     *
-     * NB. holding a handle avoids problems with
-     * the underlying SalGraphics and it's implementation
-     * changing.
      */
     class PaintScope {
-        void *pHandle;
+        VclPtr<OutputDevice> mpDev;
     public:
         PaintScope(OutputDevice *);
         ~PaintScope();
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 3c24d6d..b2112b6 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -160,9 +160,6 @@ protected:
     /// retrieve the default context for offscreen rendering
     static rtl::Reference<OpenGLContext> GetDefaultContext();
 
-    /// flush contents of the back-buffer to the screen & swap.
-    void FlushAndSwap();
-
     /// create a new context for rendering to the underlying window
     virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;
 
@@ -350,6 +347,9 @@ public:
 
     virtual OpenGLContext *beginPaint() override;
     virtual void           endPaint() override;
+
+    /// flush contents of the back-buffer to the screen & swap.
+    void flushAndSwap();
 private:
 };
 
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 4cdf1b3..2bfa57d 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -213,7 +213,7 @@ public:
     virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;
 
     virtual OpenGLContext *beginPaint() { return nullptr; }
-    virtual OpenGLContext *endPaint()   { }
+    virtual void           endPaint()   { }
 };
 
 #endif
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 422b5b2..e5a8cf1 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -264,6 +264,7 @@ public:
     virtual SystemFontData          GetSysFontData( int nFallbackLevel ) const override;
 
     virtual OpenGLContext          *BeginPaint() override;
+    virtual void                    EndPaint() override;
 
     bool TryRenderCachedNativeControl(ControlCacheKey& aControlCacheKey,
                                       int nX, int nY);
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index b7697d6..21513ea 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -437,6 +437,7 @@ public:
     virtual SystemGraphicsData GetGraphicsData() const override;
 
     virtual OpenGLContext     *BeginPaint() override;
+    virtual void               EndPaint() override;
 
     /// Update settings based on the platform values
     static void updateSettingsNative( AllSettings& rSettings );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 2d20427..e0256105 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -135,7 +135,7 @@ void OpenGLSalGraphicsImpl::Init()
     }
 
     if( mpWindowContext.is() )
-        mpWindowContext.reset();
+        mpWindowContext->reset();
     mpWindowContext = CreateWinContext();
 }
 
@@ -194,7 +194,7 @@ void OpenGLSalGraphicsImpl::PostDraw()
         if (!IsOffscreen())
         {
             SAL_DEBUG("PostDraw flush ?");
-            FlushAndSwap();
+            flushAndSwap();
         }
     }
 
@@ -1860,13 +1860,15 @@ OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
     return mpContext.get();
 }
 
-void OpenGLSalGraphicsImpl::FlushAndSwap()
+void OpenGLSalGraphicsImpl::flushAndSwap()
 {
     assert( !IsOffscreen() );
     assert( mpContext.is() );
 
     OpenGLZone aZone;
 
+    VCL_GL_INFO( "vcl.opengl", "flushAndSwap" );
+
 //    glFlush(); - not needed
     mpWindowContext->makeCurrent();
     CHECK_GL_ERROR();
@@ -1887,20 +1889,21 @@ void OpenGLSalGraphicsImpl::FlushAndSwap()
     pProgram->SetTexture( "sampler", maOffscreenTex );
 
     GLfloat aTexCoord[8];
-    maOffscreenTex.GetCoord( aTexCoord, rPosAry, false );
+    maOffscreenTex.GetCoord( aTexCoord, aPosAry, false );
     pProgram->SetTextureCoord( aTexCoord );
 
-    long nX1( rPosAry.mnDestX );
-    long nY1( rPosAry.mnDestY );
-    long nX2( nX1 + rPosAry.mnDestWidth );
-    long nY2( nY1 + rPosAry.mnDestHeight );
+    long nX1( aPosAry.mnDestX );
+    long nY1( aPosAry.mnDestY );
+    long nX2( nX1 + aPosAry.mnDestWidth );
+    long nY2( nY1 + aPosAry.mnDestHeight );
     const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
                                  { nX2, nY1 }, { nX2, nY2 }};
 
+    sal_uInt32 nPoints = 4;
     std::vector<GLfloat> aVertices(nPoints * 2);
     sal_uInt32 i, j;
 
-    for( i = 0, j = 0; i < 4; i++, j += 2 )
+    for( i = 0, j = 0; i < nPoints; i++, j += 2 )
     {
         aVertices[j]   = GLfloat(aPoints[i].mnX);
         aVertices[j+1] = GLfloat(aPoints[i].mnY);
@@ -1922,7 +1925,7 @@ void OpenGLSalGraphicsImpl::endPaint()
     AcquireContext();
     if( mpContext.is() &&
         mpContext->mnPainting == 0 )
-        FlushAndSwap();
+        flushAndSwap();
 }
 
 bool OpenGLSalGraphicsImpl::IsForeignContext(const rtl::Reference<OpenGLContext> &xContext)
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index f3c7acb..945b662 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -1080,55 +1080,4 @@ GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted
 
 #endif
 
-OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
-    : pHandle( nullptr )
-{
-    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( pDev->mpGraphics || pDev->AcquireGraphics() )
-        pDev->mpGraphics->EndPaint();
-
-#if 0
-    if( pHandle )
-    {
-        OpenGLContext *pContext = static_cast<OpenGLContext *>( pHandle );
-        pHandle = nullptr;
-        pContext->mnPainting--;
-        assert( pContext->mnPainting >= 0 );
-        if( pContext->mnPainting == 0 )
-        {
-            pContext->makeCurrent();
-            pContext->AcquireDefaultFramebuffer();
-            glFlush();
-            pContext->swapBuffers();
-            CHECK_GL_ERROR();
-        }
-        pContext->release();
-    }
-#endif
-}
-
-OutputDevice::PaintScope::~PaintScope()
-{
-    flush();
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index b343f50..1779002 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -845,4 +845,26 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
     return bDrawn;
 }
 
+OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
+    : mpDev( pDev )
+{
+    SalGraphics *mpGraphics = mpDev->GetGraphics();
+    if (mpGraphics)
+        mpGraphics->BeginPaint();
+}
+
+OutputDevice::PaintScope::~PaintScope()
+{
+    flush();
+}
+
+/// Flush all the queued rendering commands to the screen for this context.
+void OutputDevice::PaintScope::flush()
+{
+    SalGraphics *mpGraphics = mpDev->GetGraphics();
+    if (mpGraphics)
+        mpGraphics->EndPaint();
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index a6fba00..6f2c9f5 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -561,6 +561,11 @@ OpenGLContext *X11SalGraphics::BeginPaint()
     return mxImpl->beginPaint();
 }
 
+void X11SalGraphics::EndPaint()
+{
+    return mxImpl->endPaint();
+}
+
 SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const
 {
     if (m_pFrame)
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 5f29820..3be4036 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -1075,4 +1075,9 @@ OpenGLContext *WinSalGraphics::BeginPaint()
     return mpImpl->beginPaint();
 }
 
+void WinSalGraphics::EndPaint()
+{
+    return mpImpl->endPaint();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 495420cc07c1ef13ed15747b3f8ea3d4d03576ef
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 14:31:09 2015 +0000

    Stage #3 - first cut at flushing the whole buffer across ...

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 2c3c3dc..3c24d6d 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -160,6 +160,9 @@ protected:
     /// retrieve the default context for offscreen rendering
     static rtl::Reference<OpenGLContext> GetDefaultContext();
 
+    /// flush contents of the back-buffer to the screen & swap.
+    void FlushAndSwap();
+
     /// create a new context for rendering to the underlying window
     virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;
 
@@ -346,6 +349,7 @@ public:
     virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override;
 
     virtual OpenGLContext *beginPaint() override;
+    virtual void           endPaint() override;
 private:
 };
 
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index edf8875..3af0c09 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -439,6 +439,7 @@ public:
                                     const OutputDevice *pOutDev );
 
     virtual OpenGLContext      *BeginPaint() { return nullptr; }
+    virtual void                EndPaint()   { }
 
     virtual SystemGraphicsData  GetGraphicsData() const = 0;
 
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 406f0ce..4cdf1b3 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -213,6 +213,7 @@ public:
     virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;
 
     virtual OpenGLContext *beginPaint() { return nullptr; }
+    virtual OpenGLContext *endPaint()   { }
 };
 
 #endif
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index ff86249..2d20427 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -133,6 +133,10 @@ void OpenGLSalGraphicsImpl::Init()
         }
         maOffscreenTex = OpenGLTexture();
     }
+
+    if( mpWindowContext.is() )
+        mpWindowContext.reset();
+    mpWindowContext = CreateWinContext();
 }
 
 // Currently only used to get windows ordering right.
@@ -172,12 +176,6 @@ void OpenGLSalGraphicsImpl::PreDraw()
 
 void OpenGLSalGraphicsImpl::PostDraw()
 {
-    if( mpContext->mnPainting == 0 )
-    {
-        if (!IsOffscreen()) ...
-#warning "Trigger re-rendering of the window if we have one"
-        glFlush();
-    }
     if( mbUseScissor )
         glDisable( GL_SCISSOR_TEST );
     if( mbUseStencil )
@@ -191,6 +189,15 @@ void OpenGLSalGraphicsImpl::PostDraw()
 #endif
     }
 
+    if( mpContext->mnPainting == 0 )
+    {
+        if (!IsOffscreen())
+        {
+            SAL_DEBUG("PostDraw flush ?");
+            FlushAndSwap();
+        }
+    }
+
     CHECK_GL_ERROR();
     OpenGLZone::leave();
 }
@@ -1848,10 +1855,76 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
 
 OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
 {
+    SAL_DEBUG( "want to rid ourselves of this method" );
     AcquireContext();
     return mpContext.get();
 }
 
+void OpenGLSalGraphicsImpl::FlushAndSwap()
+{
+    assert( !IsOffscreen() );
+    assert( mpContext.is() );
+
+    OpenGLZone aZone;
+
+//    glFlush(); - not needed
+    mpWindowContext->makeCurrent();
+    CHECK_GL_ERROR();
+
+    mpWindowContext->AcquireDefaultFramebuffer();
+    CHECK_GL_ERROR();
+
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+    ImplInitClipRegion();
+    CHECK_GL_ERROR();
+
+    SalTwoRect aPosAry(0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
+                       0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight());
+
+    OpenGLProgram *pProgram =
+        mpContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
+
+    pProgram->SetTexture( "sampler", maOffscreenTex );
+
+    GLfloat aTexCoord[8];
+    maOffscreenTex.GetCoord( aTexCoord, rPosAry, false );
+    pProgram->SetTextureCoord( aTexCoord );
+
+    long nX1( rPosAry.mnDestX );
+    long nY1( rPosAry.mnDestY );
+    long nX2( nX1 + rPosAry.mnDestWidth );
+    long nY2( nY1 + rPosAry.mnDestHeight );
+    const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
+                                 { nX2, nY1 }, { nX2, nY2 }};
+
+    std::vector<GLfloat> aVertices(nPoints * 2);
+    sal_uInt32 i, j;
+
+    for( i = 0, j = 0; i < 4; i++, j += 2 )
+    {
+        aVertices[j]   = GLfloat(aPoints[i].mnX);
+        aVertices[j+1] = GLfloat(aPoints[i].mnY);
+    }
+
+    pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
+    pProgram->SetVertices( &aVertices[0] );
+    glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+
+    pProgram->Clean();
+
+    mpContext->swapBuffers();
+}
+
+void OpenGLSalGraphicsImpl::endPaint()
+{
+    assert( !IsOffscreen() );
+
+    AcquireContext();
+    if( mpContext.is() &&
+        mpContext->mnPainting == 0 )
+        FlushAndSwap();
+}
+
 bool OpenGLSalGraphicsImpl::IsForeignContext(const rtl::Reference<OpenGLContext> &xContext)
 {
     // so far a blunt heuristic: vcl uses shiny new contexts.
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 79833d7..f3c7acb 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -1086,6 +1086,7 @@ OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
     if( pDev->mpGraphics || pDev->AcquireGraphics() )
     {
         OpenGLContext *pContext = pDev->mpGraphics->BeginPaint();
+/*
         if( pContext )
         {
             assert( pContext->mnPainting >= 0 );
@@ -1093,6 +1094,7 @@ OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
             pContext->acquire();
             pHandle = static_cast<void *>( pContext );
         }
+*/
     }
 }
 
@@ -1101,6 +1103,10 @@ OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
  */
 void OutputDevice::PaintScope::flush()
 {
+    if( pDev->mpGraphics || pDev->AcquireGraphics() )
+        pDev->mpGraphics->EndPaint();
+
+#if 0
     if( pHandle )
     {
         OpenGLContext *pContext = static_cast<OpenGLContext *>( pHandle );
@@ -1117,6 +1123,7 @@ void OutputDevice::PaintScope::flush()
         }
         pContext->release();
     }
+#endif
 }
 
 OutputDevice::PaintScope::~PaintScope()
commit 685733b62fd223488f62f080e80e2cfb8a8e04c7
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 12:26:52 2015 +0000

    Step #2 - kill mbOffscreen.
    
    Change-Id: Ib844155cca41cd4a75bf0273c7b32a99dfb9870e

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index ba66e40..2c3c3dc 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -57,7 +57,13 @@ class VCL_DLLPUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
     friend class OpenGLTests;
 protected:
 
+    /// This context is solely for blitting @maOffscreenTex
+    rtl::Reference<OpenGLContext> mpWindowContext;
+
+    /// This context is whatever is most convenient to render
+    /// to @maOffscreenTex with.
     rtl::Reference<OpenGLContext> mpContext;
+
     SalGraphics& mrParent;
     /// Pointer to the SalFrame or SalVirtualDevice
     SalGeometryProvider* mpProvider;
@@ -72,7 +78,11 @@ protected:
     bool mbUseScissor;
     bool mbUseStencil;
 
-    bool mbOffscreen;
+    /**
+     * All rendering happens to this off-screen texture. For
+     * non-virtual devices, ie. windows - we will blit it and
+     * swapBuffers later.
+     */
     OpenGLTexture maOffscreenTex;
 
     SalColor mnLineColor;
@@ -131,8 +141,10 @@ public:
     // get the height of the device
     GLfloat GetHeight() const { return mpProvider ? mpProvider->GetHeight() : 1; }
 
-    // check whether this instance is used for offscreen (Virtual Device)
-    // rendering ie. does it need its own context.
+    /**
+     * check whether this instance is used for offscreen (Virtual Device)
+     * rendering ie. does it need its own context.
+     */
     bool IsOffscreen() const { return mpProvider == nullptr || mpProvider->IsOffScreen(); }
 
     // operations to do before painting
@@ -145,10 +157,10 @@ protected:
     bool AcquireContext();
     bool ReleaseContext();
 
-    // retrieve the default context for offscreen rendering
+    /// retrieve the default context for offscreen rendering
     static rtl::Reference<OpenGLContext> GetDefaultContext();
 
-    /// create a new context for window rendering
+    /// create a new context for rendering to the underlying window
     virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;
 
     /// check whether the given context can be used for off-screen rendering
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 19199ab..ff86249 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -45,7 +45,6 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGraphics& rParent, SalGeometryPr
     , mpProgram(nullptr)
     , mbUseScissor(false)
     , mbUseStencil(false)
-    , mbOffscreen(false)
     , mnLineColor(SALCOLOR_NONE)
     , mnFillColor(SALCOLOR_NONE)
 #ifdef DBG_UTIL
@@ -79,10 +78,9 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
 
     // We always prefer to bind our VirtualDevice / offscreen graphics
     // to the current OpenGLContext - to avoid switching contexts.
-    if (mpContext.is() && mbOffscreen)
+    if (mpContext.is() && OpenGLContext::hasCurrent() && !mpContext->isCurrent())
     {
-        if (OpenGLContext::hasCurrent() && !mpContext->isCurrent())
-            mpContext.clear();
+        mpContext.clear();
     }
 
     if( mpContext.is() )
@@ -116,8 +114,6 @@ bool OpenGLSalGraphicsImpl::ReleaseContext()
 
 void OpenGLSalGraphicsImpl::Init()
 {
-    mbOffscreen = IsOffscreen();
-
     // check if we can simply re-use the same context
     if( mpContext.is() )
     {
@@ -165,10 +161,7 @@ void OpenGLSalGraphicsImpl::PreDraw()
     mpContext->makeCurrent();
     CHECK_GL_ERROR();
 
-    if( !mbOffscreen )
-        mpContext->AcquireDefaultFramebuffer();
-    else
-        CheckOffscreenTexture();
+    CheckOffscreenTexture();
     CHECK_GL_ERROR();
 
     glViewport( 0, 0, GetWidth(), GetHeight() );
@@ -179,8 +172,12 @@ void OpenGLSalGraphicsImpl::PreDraw()
 
 void OpenGLSalGraphicsImpl::PostDraw()
 {
-    if( !mbOffscreen && mpContext->mnPainting == 0 )
+    if( mpContext->mnPainting == 0 )
+    {
+        if (!IsOffscreen()) ...
+#warning "Trigger re-rendering of the window if we have one"
         glFlush();
+    }
     if( mbUseScissor )
         glDisable( GL_SCISSOR_TEST );
     if( mbUseStencil )
@@ -206,7 +203,7 @@ void OpenGLSalGraphicsImpl::ApplyProgramMatrices(float fPixelOffset)
 void OpenGLSalGraphicsImpl::freeResources()
 {
     // TODO Delete shaders, programs and textures if not shared
-    if( mbOffscreen && mpContext.is() && mpContext->isInitialized() )
+    if( mpContext.is() && mpContext->isInitialized() )
     {
         mpContext->makeCurrent();
         mpContext->ReleaseFramebuffer( maOffscreenTex );
@@ -1529,17 +1526,9 @@ void OpenGLSalGraphicsImpl::DoCopyBits( const SalTwoRect& rPosAry, OpenGLSalGrap
         return;
     }
 
-    if( rImpl.mbOffscreen )
-    {
-        PreDraw();
-        DrawTexture( rImpl.maOffscreenTex, rPosAry );
-        PostDraw();
-        return;
-    }
-
-    SAL_WARN( "vcl.opengl", "*** NOT IMPLEMENTED *** copyBits" );
-    // TODO: Copy from one FBO to the other (glBlitFramebuffer)
-    //       ie. copying from one visible window to another visible window
+    PreDraw();
+    DrawTexture( rImpl.maOffscreenTex, rPosAry );
+    PostDraw();
 }
 
 void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
@@ -1859,10 +1848,8 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
 
 OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
 {
-    if( mbOffscreen || !AcquireContext() )
-        return nullptr;
-    else
-        return mpContext.get();
+    AcquireContext();
+    return mpContext.get();
 }
 
 bool OpenGLSalGraphicsImpl::IsForeignContext(const rtl::Reference<OpenGLContext> &xContext)
commit 52fff4e27a56a921fdbc9c32725488163340b586
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 13 12:00:59 2015 +0000

    Step #1 - de-virtualize UseContext
    
    Change-Id: If343746b6544d77fec76ee89351cd7262d1bf350

diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index ecefede..8102d2e 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -31,7 +31,6 @@ public:
 
 protected:
     virtual rtl::Reference<OpenGLContext> CreateWinContext() override;
-    virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) override;
 
     bool RenderTextureCombo(TextureCombo& rCombo, int nX, int nY);
 
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
index f07468d..eccd0ef 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -29,7 +29,6 @@ public:
 
 protected:
     virtual rtl::Reference<OpenGLContext> CreateWinContext() override;
-    virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) override;
 
     bool RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY, TextureCombo& rCombo);
 
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 917cf01..ba66e40 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -131,7 +131,8 @@ public:
     // get the height of the device
     GLfloat GetHeight() const { return mpProvider ? mpProvider->GetHeight() : 1; }
 
-    // check whether this instance is used for offscreen rendering
+    // check whether this instance is used for offscreen (Virtual Device)
+    // rendering ie. does it need its own context.
     bool IsOffscreen() const { return mpProvider == nullptr || mpProvider->IsOffScreen(); }
 
     // operations to do before painting
@@ -147,11 +148,15 @@ protected:
     // retrieve the default context for offscreen rendering
     static rtl::Reference<OpenGLContext> GetDefaultContext();
 
-    // create a new context for window rendering
+    /// create a new context for window rendering
     virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;
 
-    // check whether the given context can be used by this instance
-    virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) = 0;
+    /// check whether the given context can be used for off-screen rendering
+    bool UseContext( const rtl::Reference<OpenGLContext> &pContext )
+    {
+        return pContext->isInitialized() &&  // not released by the OS etc.
+               IsForeignContext( pContext ); // a genuine VCL context.
+    }
 
 public:
     OpenGLSalGraphicsImpl(SalGraphics& pParent, SalGeometryProvider *pProvider);
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 51dbc5a..19199ab 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -97,15 +97,12 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
     while( pContext )
     {
         // check if this context can be used by this SalGraphicsImpl instance
-        if( UseContext( pContext )  )
+        if( UseContext( pContext ) )
             break;
         pContext = pContext->mpPrevContext;
     }
 
-    if( pContext )
-        mpContext = pContext;
-    else
-        mpContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
+    mpContext = pContext ? pContext : GetDefaultContext();
 
     return mpContext.is();
 }
@@ -124,14 +121,12 @@ void OpenGLSalGraphicsImpl::Init()
     // check if we can simply re-use the same context
     if( mpContext.is() )
     {
-        if( !mpContext->isInitialized() ||
-            !UseContext( mpContext ) )
+        if( !UseContext( mpContext ) )
             ReleaseContext();
     }
 
-    // reset the offscreen texture
-    if( !mbOffscreen ||
-        maOffscreenTex.GetWidth()  != GetWidth() ||
+    // Always create the offscreen texture
+    if( maOffscreenTex.GetWidth()  != GetWidth() ||
         maOffscreenTex.GetHeight() != GetHeight() )
     {
         if( maOffscreenTex && // don't work to release empty textures
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index f57c82d..666cdbf 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -29,21 +29,10 @@ void WinOpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics*
 rtl::Reference<OpenGLContext> WinOpenGLSalGraphicsImpl::CreateWinContext()
 {
     rtl::Reference<OpenGLContext> pContext = OpenGLContext::Create();
-    pContext->requestSingleBufferedRendering();
     pContext->init( mrParent.mhLocalDC, mrParent.mhWnd );
     return pContext;
 }
 
-bool WinOpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> &pContext )
-{
-    if( !pContext.is() || !pContext->isInitialized() || IsForeignContext( pContext ) )
-        return false;
-    if( IsOffscreen() )
-        return true;
-    return pContext->getOpenGLWindow().hWnd == mrParent.mhWnd &&
-           pContext->getOpenGLWindow().hDC == mrParent.mhLocalDC;
-}
-
 void WinOpenGLSalGraphicsImpl::Init()
 {
     if ( !IsOffscreen() && mpContext.is() && mpContext->isInitialized() &&
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 20c45ff..602c33e 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -58,18 +58,6 @@ rtl::Reference<OpenGLContext> X11OpenGLSalGraphicsImpl::CreateWinContext()
     return pContext;
 }
 
-bool X11OpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> &pContext )
-{
-    X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
-
-    if( !pContext->isInitialized() || IsForeignContext( pContext ) )
-        return false;
-    if( !pProvider )
-        return pContext->getOpenGLWindow().win != None;
-    else
-        return pContext->getOpenGLWindow().win == pProvider->GetX11Window();
-}
-
 void X11OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
 {
     OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? static_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : static_cast< OpenGLSalGraphicsImpl *>(mrParent.GetImpl());
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 6670489..9d840d7 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -124,11 +124,6 @@ void OpenGLContext::requestLegacyContext()
     mbRequestLegacyContext = true;
 }
 
-void OpenGLContext::requestSingleBufferedRendering()
-{
-    mbUseDoubleBufferedRendering = false;
-}
-
 #if defined( _WIN32 )
 static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
commit a6c5cfa56d2bdebb899d05f702c29d79c39be299
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 15:38:03 2015 +0000

    vcl: de-layer needless module fragmentation in gtk and gtk3.
    
    Change-Id: I299fa196e960f14e9480e2ac1047bcdcc95b1021

diff --git a/vcl/Executable_xid_fullscreen_on_all_monitors.mk b/vcl/Executable_xid_fullscreen_on_all_monitors.mk
index ee17162..296436a 100644
--- a/vcl/Executable_xid_fullscreen_on_all_monitors.mk
+++ b/vcl/Executable_xid_fullscreen_on_all_monitors.mk
@@ -16,7 +16,7 @@ $(eval $(call gb_Executable_add_libs,xid-fullscreen-on-all-monitors,\
 endif
 
 $(eval $(call gb_Executable_add_cobjects,xid-fullscreen-on-all-monitors,\
-    vcl/unx/gtk/window/xid_fullscreen_on_all_monitors \
+    vcl/unx/gtk/xid_fullscreen_on_all_monitors \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/vcl/Library_vclplug_gtk.mk b/vcl/Library_vclplug_gtk.mk
index ec7f2f8..8a61131 100644
--- a/vcl/Library_vclplug_gtk.mk
+++ b/vcl/Library_vclplug_gtk.mk
@@ -23,7 +23,7 @@ $(eval $(call gb_Library_set_include,vclplug_gtk,\
     $$(INCLUDE) \
     -I$(SRCDIR)/vcl/inc \
     -I$(SRCDIR)/vcl/unx \
-    -I$(SRCDIR)/vcl/unx/gtk/inc \
+    -I$(SRCDIR)/vcl/unx/gtk \
 ))
 
 $(eval $(call gb_Library_add_defs,vclplug_gtk,\
@@ -96,12 +96,12 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk,\
     vcl/unx/gtk/a11y/atkvalue \
     vcl/unx/gtk/a11y/atkwindow \
     vcl/unx/gtk/a11y/atkwrapper \
-    vcl/unx/gtk/app/gtkdata \
-    vcl/unx/gtk/app/gtkinst \
-    vcl/unx/gtk/app/gtksys \
-    vcl/unx/gtk/gdi/salnativewidgets-gtk \
-    vcl/unx/gtk/window/gtksalframe \
-    vcl/unx/gtk/window/gtkobject \
+    vcl/unx/gtk/gtkdata \
+    vcl/unx/gtk/gtkinst \
+    vcl/unx/gtk/gtksys \
+    vcl/unx/gtk/salnativewidgets-gtk \
+    vcl/unx/gtk/gtksalframe \
+    vcl/unx/gtk/gtkobject \
     vcl/unx/gtk/fpicker/resourceprovider \
     vcl/unx/gtk/fpicker/SalGtkPicker \
     vcl/unx/gtk/fpicker/SalGtkFilePicker \
@@ -111,18 +111,18 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk,\
 ifneq ($(ENABLE_DBUS),)
 ifneq ($(ENABLE_GIO),)
 $(eval $(call gb_Library_add_exception_objects,vclplug_gtk,\
-    vcl/unx/gtk/window/gloactiongroup \
-    vcl/unx/gtk/window/gtksalmenu \
-    vcl/unx/gtk/window/glomenu \
-    vcl/unx/gtk/window/hudawareness \
+    vcl/unx/gtk/gloactiongroup \
+    vcl/unx/gtk/gtksalmenu \
+    vcl/unx/gtk/glomenu \
+    vcl/unx/gtk/hudawareness \
 ))
 endif
 endif
 
 ifeq ($(ENABLE_GTK_PRINT),TRUE)
 $(eval $(call gb_Library_add_exception_objects,vclplug_gtk,\
-    vcl/unx/gtk/gdi/gtkprintwrapper \
-    vcl/unx/gtk/gdi/salprn-gtk \
+    vcl/unx/gtk/gtkprintwrapper \
+    vcl/unx/gtk/salprn-gtk \
 ))
 endif
 
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index 515a81c..e36dc21 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -29,7 +29,7 @@ $(eval $(call gb_Library_set_include,vclplug_gtk3,\
     $$(INCLUDE) \
     -I$(SRCDIR)/vcl/inc \
     -I$(SRCDIR)/vcl/unx \
-    -I$(SRCDIR)/vcl/unx/gtk3/inc \
+    -I$(SRCDIR)/vcl/unx/gtk3 \
 ))
 
 $(eval $(call gb_Library_add_cxxflags,vclplug_gtk3,\
@@ -98,21 +98,21 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
     vcl/unx/gtk3/a11y/gtk3atkvalue \
     vcl/unx/gtk3/a11y/gtk3atkwindow \
     vcl/unx/gtk3/a11y/gtk3atkwrapper \
-    vcl/unx/gtk3/app/gtk3gtkdata \
-    vcl/unx/gtk3/app/gtk3gtkinst \
-    vcl/unx/gtk3/app/gtk3gtksys \
-    vcl/unx/gtk3/app/gtk3fpicker \
-    vcl/unx/gtk3/gdi/cairo_gtk3_cairo \
-    vcl/unx/gtk3/gdi/gtk3cairotextrender \
-    vcl/unx/gtk3/gdi/gtk3gtkprintwrapper \
-    vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk \
-    vcl/unx/gtk3/gdi/gtk3salprn-gtk \
-    vcl/unx/gtk3/window/gtk3gtkframe \
-    vcl/unx/gtk3/window/gtk3gtkobject \
-	vcl/unx/gtk3/window/gtk3gtksalmenu \
-	vcl/unx/gtk3/window/gtk3glomenu \
-	vcl/unx/gtk3/window/gtk3gloactiongroup \
-    vcl/unx/gtk3/window/gtk3hudawareness \
+    vcl/unx/gtk3/gtk3gtkdata \
+    vcl/unx/gtk3/gtk3gtkinst \
+    vcl/unx/gtk3/gtk3gtksys \
+    vcl/unx/gtk3/gtk3fpicker \
+    vcl/unx/gtk3/cairo_gtk3_cairo \
+    vcl/unx/gtk3/gtk3cairotextrender \
+    vcl/unx/gtk3/gtk3gtkprintwrapper \
+    vcl/unx/gtk3/gtk3salnativewidgets-gtk \
+    vcl/unx/gtk3/gtk3salprn-gtk \
+    vcl/unx/gtk3/gtk3gtkframe \
+    vcl/unx/gtk3/gtk3gtkobject \
+	vcl/unx/gtk3/gtk3gtksalmenu \
+	vcl/unx/gtk3/gtk3glomenu \
+	vcl/unx/gtk3/gtk3gloactiongroup \
+    vcl/unx/gtk3/gtk3hudawareness \
 ))
 
 ifeq ($(OS),LINUX)
diff --git a/vcl/unx/gtk/window/gloactiongroup.cxx b/vcl/unx/gtk/gloactiongroup.cxx
similarity index 100%
rename from vcl/unx/gtk/window/gloactiongroup.cxx
rename to vcl/unx/gtk/gloactiongroup.cxx
diff --git a/vcl/unx/gtk/window/glomenu.cxx b/vcl/unx/gtk/glomenu.cxx
similarity index 100%
rename from vcl/unx/gtk/window/glomenu.cxx
rename to vcl/unx/gtk/glomenu.cxx
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx
similarity index 100%
rename from vcl/unx/gtk/app/gtkdata.cxx
rename to vcl/unx/gtk/gtkdata.cxx
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
similarity index 100%
rename from vcl/unx/gtk/app/gtkinst.cxx
rename to vcl/unx/gtk/gtkinst.cxx
diff --git a/vcl/unx/gtk/window/gtkobject.cxx b/vcl/unx/gtk/gtkobject.cxx
similarity index 100%
rename from vcl/unx/gtk/window/gtkobject.cxx
rename to vcl/unx/gtk/gtkobject.cxx
diff --git a/vcl/unx/gtk/gdi/gtkprintwrapper.cxx b/vcl/unx/gtk/gtkprintwrapper.cxx
similarity index 100%
rename from vcl/unx/gtk/gdi/gtkprintwrapper.cxx
rename to vcl/unx/gtk/gtkprintwrapper.cxx
diff --git a/vcl/unx/gtk/inc/gtkprintwrapper.hxx b/vcl/unx/gtk/gtkprintwrapper.hxx
similarity index 100%
rename from vcl/unx/gtk/inc/gtkprintwrapper.hxx
rename to vcl/unx/gtk/gtkprintwrapper.hxx
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
similarity index 100%
rename from vcl/unx/gtk/window/gtksalframe.cxx
rename to vcl/unx/gtk/gtksalframe.cxx
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
similarity index 100%
rename from vcl/unx/gtk/window/gtksalmenu.cxx
rename to vcl/unx/gtk/gtksalmenu.cxx
diff --git a/vcl/unx/gtk/app/gtksys.cxx b/vcl/unx/gtk/gtksys.cxx
similarity index 100%
rename from vcl/unx/gtk/app/gtksys.cxx
rename to vcl/unx/gtk/gtksys.cxx
diff --git a/vcl/unx/gtk/window/hudawareness.cxx b/vcl/unx/gtk/hudawareness.cxx
similarity index 100%
rename from vcl/unx/gtk/window/hudawareness.cxx
rename to vcl/unx/gtk/hudawareness.cxx
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx
similarity index 100%
rename from vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
rename to vcl/unx/gtk/salnativewidgets-gtk.cxx
diff --git a/vcl/unx/gtk/gdi/salprn-gtk.cxx b/vcl/unx/gtk/salprn-gtk.cxx
similarity index 100%
rename from vcl/unx/gtk/gdi/salprn-gtk.cxx
rename to vcl/unx/gtk/salprn-gtk.cxx
diff --git a/vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c b/vcl/unx/gtk/xid_fullscreen_on_all_monitors.c
similarity index 100%
rename from vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c
rename to vcl/unx/gtk/xid_fullscreen_on_all_monitors.c
diff --git a/vcl/unx/gtk3/app/gtk3fpicker.cxx b/vcl/unx/gtk3/app/gtk3fpicker.cxx
deleted file mode 100644
index 336d47a..0000000
--- a/vcl/unx/gtk3/app/gtk3fpicker.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "../../gtk/fpicker/resourceprovider.cxx"
-#include "../../gtk/fpicker/SalGtkPicker.cxx"
-#include "../../gtk/fpicker/SalGtkFilePicker.cxx"
-#include "../../gtk/fpicker/SalGtkFolderPicker.cxx"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gdi/cairo_gtk3_cairo.cxx b/vcl/unx/gtk3/cairo_gtk3_cairo.cxx
similarity index 100%
rename from vcl/unx/gtk3/gdi/cairo_gtk3_cairo.cxx
rename to vcl/unx/gtk3/cairo_gtk3_cairo.cxx
diff --git a/vcl/unx/gtk3/gdi/cairo_gtk3_cairo.hxx b/vcl/unx/gtk3/cairo_gtk3_cairo.hxx
similarity index 100%
rename from vcl/unx/gtk3/gdi/cairo_gtk3_cairo.hxx
rename to vcl/unx/gtk3/cairo_gtk3_cairo.hxx
diff --git a/vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx b/vcl/unx/gtk3/gtk3cairotextrender.cxx
similarity index 100%
rename from vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx
rename to vcl/unx/gtk3/gtk3cairotextrender.cxx
diff --git a/vcl/unx/gtk3/gdi/gtk3cairotextrender.hxx b/vcl/unx/gtk3/gtk3cairotextrender.hxx
similarity index 100%
rename from vcl/unx/gtk3/gdi/gtk3cairotextrender.hxx
rename to vcl/unx/gtk3/gtk3cairotextrender.hxx
diff --git a/vcl/unx/gtk3/gdi/gtk3gtkprintwrapper.cxx b/vcl/unx/gtk3/gtk3fpicker.cxx
similarity index 67%
rename from vcl/unx/gtk3/gdi/gtk3gtkprintwrapper.cxx
rename to vcl/unx/gtk3/gtk3fpicker.cxx
index f456b6e..9b83c57 100644
--- a/vcl/unx/gtk3/gdi/gtk3gtkprintwrapper.cxx
+++ b/vcl/unx/gtk3/gtk3fpicker.cxx
@@ -7,6 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "../../gtk/gdi/gtkprintwrapper.cxx"
+#include "../gtk/fpicker/resourceprovider.cxx"
+#include "../gtk/fpicker/SalGtkPicker.cxx"
+#include "../gtk/fpicker/SalGtkFilePicker.cxx"
+#include "../gtk/fpicker/SalGtkFolderPicker.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/window/gtk3gloactiongroup.cxx b/vcl/unx/gtk3/gtk3gloactiongroup.cxx
similarity index 74%
rename from vcl/unx/gtk3/window/gtk3gloactiongroup.cxx
rename to vcl/unx/gtk3/gtk3gloactiongroup.cxx
index 7f26437..749f543 100644
--- a/vcl/unx/gtk3/window/gtk3gloactiongroup.cxx
+++ b/vcl/unx/gtk3/gtk3gloactiongroup.cxx
@@ -1,5 +1,5 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
-#include "../../gtk/window/gloactiongroup.cxx"
+#include "../gtk/gloactiongroup.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/window/gtk3glomenu.cxx b/vcl/unx/gtk3/gtk3glomenu.cxx
similarity index 77%
rename from vcl/unx/gtk3/window/gtk3glomenu.cxx
rename to vcl/unx/gtk3/gtk3glomenu.cxx
index 6ca68cd..e894b09 100644
--- a/vcl/unx/gtk3/window/gtk3glomenu.cxx
+++ b/vcl/unx/gtk3/gtk3glomenu.cxx
@@ -1,5 +1,5 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
-#include "../../gtk/window/glomenu.cxx"
+#include "../gtk/glomenu.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/app/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx
similarity index 91%
rename from vcl/unx/gtk3/app/gtk3gtkdata.cxx
rename to vcl/unx/gtk3/gtk3gtkdata.cxx
index 28745a4..df53f34 100644
--- a/vcl/unx/gtk3/app/gtk3gtkdata.cxx
+++ b/vcl/unx/gtk3/gtk3gtkdata.cxx
@@ -7,6 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "../../gtk/app/gtkdata.cxx"
+#include "../gtk/gtkdata.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
new file mode 100644
index 0000000..26d1a07
--- /dev/null
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../gtk/gtksalframe.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/app/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
similarity index 99%
rename from vcl/unx/gtk3/app/gtk3gtkinst.cxx
rename to vcl/unx/gtk3/gtk3gtkinst.cxx
index 8482ed4..9f15db0 100644
--- a/vcl/unx/gtk3/app/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "../../gtk/app/gtkinst.cxx"
+#include "../gtk/gtkinst.cxx"
 
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include "com/sun/star/lang/XServiceInfo.hpp"
diff --git a/vcl/unx/gtk3/window/gtk3gtkobject.cxx b/vcl/unx/gtk3/gtk3gtkobject.cxx
similarity index 90%
rename from vcl/unx/gtk3/window/gtk3gtkobject.cxx
rename to vcl/unx/gtk3/gtk3gtkobject.cxx
index efbafe71..96c1527 100644
--- a/vcl/unx/gtk3/window/gtk3gtkobject.cxx
+++ b/vcl/unx/gtk3/gtk3gtkobject.cxx
@@ -7,6 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "../../gtk/window/gtkobject.cxx"
+#include "../gtk/gtkobject.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtk3gtkprintwrapper.cxx b/vcl/unx/gtk3/gtk3gtkprintwrapper.cxx
new file mode 100644
index 0000000..edefca9
--- /dev/null
+++ b/vcl/unx/gtk3/gtk3gtkprintwrapper.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../gtk/gtkprintwrapper.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/window/gtk3gtksalmenu.cxx b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
similarity index 75%
rename from vcl/unx/gtk3/window/gtk3gtksalmenu.cxx
rename to vcl/unx/gtk3/gtk3gtksalmenu.cxx
index ef288ba..d465594 100644
--- a/vcl/unx/gtk3/window/gtk3gtksalmenu.cxx
+++ b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
@@ -1,5 +1,5 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
-#include "../../gtk/window/gtksalmenu.cxx"
+#include "../gtk/gtksalmenu.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/app/gtk3gtksys.cxx b/vcl/unx/gtk3/gtk3gtksys.cxx
similarity index 91%
rename from vcl/unx/gtk3/app/gtk3gtksys.cxx
rename to vcl/unx/gtk3/gtk3gtksys.cxx
index 2fcec09..2406e0a 100644
--- a/vcl/unx/gtk3/app/gtk3gtksys.cxx
+++ b/vcl/unx/gtk3/gtk3gtksys.cxx
@@ -7,6 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "../../gtk/app/gtksys.cxx"
+#include "../gtk/gtksys.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/window/gtk3hudawareness.cxx b/vcl/unx/gtk3/gtk3hudawareness.cxx
similarity index 74%
rename from vcl/unx/gtk3/window/gtk3hudawareness.cxx
rename to vcl/unx/gtk3/gtk3hudawareness.cxx
index 76ea94a..3d928f0 100644
--- a/vcl/unx/gtk3/window/gtk3hudawareness.cxx
+++ b/vcl/unx/gtk3/gtk3hudawareness.cxx
@@ -1,4 +1,4 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-#include "../../gtk/window/hudawareness.cxx"
+#include "../gtk/hudawareness.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
similarity index 100%
rename from vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
rename to vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
diff --git a/vcl/unx/gtk3/gdi/gtk3salprn-gtk.cxx b/vcl/unx/gtk3/gtk3salprn-gtk.cxx
similarity index 90%
rename from vcl/unx/gtk3/gdi/gtk3salprn-gtk.cxx
rename to vcl/unx/gtk3/gtk3salprn-gtk.cxx
index 708c0ba..16bf17c 100644
--- a/vcl/unx/gtk3/gdi/gtk3salprn-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salprn-gtk.cxx
@@ -7,6 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "../../gtk/gdi/salprn-gtk.cxx"
+#include "../gtk/salprn-gtk.cxx"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/inc/gtkprintwrapper.hxx b/vcl/unx/gtk3/gtkprintwrapper.hxx
similarity index 92%
rename from vcl/unx/gtk3/inc/gtkprintwrapper.hxx
rename to vcl/unx/gtk3/gtkprintwrapper.hxx
index 032080d..9ee46e7 100644
--- a/vcl/unx/gtk3/inc/gtkprintwrapper.hxx
+++ b/vcl/unx/gtk3/gtkprintwrapper.hxx
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_VCL_UNX_GTK3_INC_GTKPRINTWRAPPER_HXX
 #define INCLUDED_VCL_UNX_GTK3_INC_GTKPRINTWRAPPER_HXX
 
-#include "../../gtk/inc/gtkprintwrapper.hxx"
+#include "../gtk/gtkprintwrapper.hxx"
 
 #endif // INCLUDED_VCL_UNX_GTK3_INC_GTKPRINTWRAPPER_HXX
 
diff --git a/vcl/unx/gtk3/window/gtk3gtkframe.cxx b/vcl/unx/gtk3/window/gtk3gtkframe.cxx
deleted file mode 100644
index 5710d50..0000000
--- a/vcl/unx/gtk3/window/gtk3gtkframe.cxx
+++ /dev/null
@@ -1,12 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "../../gtk/window/gtksalframe.cxx"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9801b2c24c3115b52de3f6958eb462648d702491
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 14:51:28 2015 +0000

    opengl: remove unused mbPixmap & glPix members.
    
    We use textures bound to FBO's for everything in recent times.
    
    Change-Id: I7c9068d75b3653a2ceff0056e2ade1f27955422f
    Reviewed-on: https://gerrit.libreoffice.org/19995
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 82a9d63..28db7f9 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -84,7 +84,6 @@ struct GLWindow
 #endif
     XVisualInfo*       vi;
     GLXContext         ctx;
-    GLXPixmap           glPix;
 
     bool HasGLXExtension( const char* name ) const;
     const char*             GLXExtensions;
@@ -115,7 +114,6 @@ struct GLWindow
 #endif
         vi(nullptr),
         ctx(nullptr),
-        glPix(0),
         GLXExtensions(nullptr),
 #endif
         bpp(0),
@@ -230,9 +228,6 @@ private:
     int  mnRefCount;
     bool mbRequestLegacyContext;
     bool mbUseDoubleBufferedRendering;
-#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
-    bool mbPixmap; // is a pixmap instead of a window
-#endif
 
     int mnFramebufferCount;
     OpenGLFramebuffer* mpCurrentFramebuffer;
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 6929bbc..6670489 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -71,10 +71,6 @@ OpenGLContext::OpenGLContext():
 {
     VCL_GL_INFO("vcl.opengl", "new context: " << this);
 
-#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
-    mbPixmap = false;
-#endif
-
     ImplSVData* pSVData = ImplGetSVData();
     if( pSVData->maGDIData.mpLastContext )
     {
@@ -727,7 +723,7 @@ bool OpenGLContext::ImplInit()
         pSharedCtx = g_vShareList.front();
 
 #ifdef DBG_UTIL
-    if (!mbPixmap && glXCreateContextAttribsARB && !mbRequestLegacyContext)
+    if (glXCreateContextAttribsARB && !mbRequestLegacyContext)
     {
         int best_fbc = -1;
         GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc, mbUseDoubleBufferedRendering, true);
@@ -772,7 +768,7 @@ bool OpenGLContext::ImplInit()
         return false;
     }
 
-    if( !glXMakeCurrent( m_aGLWin.dpy, mbPixmap ? m_aGLWin.glPix : m_aGLWin.win, m_aGLWin.ctx ) )
+    if( !glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ) )
     {
         SAL_WARN("vcl.opengl", "unable to select current GLX context");
         return false;
@@ -788,12 +784,7 @@ bool OpenGLContext::ImplInit()
     SAL_INFO("vcl.opengl", "available GL  extensions: " << m_aGLWin.GLExtensions);
 
     XWindowAttributes xWinAttr;
-    if( mbPixmap )
-    {
-        m_aGLWin.Width = 0; // FIXME: correct ?
-        m_aGLWin.Height = 0;
-    }
-    else if( !XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr ) )
+    if( !XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr ) )
     {
         SAL_WARN("vcl.opengl", "Failed to get window attributes on " << m_aGLWin.win);
         m_aGLWin.Width = 0;
@@ -1278,9 +1269,6 @@ void OpenGLContext::reset()
             SAL_WARN("vcl.opengl", "glError: " << glGetError());
         }
         glXDestroyContext(m_aGLWin.dpy, m_aGLWin.ctx);
-
-        if (mbPixmap && m_aGLWin.glPix != None)
-            glXDestroyPixmap(m_aGLWin.dpy, m_aGLWin.glPix);
         m_aGLWin.ctx = nullptr;
     }
 #endif
@@ -1350,17 +1338,16 @@ bool OpenGLContext::isCurrent()
     OpenGLZone aZone;
 
 #if defined( WNT )
-    return (wglGetCurrentContext() == m_aGLWin.hRC &&
-            wglGetCurrentDC() == m_aGLWin.hDC);
+    return wglGetCurrentContext() == m_aGLWin.hRC &&
+           wglGetCurrentDC() == m_aGLWin.hDC;
 #elif defined( MACOSX )
     (void) this; // loplugin:staticmethods
     return false;
 #elif defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS)
     return false;
 #elif defined( UNX )
-    GLXDrawable nDrawable = mbPixmap ? m_aGLWin.glPix : m_aGLWin.win;
-    return (m_aGLWin.ctx && glXGetCurrentContext() == m_aGLWin.ctx &&
-            glXGetCurrentDrawable() == nDrawable);
+    return m_aGLWin.ctx && glXGetCurrentContext() == m_aGLWin.ctx &&
+           glXGetCurrentDrawable() == m_aGLWin.win;
 #endif
 }
 
@@ -1432,10 +1419,10 @@ void OpenGLContext::makeCurrent()
 
     if (m_aGLWin.dpy)
     {
-        GLXDrawable nDrawable = mbPixmap ? m_aGLWin.glPix : m_aGLWin.win;
-        if (!glXMakeCurrent( m_aGLWin.dpy, nDrawable, m_aGLWin.ctx ))
+        if (!glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ))
         {
-            SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed on drawable " << nDrawable << " pixmap? " << mbPixmap);
+            SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed "
+                     "on drawable " << m_aGLWin.win);
             return;
         }
     }
@@ -1497,7 +1484,7 @@ void OpenGLContext::swapBuffers()
 #elif defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS)
     // nothing
 #elif defined( UNX )
-    glXSwapBuffers(m_aGLWin.dpy, mbPixmap ? m_aGLWin.glPix : m_aGLWin.win);
+    glXSwapBuffers(m_aGLWin.dpy, m_aGLWin.win);
 #endif
 }
 
commit 4ad05823f6c2edb0f5fbf5794b2deb6c163686a2
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 14:16:32 2015 +0000

    Add comment to 'direct' parameter: un-related to double-buffering.
    
    Change-Id: I07002fd73fc004439aea75c5aca8ca3700ec1079
    Reviewed-on: https://gerrit.libreoffice.org/19996
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list