Kaydet (Commit) c71de145 authored tarafından Michael Meeks's avatar Michael Meeks

tdf#96919 - vcl opengl: implement missing XOR mode.

Also revert "tdf#96257: Silly work-around to produce same result ..."
    from commit ec8bc265.

XOR rendering (it turns out) behaves oddly, and not for all operations.

Change-Id: Ie07d988bbf7fed10fb5625ac547a01a306b05319
Reviewed-on: https://gerrit.libreoffice.org/21282Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 2a5afa83
......@@ -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++)
......
......@@ -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();
......
......@@ -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
......
......@@ -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]));
......
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