summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-08 17:41:21 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-08 19:10:13 +0900
commit094faaae6982472375420e57d6b9e34eefdbced8 (patch)
tree5f1e5fcccef32941f1d4ec14f6e12b3fd3d90d07 /vcl
parent80d0b2916db81a7f47bb1d368677016bbb870df6 (diff)
opengl: fix wrong clipping when drawing text
Change-Id: I41a182c5309586337032328dfe82b1c6715f0dc2
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/openglgdiimpl.hxx5
-rw-r--r--vcl/opengl/gdiimpl.cxx35
2 files changed, 29 insertions, 11 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 756190135daa..ef23328658f1 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -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);
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index bf979d0cba10..90c19d5aed66 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -187,6 +187,13 @@ void OpenGLSalGraphicsImpl::DeInit()
void OpenGLSalGraphicsImpl::PreDraw(XOROption eOpt)
{
+ FlushDeferredDrawing();
+
+ InitializePreDrawState(eOpt);
+}
+
+void OpenGLSalGraphicsImpl::InitializePreDrawState(XOROption eOpt)
+{
OpenGLZone::enter();
mnDrawCount++;
@@ -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 )