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