summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-08-04 16:21:47 +0900
committerCaolán McNamara <caolanm@redhat.com>2016-08-08 11:33:33 +0000
commitc0f43368471a5844f10025d42a36b89d3a2cc184 (patch)
tree0213172043d5834d1f80993c651af34dada91241 /vcl
parent09fe869bf8ef14a6011317c8c494067c09951820 (diff)
tdf#101008 fix XOR rendering
Change-Id: Ied73966633e5ffd56faccea7ec1408bd83642b58 Reviewed-on: https://gerrit.libreoffice.org/27862 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/27922 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/opengl/gdiimpl.cxx93
1 files changed, 69 insertions, 24 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 4f1da078cb9d..6c910133ef1b 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -222,6 +222,10 @@ void OpenGLSalGraphicsImpl::InitializePreDrawState(XOROption eOpt)
CHECK_GL_ERROR();
glLogicOp(GL_XOR);
+ CHECK_GL_ERROR();
+
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
+ CHECK_GL_ERROR();
}
}
@@ -231,6 +235,8 @@ void OpenGLSalGraphicsImpl::PostDraw()
{
glDisable(GL_COLOR_LOGIC_OP);
CHECK_GL_ERROR();
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ CHECK_GL_ERROR();
}
if( mpProgram )
@@ -458,17 +464,43 @@ void OpenGLSalGraphicsImpl::SetFillColor( SalColor nSalColor )
// enable/disable XOR drawing
void OpenGLSalGraphicsImpl::SetXORMode( bool bSet, bool )
{
- mbXORMode = bSet;
+ if (mbXORMode != bSet)
+ {
+ FlushDeferredDrawing();
+ mbXORMode = bSet;
+ }
}
-// set line color for raster operations
-void OpenGLSalGraphicsImpl::SetROPLineColor( SalROPColor /*nROPColor*/ )
+void OpenGLSalGraphicsImpl::SetROPLineColor(SalROPColor nROPColor)
{
+ switch (nROPColor)
+ {
+ case SalROPColor::N0:
+ mnLineColor = MAKE_SALCOLOR(0, 0, 0);
+ break;
+ case SalROPColor::N1:
+ mnLineColor = MAKE_SALCOLOR(0xff, 0xff, 0xff);
+ break;
+ case SalROPColor::Invert:
+ mnLineColor = MAKE_SALCOLOR(0xff, 0xff, 0xff);
+ break;
+ }
}
-// set fill color for raster operations
-void OpenGLSalGraphicsImpl::SetROPFillColor( SalROPColor /*nROPColor*/ )
+void OpenGLSalGraphicsImpl::SetROPFillColor(SalROPColor nROPColor)
{
+ switch (nROPColor)
+ {
+ case SalROPColor::N0:
+ mnFillColor = MAKE_SALCOLOR(0, 0, 0);
+ break;
+ case SalROPColor::N1:
+ mnFillColor = MAKE_SALCOLOR(0xff, 0xff, 0xff);
+ break;
+ case SalROPColor::Invert:
+ mnFillColor = MAKE_SALCOLOR(0xff, 0xff, 0xff);
+ break;
+ }
}
bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
@@ -2274,15 +2306,21 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
{
Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
- VCL_GL_INFO( "::drawGradient" );
+ VCL_GL_INFO("::drawGradient " << rPolyPoly.GetBoundRect());
- if( aBoundRect.IsEmpty() )
+ if (aBoundRect.IsEmpty())
+ {
+ VCL_GL_INFO("::drawGradient nothing to draw");
return true;
+ }
- if( rGradient.GetStyle() != GradientStyle_LINEAR &&
+ if (rGradient.GetStyle() != GradientStyle_LINEAR &&
rGradient.GetStyle() != GradientStyle_AXIAL &&
rGradient.GetStyle() != GradientStyle_RADIAL )
+ {
+ VCL_GL_INFO("::drawGradient unsupported gradient type");
return false;
+ }
aBoundRect.Left()--;
aBoundRect.Top()--;
@@ -2296,14 +2334,14 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
ImplSetClipBit( vcl::Region( rPolyPoly ), 0x02 );
if( mbUseStencil )
{
- glEnable( GL_STENCIL_TEST );
+ mpContext->state()->stencil().enable();
CHECK_GL_ERROR();
glStencilFunc( GL_EQUAL, 3, 0xFF );
CHECK_GL_ERROR();
}
else
{
- glEnable( GL_STENCIL_TEST );
+ mpContext->state()->stencil().enable();
CHECK_GL_ERROR();
glStencilFunc( GL_EQUAL, 2, 0xFF );
CHECK_GL_ERROR();
@@ -2311,32 +2349,39 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
#endif
// if border >= 100%, draw solid rectangle with start color
- if( rGradient.GetBorder() >= 100.0 )
+ if (rGradient.GetBorder() >= 100.0)
{
- Color aCol = rGradient.GetStartColor();
- long nF = rGradient.GetStartIntensity();
- if( UseSolid( MAKE_SALCOLOR( aCol.GetRed() * nF / 100,
- aCol.GetGreen() * nF / 100,
- aCol.GetBlue() * nF / 100 ) ) )
- DrawRect( aBoundRect );
+ VCL_GL_INFO("::drawGradient -> DrawRect (no gradient)");
+
+ Color aColor = rGradient.GetStartColor();
+ long nIntensity = rGradient.GetStartIntensity();
+ if (UseSolid(MAKE_SALCOLOR(aColor.GetRed() * nIntensity / 100.0,
+ aColor.GetGreen()* nIntensity / 100.0,
+ aColor.GetBlue() * nIntensity / 100.0)))
+ {
+ DrawRect(aBoundRect);
+ }
}
- else if( rGradient.GetStyle() == GradientStyle_LINEAR )
+ else if (rGradient.GetStyle() == GradientStyle_LINEAR)
{
- DrawLinearGradient( rGradient, aBoundRect );
+ VCL_GL_INFO("::drawGradient -> DrawLinearGradient");
+ DrawLinearGradient(rGradient, aBoundRect);
}
- else if( rGradient.GetStyle() == GradientStyle_AXIAL )
+ else if (rGradient.GetStyle() == GradientStyle_AXIAL)
{
- DrawAxialGradient( rGradient, aBoundRect );
+ VCL_GL_INFO("::drawGradient -> DrawAxialGradient");
+ DrawAxialGradient(rGradient, aBoundRect);
}
- else if( rGradient.GetStyle() == GradientStyle_RADIAL )
+ else if (rGradient.GetStyle() == GradientStyle_RADIAL)
{
- DrawRadialGradient( rGradient, aBoundRect );
+ VCL_GL_INFO("::drawGradient -> DrawRadialGradient");
+ DrawRadialGradient(rGradient, aBoundRect);
}
#if FIXME_BROKEN_STENCIL_FOR_GRADIENTS
if( !mbUseStencil )
{
- glDisable( GL_STENCIL_TEST );
+ mpContext->state()->stencil().disable();
CHECK_GL_ERROR();
}
#endif