[Libreoffice-commits] core.git: 6 commits - bin/check-merged.sh include/vcl vcl/inc vcl/opengl vcl/source vcl/unx

Jan Holesovsky kendy at collabora.com
Tue Nov 18 06:44:32 PST 2014


 bin/check-merged.sh                  |   36 -------------------------
 include/vcl/opengl/OpenGLContext.hxx |    1 
 vcl/inc/opengl/contextprovider.hxx   |   28 --------------------
 vcl/inc/opengl/salbmp.hxx            |    5 ++-
 vcl/inc/salgdi.hxx                   |    4 ++
 vcl/inc/unx/salgdi.h                 |    7 -----
 vcl/opengl/gdiimpl.cxx               |   19 +++++++------
 vcl/opengl/salbmp.cxx                |   49 ++++++++++++++++-------------------
 vcl/opengl/scale.cxx                 |    1 
 vcl/source/gdi/salgdilayout.cxx      |   13 ++++++++-
 vcl/source/opengl/OpenGLContext.cxx  |   46 ++++++++++++++++++++++++++++----
 vcl/unx/generic/gdi/salgdi.cxx       |    9 ------
 12 files changed, 95 insertions(+), 123 deletions(-)

New commits:
commit 4066cc6bcba2c2e8d9529a2557870e384756a098
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 18 15:30:24 2014 +0100

    Kill check-merged.sh, 'git cherry' actually gives better results.
    
    Change-Id: Ia4163f77f5267f6cb714369fc9a4cfbb901019df

diff --git a/bin/check-merged.sh b/bin/check-merged.sh
deleted file mode 100755
index 678afe8..0000000
--- a/bin/check-merged.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#! /bin/bash
-#
-# check that master contains all the patches from a branch
-# and list those that are missing
-#
-
-BRANCH="$1"
-[ -z "$BRANCH" ] && {
-    cat 1>&2 << EOF
-check-merged.sh branchname
-
-Checks that all the patches from branch 'branchname' are in master, and
-reports the commits that are not.
-
-The check is based on the Change-Id's, so if some commits are missing it, they
-won't be detected as missing.
-EOF
-    exit 1;
-}
-
-function collect_change_ids {
-    git log `git merge-base origin/master "$1"`.."$1" | \
-        sed 's/^commit /XXXcommitXXX/g' | \
-        tr '\n' ';' | \
-        sed 's/XXXcommitXXX/\n/g' | \
-        sed -e 's/;.*Change-Id://' -e 's/;.*$//' | \
-        grep -v '^$'> "$2"
-}
-
-collect_change_ids "$BRANCH" /tmp/check-merged.branch
-collect_change_ids "origin/master" /tmp/check-merged.master
-
-cat /tmp/check-merged.branch | \
-    while read COMMIT CHID ; do
-        [ -n "$CHID" -a "$CHID" != " " ] && grep -q "$CHID" /tmp/check-merged.master || echo "$COMMIT not in origin/master"
-    done
commit 4bf891dbc2ca11c5990a71bcefe771b9ce813074
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 18 11:45:40 2014 +0100

    windows opengl: Share the contexts as we do on Linux.
    
    Change-Id: Ic58cca612cdf8f73170c18573917465bf34a187c

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 215f5fe..60746df1 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -31,6 +31,7 @@
 
 #if defined( _WIN32 )
 #include <GL/glext.h>
+#include <GL/wglew.h>
 #include <GL/wglext.h>
 #elif defined( MACOSX )
 #include <OpenGL/OpenGL.h>
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 67e4c5f..d30ac17 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -29,8 +29,11 @@
 
 using namespace com::sun::star;
 
+// TODO use rtl::Static instead of 'static'
 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
-static std::vector< GLXContext > vShareList;
+static std::vector<GLXContext> vShareList;
+#elif defined(WNT)
+static std::vector<HGLRC> vShareList;
 #endif
 
 GLWindow::~GLWindow()
@@ -58,6 +61,8 @@ OpenGLContext::~OpenGLContext()
 #if defined( WNT )
     if (m_aGLWin.hRC)
     {
+        vShareList.erase(std::remove(vShareList.begin(), vShareList.end(), m_aGLWin.hRC));
+
         wglMakeCurrent( m_aGLWin.hDC, 0 );
         wglDeleteContext( m_aGLWin.hRC );
         ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC );
