Kaydet (Commit) 094faaae authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

opengl: fix wrong clipping when drawing text

Change-Id: I41a182c5309586337032328dfe82b1c6715f0dc2
üst 80d0b291
......@@ -148,7 +148,7 @@ public:
void DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect );
void DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect );
void DeferredTextDraw(OpenGLTexture& rTexture, const SalColor nMaskColor, const SalTwoRect& rPosAry);
void FlushDeferredDrawing(bool bInDraw = false);
void FlushDeferredDrawing();
public:
// get the width of the device
......@@ -166,6 +166,9 @@ public:
/// Oddly not all operations obey the XOR option.
enum XOROption { IGNORE_XOR, IMPLEMENT_XOR };
// initialize pre-draw state
void InitializePreDrawState(XOROption eOpt = IGNORE_XOR);
// operations to do before painting
void PreDraw(XOROption eOpt = IGNORE_XOR);
......
......@@ -186,6 +186,13 @@ void OpenGLSalGraphicsImpl::DeInit()
}
void OpenGLSalGraphicsImpl::PreDraw(XOROption eOpt)
{
FlushDeferredDrawing();
InitializePreDrawState(eOpt);
}
void OpenGLSalGraphicsImpl::InitializePreDrawState(XOROption eOpt)
{
OpenGLZone::enter();
......@@ -206,8 +213,6 @@ void OpenGLSalGraphicsImpl::PreDraw(XOROption eOpt)
glViewport( 0, 0, GetWidth(), GetHeight() );
CHECK_GL_ERROR();
FlushDeferredDrawing(true);
ImplInitClipRegion();
CHECK_GL_ERROR();
......@@ -268,6 +273,7 @@ void OpenGLSalGraphicsImpl::freeResources()
{
VCL_GL_INFO( "freeResources" );
mpContext->makeCurrent();
FlushDeferredDrawing();
mpContext->ReleaseFramebuffer( maOffscreenTex );
}
ReleaseContext();
......@@ -357,12 +363,16 @@ const vcl::Region& OpenGLSalGraphicsImpl::getClipRegion() const
bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
{
VCL_GL_INFO( "::setClipRegion " << rClip );
if (maClipRegion == rClip)
return true;
{
VCL_GL_INFO("::setClipRegion (no change) " << rClip);
return true;
}
FlushDeferredDrawing();
VCL_GL_INFO("::setClipRegion " << rClip);
maClipRegion = rClip;
mbUseStencil = false;
......@@ -378,12 +388,16 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
// set the clip region to empty
void OpenGLSalGraphicsImpl::ResetClipRegion()
{
VCL_GL_INFO( "::ResetClipRegion" );
if (maClipRegion.IsEmpty())
{
VCL_GL_INFO("::ResetClipRegion (no change) ");
return;
}
FlushDeferredDrawing();
VCL_GL_INFO("::ResetClipRegion");
maClipRegion.SetEmpty();
mbUseScissor = false;
mbUseStencil = false;
......@@ -1674,13 +1688,12 @@ void OpenGLSalGraphicsImpl::DeferredTextDraw(OpenGLTexture& rTexture, SalColor a
mpAccumulatedTextures->insert(rTexture, aMaskColor, rPosAry);
}
void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
void OpenGLSalGraphicsImpl::FlushDeferredDrawing()
{
if (mpAccumulatedTextures->empty())
return;
if (!bIsInDraw)
PreDraw();
InitializePreDrawState();
VCL_GL_INFO("FlushDeferredDrawing");
......@@ -1725,7 +1738,9 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
if( !UseProgram( "textureVertexShader", "maskFragmentShader" ) )
return;
mpProgram->SetBlendMode(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (auto& rPair : mpAccumulatedTextures->getAccumulatedTexturesMap())
{
OpenGLTexture& rTexture = rPair.second->maTexture;
......@@ -1742,8 +1757,8 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
}
mpProgram->Clean();
mpAccumulatedTextures->clear();
if (!bIsInDraw)
PostDraw();
PostDraw();
}
void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect )
......
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