[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - vcl/inc vcl/opengl vcl/workben
Michael Meeks
michael.meeks at collabora.com
Mon Jan 11 02:05:55 PST 2016
vcl/inc/openglgdiimpl.hxx | 7 ++++++-
vcl/opengl/gdiimpl.cxx | 45 +++++++++++++++++++++++++++++++--------------
vcl/workben/vcldemo.cxx | 4 +++-
3 files changed, 40 insertions(+), 16 deletions(-)
New commits:
commit 1b2a60dbde98034125aa30551c12bcf0d1c420b8
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Fri Jan 8 22:33:11 2016 +0000
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 at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/21288
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Tested-by: Tor Lillqvist <tml at collabora.com>
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 14beab5..a178d18 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 8c31f5e..7304a1a 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& rP
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++ )
@@ -1717,7 +1734,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();
@@ -1903,7 +1920,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 bfd29e5..3a91d44 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -879,7 +879,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]));
More information about the Libreoffice-commits
mailing list