@@ -655,13 +660,13 @@ bool OpenGLContext::ImplInit()
 
         if (best_fbc != -1)
         {
-            int nContextAttribs[] =
+            int pContextAttribs[] =
             {
                 GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
                 GLX_CONTEXT_MINOR_VERSION_ARB, 2,
                 None
             };
-            m_aGLWin.ctx = glXCreateContextAttribsARB(m_aGLWin.dpy, pFBC[best_fbc], pSharedCtx, GL_TRUE, nContextAttribs);
+            m_aGLWin.ctx = glXCreateContextAttribsARB(m_aGLWin.dpy, pFBC[best_fbc], pSharedCtx, GL_TRUE, pContextAttribs);
             SAL_INFO_IF(m_aGLWin.ctx, "vcl.opengl", "created a 3.2 core context");
         }
         else
@@ -825,7 +830,7 @@ bool OpenGLContext::ImplInit()
         return false;
     }
 
-    m_aGLWin.hRC = wglCreateContext(m_aGLWin.hDC);
+    HGLRC hTempRC = wglCreateContext(m_aGLWin.hDC);
     if (m_aGLWin.hRC == NULL)
     {
         ImplWriteLastError(GetLastError(), "wglCreateContext in OpenGLContext::ImplInit");
@@ -833,19 +838,48 @@ bool OpenGLContext::ImplInit()
         return false;
     }
 
-    if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
+    if (!wglMakeCurrent(m_aGLWin.hDC, hTempRC))
     {
         ImplWriteLastError(GetLastError(), "wglMakeCurrent in OpenGLContext::ImplInit");
         SAL_WARN("vcl.opengl", "wglMakeCurrent failed");
         return false;
     }
 
+    if (!InitGLEW())
+        return false;
+
+    HGLRC hSharedCtx = 0;
+    if (!vShareList.empty())
+        hSharedCtx = vShareList.front();
+
+    // now setup the shared context; this needs a temporary context already
+    // set up in order to work
+    m_aGLWin.hRC = wglCreateContextAttribsARB(m_aGLWin.hDC, hSharedCtx, NULL);
+    if (m_aGLWin.hRC == 0)
+    {
+        ImplWriteLastError(GetLastError(), "wglCreateContextAttribsARB in OpenGLContext::ImplInit");
+        SAL_WARN("vcl.opengl", "wglCreateContextAttribsARB failed");
+        return false;
+    }
+
+    wglMakeCurrent(NULL, NULL);
+    wglDeleteContext(hTempRC);
+
+    if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
+    {
+        ImplWriteLastError(GetLastError(), "wglMakeCurrent (with shared context) in OpenGLContext::ImplInit");
+        SAL_WARN("vcl.opengl", "wglMakeCurrent failed");
+        return false;
+    }
+
+    vShareList.push_back(m_aGLWin.hRC);
+
     RECT clientRect;
     GetClientRect(WindowFromDC(m_aGLWin.hDC), &clientRect);
     m_aGLWin.Width = clientRect.right - clientRect.left;
     m_aGLWin.Height = clientRect.bottom - clientRect.top;
 
-    return InitGLEW();
+    return true;
 }
 
 #elif defined( MACOSX )
commit e6592aaa5c9b0f83bf948ce8a2e1ab5029cc3ef5
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Nov 18 11:56:00 2014 +0000

    vcl: remove old GetOpenGLContext method.
    
    Change-Id: I1959b2e4aabdee92472fed31905fea44b989230d

diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 6bf4c04..5caf7b9 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -32,8 +32,6 @@
 #include "sallayout.hxx"
 #include "vclpluginapi.h"
 
-#include "opengl/contextprovider.hxx"
-
 #include <boost/scoped_ptr.hpp>
 
 #include <deque>
@@ -300,9 +298,6 @@ public:
                                 unsigned int w, unsigned int h,
                                 int dest_x, int dest_y );
     static void releaseGlyphPeer();
-
-public:
-    virtual OpenGLContext* GetOpenGLContext() const SAL_OVERRIDE;
 };
 
 inline const SalDisplay *X11SalGraphics::GetDisplay() const
commit 878cea9134768cadfc57fe70baeb4b9a8bf4dfbf
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 18 09:07:31 2014 +0100

    windows opengl: Provide the context to textures everywhere where we have it.
    
    Change-Id: Ib820326fdc752d0893840bad3eb7f1369469f796

