Kaydet (Commit) 89ec42e1 authored tarafından Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Kaydeden (comit) Jan Holesovsky

vcl: Execute pending operations on source when copying bitmap

Change-Id: I8a6a5ffe71c9e5f16533fd1f0944d4fd2a051c73
üst 21cf4432
......@@ -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 );
......
......@@ -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();
......
......@@ -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();
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment