[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl2' - vcl/inc vcl/opengl

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Mon Nov 17 11:34:14 PST 2014


 vcl/inc/opengl/salbmp.hxx |    3 ++-
 vcl/opengl/gdiimpl.cxx    |   18 +++++++++---------
 vcl/opengl/salbmp.cxx     |   32 ++++++++++++++++++++------------
 vcl/opengl/scale.cxx      |    1 +
 4 files changed, 32 insertions(+), 22 deletions(-)

New commits:
commit 67ff07df7d5bcf11da407b775b3fc541622fe297
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 187458b..c9f8d4e 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1339,7 +1339,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();
@@ -1362,8 +1362,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();
@@ -1377,7 +1377,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();
@@ -1492,8 +1492,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();
@@ -1507,7 +1507,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();
@@ -1528,11 +1528,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 780c268..6dfb4bd 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