summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-17 14:24:31 -0500
committerLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-17 14:24:31 -0500
commit67ff07df7d5bcf11da407b775b3fc541622fe297 (patch)
tree1e66932778453755fd78f734d946647c1ec45d7c
parent435e8d6aa8a185540fe0f788f28bba188cc840e6 (diff)
vcl: Execute pending operations on source when copying bitmap
Change-Id: I8a6a5ffe71c9e5f16533fd1f0944d4fd2a051c73
-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 187458bece73..c9f8d4e542d3 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 780c268c5516..6dfb4bdf6be4 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 );