summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2016-01-08 22:33:11 +0000
committerMichael Meeks <michael.meeks@collabora.com>2016-01-09 09:33:43 +0000
commitc71de1458cebcd45b65cef3a182bf1092dc8ad80 (patch)
treec22c3ef49e083382d89265f33ff9d6c38a445bce
parent2a5afa8394d4ef928c56c0b62e76984b1b87e8c8 (diff)
tdf#96919 - vcl opengl: implement missing XOR mode.
Also revert "tdf#96257: Silly work-around to produce same result ..." from commit ec8bc265050d86a749140c353360a78cce4e3fce. XOR rendering (it turns out) behaves oddly, and not for all operations. Change-Id: Ie07d988bbf7fed10fb5625ac547a01a306b05319 Reviewed-on: https://gerrit.libreoffice.org/21282 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--svx/source/sdr/overlay/overlayselection.cxx9
-rw-r--r--vcl/inc/openglgdiimpl.hxx7
-rw-r--r--vcl/opengl/gdiimpl.cxx45
-rw-r--r--vcl/workben/vcldemo.cxx4
4 files changed, 40 insertions, 25 deletions
diff --git a/svx/source/sdr/overlay/overlayselection.cxx b/svx/source/sdr/overlay/overlayselection.cxx
index 941df12d8093..bab9366054c2 100644
--- a/svx/source/sdr/overlay/overlayselection.cxx
+++ b/svx/source/sdr/overlay/overlayselection.cxx
@@ -107,16 +107,7 @@ namespace sdr
if(bInvert)
{
// force color to white for invert to get a full invert
-#ifdef WNT
- // tdf#96257: For likely separate reasons, neither the non-OpenGL nor the OpenGL
- // code path produces what we actually want here (a line drawn in 'invert' mode
- // if white is used, as happens on X11). In the non-OpenGL case we get a black
- // line, in the OpenGL case a white one. So let's use grey and at least get the
- // same on both.
- aRGBColor = basegfx::BColor(0.5, 0.5, 0.5);
-#else
aRGBColor = basegfx::BColor(1.0, 1.0, 1.0);
-#endif
}
for(sal_uInt32 a(0);a < nCount; a++)
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 4883d0f938df..df2e91449565 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -80,6 +80,8 @@ protected:
bool mbUseScissor;
bool mbUseStencil;
+ bool mbXORMode;
+
/**
* All rendering happens to this off-screen texture. For
* non-virtual devices, ie. windows - we will blit it and
@@ -152,8 +154,11 @@ public:
*/
bool IsOffscreen() const { return mpProvider == nullptr || mpProvider->IsOffScreen(); }
+ /// Oddly not all operations obey the XOR option.
+ enum XOROption { IGNORE_XOR, IMPLEMENT_XOR };
+
// operations to do before painting
- void PreDraw();
+ void PreDraw(XOROption eOpt = IGNORE_XOR);
// operations to do after painting
void PostDraw();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 791bf09b4eb9..e00352ffd059 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -68,6 +68,7 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGraphics& rParent, SalGeometryPr
, mpFlush(new OpenGLFlushIdle(this))
, mbUseScissor(false)
, mbUseStencil(false)
+ , mbXORMode(false)
, mnLineColor(SALCOLOR_NONE)
, mnFillColor(SALCOLOR_NONE)
#ifdef DBG_UTIL
@@ -176,7 +177,7 @@ void OpenGLSalGraphicsImpl::DeInit()
mpContext.clear();
}
-void OpenGLSalGraphicsImpl::PreDraw()
+void OpenGLSalGraphicsImpl::PreDraw(XOROption eOpt)
{
OpenGLZone::enter();
@@ -196,13 +197,27 @@ void OpenGLSalGraphicsImpl::PreDraw()
glViewport( 0, 0, GetWidth(), GetHeight() );
CHECK_GL_ERROR();
- ImplInitClipRegion();
+ ImplInitClipRegion();
CHECK_GL_ERROR();
+
+ if (eOpt == IMPLEMENT_XOR && mbXORMode)
+ {
+ glEnable(GL_COLOR_LOGIC_OP);
+ CHECK_GL_ERROR();
+
+ glLogicOp(GL_XOR);
+ }
}
void OpenGLSalGraphicsImpl::PostDraw()
{
+ if (mbXORMode)
+ {
+ glDisable(GL_COLOR_LOGIC_OP);
+ CHECK_GL_ERROR();
+ }
+
if( mbUseScissor )
{
glDisable( GL_SCISSOR_TEST );
@@ -404,8 +419,9 @@ void OpenGLSalGraphicsImpl::SetFillColor( SalColor nSalColor )
}
// enable/disable XOR drawing
-void OpenGLSalGraphicsImpl::SetXORMode( bool /*bSet*/, bool /*bInvertOnly*/ )
+void OpenGLSalGraphicsImpl::SetXORMode( bool bSet, bool )
{
+ mbXORMode = bSet;
}
// set line color for raster operations
@@ -503,6 +519,7 @@ bool OpenGLSalGraphicsImpl::UseSolid( SalColor nColor, sal_uInt8 nTransparency )
#endif
mProgramSolidColor = nColor;
mProgramSolidTransparency = nTransparency / 100.0;
+
return true;
}
@@ -1331,7 +1348,7 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY )
VCL_GL_INFO( "::drawPixel" );
if( mnLineColor != SALCOLOR_NONE )
{
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( mnLineColor ) )
DrawPoint( nX, nY );
PostDraw();
@@ -1343,7 +1360,7 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY, SalColor nSalColor )
VCL_GL_INFO( "::drawPixel" );
if( nSalColor != SALCOLOR_NONE )
{
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( nSalColor ) )
DrawPoint( nX, nY );
PostDraw();
@@ -1355,7 +1372,7 @@ void OpenGLSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 )
VCL_GL_INFO( "::drawLine" );
if( mnLineColor != SALCOLOR_NONE )
{
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolidAA( mnLineColor ) )
DrawLineAA( nX1, nY1, nX2, nY2 );
PostDraw();
@@ -1365,7 +1382,7 @@ void OpenGLSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 )
void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeight )
{
VCL_GL_INFO( "::drawRect" );
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( mnFillColor ) )
DrawRect( nX, nY, nWidth, nHeight );
@@ -1403,7 +1420,7 @@ void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pP
if( mnLineColor != SALCOLOR_NONE && nPoints > 1 )
{
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolidAA( mnLineColor ) )
DrawLinesAA( nPoints, pPtAry, false );
PostDraw();
@@ -1427,7 +1444,7 @@ void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
return;
}
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( mnFillColor ) )
DrawPolygon( nPoints, pPtAry );
@@ -1444,7 +1461,7 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
if( nPoly <= 0 )
return;
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( mnFillColor ) )
{
@@ -1481,7 +1498,7 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon( const basegfx::B2DPolyPolygon& rPol
if( rPolyPolygon.count() <= 0 )
return true;
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( mnFillColor, fTransparency ) )
DrawPolyPolygon( rPolyPolygon );
@@ -1555,7 +1572,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX()));
}
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
if( UseSolid( mnLineColor, fTransparency ) )
{
for( sal_uInt32 i = 0; i < aAreaPolyPoly.count(); i++ )
@@ -1722,7 +1739,7 @@ SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY )
{
char pixel[3] = { 0, 0, 0 };
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
nY = GetHeight() - nY - 1;
glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
CHECK_GL_ERROR();
@@ -1920,7 +1937,7 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
aBoundRect.Right()++;
aBoundRect.Bottom()++;
- PreDraw();
+ PreDraw( XOROption::IMPLEMENT_XOR );
#define FIXME_BROKEN_STENCIL_FOR_GRADIENTS 0
#if FIXME_BROKEN_STENCIL_FOR_GRADIENTS
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 20a28abfea32..40a37fd86146 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1014,7 +1014,9 @@ public:
"cmd/lc_marks.png",
"cmd/lc_fieldnames.png",
"cmd/lc_hyperlinkdialog.png",
- };
+ "cmd/lc_basicshapes.rectangle.png",
+ "cmd/lc_basicshapes.round-rectangle.png"
+ };
for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
{
maIconNames.push_back(OUString::createFromAscii(pNames[i]));