diff --git a/vcl/inc/opengl/contextprovider.hxx b/vcl/inc/opengl/contextprovider.hxx
deleted file mode 100644
index 47eb98c..0000000
--- a/vcl/inc/opengl/contextprovider.hxx
+++ /dev/null
@@ -1,28 +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/.
- */
-
-#ifndef INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX
-#define INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX
-
-#include "vclpluginapi.h"
-
-#include <vcl/opengl/OpenGLContext.hxx>
-
-class VCLPLUG_GEN_PUBLIC OpenGLContextProvider
-{
-public:
-    virtual ~OpenGLContextProvider() {};
-
-    /* Get the OpenGL context provided by this instance */
-    virtual OpenGLContext* GetOpenGLContext() const = 0;
-};
-
-#endif // INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 98fc2fe..c862672 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -52,7 +52,7 @@ private:
     int                                 mnBufHeight;
     std::deque< OpenGLSalBitmapOp* >    maPendingOps;
 
-    bool makeCurrent();
+    void makeCurrent();
 
 public:
     OpenGLSalBitmap();
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 4a567f5..95920a0 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -44,6 +44,7 @@ class SalLayout;
 class ImplLayoutArgs;
 class Rectangle;
 class FontSubsetInfo;
+class OpenGLContext;
 class OutputDevice;
 class ServerFontLayout;
 struct SystemGraphicsData;
@@ -85,6 +86,9 @@ public:
 
     virtual SalGraphicsImpl*    GetImpl() const = 0;
 
+    /// Check that our mpImpl is OpenGL and return the context, otherwise NULL.
+    virtual OpenGLContext*      GetOpenGLContext() const;
+
     void                        setAntiAliasB2DDraw(bool bNew) { m_bAntiAliasB2DDraw = bNew; }
     bool                        getAntiAliasB2DDraw() const { return m_bAntiAliasB2DDraw; }
 
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 6b0e2be..6bf4c04 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -62,7 +62,7 @@ namespace basegfx {
     class B2DTrapezoid;
 }
 
-class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics, public OpenGLContextProvider
+class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
 {
     friend class ServerFontLayout;
     friend class X11SalGraphicsImpl;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 78bcf07..c664d7e 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -27,7 +27,6 @@
 #include "svdata.hxx"
 #include "salgdi.hxx"
 
-#include "opengl/contextprovider.hxx"
 #include "opengl/salbmp.hxx"
 
 static bool isValidBitCount( sal_uInt16 nBitCount )
@@ -407,8 +406,7 @@ GLuint OpenGLSalBitmap::CreateTexture()
         }
     }
 
-    if( !makeCurrent() )
-        return 0;
+    makeCurrent();
 
     maTexture = OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData );
     SAL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
@@ -470,21 +468,13 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
     return mnBits;
 }
 
-bool OpenGLSalBitmap::makeCurrent()
+void OpenGLSalBitmap::makeCurrent()
 {
     if (!mpContext || !mpContext->isInitialized())
-    {
-        OpenGLContextProvider *pProvider;
-        pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
-        if( pProvider == NULL )
-        {
-            SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
-            return false;
-        }
-        mpContext = pProvider->GetOpenGLContext();
-    }
+        mpContext = ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
+
+    assert(mpContext && "Couldn't get default OpenGL context provider");
     mpContext->makeCurrent();
-    return true;
 }
 
 BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
