summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-17 14:24:31 -0500
committerJan Holesovsky <kendy@collabora.com>2014-11-18 15:44:02 +0100
commit89ec42e1d11457c0855a84d1ba651964662140fb (patch)
treed36f4e9963d9a7af46fec3fba8d9846bcb69cbf9 /vcl
parent21cf443235bf6579959988edee325e8332a42f9f (diff)
vcl: Execute pending operations on source when copying bitmap
Change-Id: I8a6a5ffe71c9e5f16533fd1f0944d4fd2a051c73
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/opengl/salbmp.hxx3
-rw-r--r--vcl/opengl/gdiimpl.cxx18
-rw-r--r--vcl/opengl/salbmp.cxx32
-rw-r--r--vcl/opengl/scale.cxx1
4 files changed, 32 insertions, 22 deletions
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 99956458a8a7..98fc2feb6e2b 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 ab6b95f68a23..67af601f1668 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 15ef1b38a8dd..78bcf07b1594 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 92fdd3f27830..741bdd1414fa 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 );