@@ -499,8 +489,7 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
 
     if( !maPendingOps.empty() )
     {
-        if (!makeCurrent())
-            return NULL;
+        makeCurrent();
 
         SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" );
         if( !CreateTexture() || !AllocateUserData() || !ReadTexture() )
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index e9bed70..59b39ce 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -27,11 +27,13 @@
 #include <vcl/metaact.hxx>
 #include <vcl/gdimtf.hxx>
 #include <vcl/print.hxx>
+#include <vcl/opengl/OpenGLContext.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/unowrap.hxx>
 #include <vcl/settings.hxx>
 
 #include <window.h>
+#include <openglgdiimpl.hxx>
 #include <outdev.h>
 #include <sallayout.hxx>
 #include <salgdi.hxx>
@@ -43,7 +45,7 @@
 #include <boost/scoped_array.hpp>
 #include <boost/scoped_ptr.hpp>
 
-#include "basegfx/polygon/b2dpolygon.hxx"
+#include <basegfx/polygon/b2dpolygon.hxx>
 
 // The only common SalFrame method
 
@@ -75,6 +77,15 @@ SalGraphics::~SalGraphics()
 {
 }
 
+OpenGLContext* SalGraphics::GetOpenGLContext() const
+{
+    OpenGLSalGraphicsImpl *pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(GetImpl());
+    if (pImpl)
+        return &pImpl->GetOpenGLContext();
+
+    return NULL;
+}
+
 bool SalGraphics::drawTransformedBitmap(
     const basegfx::B2DPoint& /* rNull */,
     const basegfx::B2DPoint& /* rX */,
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index b425cd7..e07b56e 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -173,15 +173,6 @@ void X11SalGraphics::DeInit()
     SetDrawable( None, m_nXScreen );
 }
 
-OpenGLContext* X11SalGraphics::GetOpenGLContext() const
-{
-    OpenGLSalGraphicsImpl *pImpl;
-    pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(mpImpl.get());
-    if( pImpl )
-        return &pImpl->GetOpenGLContext();
-    return NULL;
-}
-
 void X11SalGraphics::SetClipRegion( GC pGC, Region pXReg ) const
 {
     Display *pDisplay = GetXDisplay();
commit fef950f828f6e6da844f3a11ee72d9cd628b1474
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Mon Nov 17 17:36:42 2014 -0500

    vcl: Unbind framebuffer after setting offscreen mode
    
    Change-Id: I057b148f51c8f011cb013e1f06288aec4d9bdb2a

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 67af601..d324397 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -292,6 +292,7 @@ void OpenGLSalGraphicsImpl::SetOffscreen( bool bOffscreen )
         glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
         maOffscreenTex = OpenGLTexture( GetWidth(), GetHeight() );
         glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, maOffscreenTex.Id(), 0 );
+        glBindFramebuffer( GL_FRAMEBUFFER, 0 );
     }
 
     CHECK_GL_ERROR();
commit 89ec42e1d11457c0855a84d1ba651964662140fb
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Mon Nov 17 14:24:31 2014 -0500

    vcl: Execute pending operations on source when copying bitmap
    
    Change-Id: I8a6a5ffe71c9e5f16533fd1f0944d4fd2a051c73

diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 9995645..98fc2fe 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -84,10 +84,11 @@ public:
 public:
 
     bool            Create( OpenGLContext& rContext, const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight );
-    OpenGLTexture&  GetTexture( OpenGLContext& rContext ) const;
+    OpenGLTexture&  GetTexture() const;
 
 private:
 
+    void            ExecuteOperations();
     GLuint          CreateTexture();
     void            DeleteTexture();
     void            DrawTexture( GLuint nTexture, const SalTwoRect& rPosAry );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index ab6b95f..67af601 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1338,7 +1338,7 @@ void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitm
     assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBitmap));
 
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
-    OpenGLTexture& rTexture = rBitmap.GetTexture( maContext );
+    OpenGLTexture& rTexture = rBitmap.GetTexture();
 
     SAL_INFO( "vcl.opengl", "::drawBitmap" );
     PreDraw();
@@ -1361,8 +1361,8 @@ void OpenGLSalGraphicsImpl::drawBitmap(
 {
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
     const OpenGLSalBitmap& rMask = static_cast<const OpenGLSalBitmap&>(rMaskBitmap);
-    OpenGLTexture& rTexture( rBitmap.GetTexture( maContext ) );
-    OpenGLTexture& rMaskTex( rMask.GetTexture( maContext ) );
+    OpenGLTexture& rTexture( rBitmap.GetTexture() );
+    OpenGLTexture& rMaskTex( rMask.GetTexture() );
 
     SAL_INFO( "vcl.opengl", "::drawBitmap with MASK" );
     PreDraw();
@@ -1376,7 +1376,7 @@ void OpenGLSalGraphicsImpl::drawMask(
             SalColor nMaskColor )
 {
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
-    OpenGLTexture& rTexture( rBitmap.GetTexture( maContext ) );
+    OpenGLTexture& rTexture( rBitmap.GetTexture() );
 
     SAL_INFO( "vcl.opengl", "::drawMask" );
     PreDraw();
@@ -1491,8 +1491,8 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
 {
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
     const OpenGLSalBitmap& rAlpha = static_cast<const OpenGLSalBitmap&>(rAlphaBitmap);
-    OpenGLTexture& rTexture( rBitmap.GetTexture( maContext ) );
-    OpenGLTexture& rAlphaTex( rAlpha.GetTexture( maContext ) );
+    OpenGLTexture& rTexture( rBitmap.GetTexture() );
+    OpenGLTexture& rAlphaTex( rAlpha.GetTexture() );
 
     SAL_INFO( "vcl.opengl", "::drawAlphaBitmap" );
     PreDraw();
@@ -1506,7 +1506,7 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
             const SalBitmap& rSalBitmap )
 {
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
-    OpenGLTexture& rTexture( rBitmap.GetTexture( maContext ) );
+    OpenGLTexture& rTexture( rBitmap.GetTexture() );
 
     SAL_INFO( "vcl.opengl", "::drawAlphaBitmap" );
     PreDraw();
@@ -1527,11 +1527,11 @@ bool OpenGLSalGraphicsImpl::drawTransformedBitmap(
 {
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSrcBitmap);
     const OpenGLSalBitmap* pMaskBitmap = static_cast<const OpenGLSalBitmap*>(pAlphaBitmap);
-    OpenGLTexture& rTexture( rBitmap.GetTexture( maContext ) );
+    OpenGLTexture& rTexture( rBitmap.GetTexture() );
     OpenGLTexture aMask; // no texture
 
     if( pMaskBitmap != NULL )
-        aMask = pMaskBitmap->GetTexture( maContext );
+        aMask = pMaskBitmap->GetTexture();
 
     SAL_INFO( "vcl.opengl", "::drawTransformedBitmap" );
     PreDraw();
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 15ef1b3..78bcf07 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -130,8 +130,9 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
         mnBufWidth = rSourceBitmap.mnBufWidth;
         mnBufHeight = rSourceBitmap.mnBufHeight;
         maPalette = rSourceBitmap.maPalette;
+        // execute any pending operations on the source bitmap
+        maTexture = rSourceBitmap.GetTexture();
         mpContext = rSourceBitmap.mpContext;
-        maTexture = rSourceBitmap.maTexture;
         mbDirtyTexture = false;
         maUserBuffer = rSourceBitmap.maUserBuffer;
 
@@ -147,13 +148,13 @@ bool OpenGLSalBitmap::Create( const ::com::sun::star::uno::Reference< ::com::sun
     return false;
 }
 
-OpenGLTexture& OpenGLSalBitmap::GetTexture( OpenGLContext& rContext ) const
+OpenGLTexture& OpenGLSalBitmap::GetTexture() const
 {
     OpenGLSalBitmap* pThis = const_cast<OpenGLSalBitmap*>(this);
-    if( !mpContext )
-        pThis->mpContext = &rContext;
     if( !maTexture || mbDirtyTexture )
         pThis->CreateTexture();
+    else if( !maPendingOps.empty() )
+        pThis->ExecuteOperations();
     SAL_INFO( "vcl.opengl", "Got texture " << maTexture.Id() );
     return pThis->maTexture;
 }
@@ -327,6 +328,17 @@ Size OpenGLSalBitmap::GetSize() const
     return aSize;
 }
 
+void OpenGLSalBitmap::ExecuteOperations()
+{
+    makeCurrent();
+    while( !maPendingOps.empty() )
+    {
+        OpenGLSalBitmapOp* pOp = maPendingOps.front();
+        pOp->Execute();
+        maPendingOps.pop_front();
+    }
+}
+
 GLuint OpenGLSalBitmap::CreateTexture()
 {
     SAL_INFO( "vcl.opengl", "::CreateTexture" );
@@ -395,20 +407,16 @@ GLuint OpenGLSalBitmap::CreateTexture()
         }
     }
 
-    makeCurrent();
+    if( !makeCurrent() )
+        return 0;
+
     maTexture = OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData );
     SAL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
 
     if( bAllocated )
         delete[] pData;
 
-    while( !maPendingOps.empty() )
-    {
-        OpenGLSalBitmapOp* pOp = maPendingOps.front();
-        pOp->Execute();
-        maPendingOps.pop_front();
-    }
-
+    ExecuteOperations();
     mbDirtyTexture = false;
 
     CHECK_GL_ERROR();
diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx
index 92fdd3f..741bdd1 100644
--- a/vcl/opengl/scale.cxx
+++ b/vcl/opengl/scale.cxx
@@ -104,6 +104,7 @@ bool OpenGLSalBitmap::ImplScaleFilter(
     OpenGLTexture aNewTex = OpenGLTexture( nNewWidth, nNewHeight );
     glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, aNewTex.Id(), 0 );
 
+    glViewport( 0, 0, nNewWidth, nNewHeight );
     maTexture.Bind();
     nOldFilter = maTexture.GetFilter();
     maTexture.SetFilter( nFilter );


More information about the Libreoffice-commits mailing list