summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-09-25 13:30:11 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-09-29 09:54:42 +0200
commit4deadc3c78949c18bb886eb1f66caa8f3cd7a2df (patch)
treec6c17519268c9adaf382f2dd07f71787e2d8cff5
parentcd85546a2fbdade42f80fd3b6bd650791db9f32d (diff)
disentangle AA and B2D use in VCL drawing
A number of powerful functions using B2D polygons such as OutputDevice::DrawPolyLineDirect() were used only if AA was enabled. So e.g. dashing for an AA-ed polyline could be drawn directly using the function, but with AA disabled had to be done manually by a number of polygon operations. Which doesn't make much sense, surely these powerful functions can also draw without AA if set so (and indeed that's mostly the case). And DrawPolyLineDirect() even had a flag to bypass the check. So simply try to use B2D-based drawing whenever possible, AA or not. The previous commit had already changed the naming of the AA option to not include B2D in the name. This seems to come from https://bz.apache.org/ooo/show_bug.cgi?id=88795, which doesn't explain why AA only. There are other bugreports such as https://bz.apache.org/ooo/show_bug.cgi?id=101491 and https://bz.apache.org/ooo/show_bug.cgi?id=98289 that are related, but there I cannot see any difference with this patch. And all unit tests pass. Change-Id: Ibb5938e8fff9b7452bac4bf12ed3e42fd3e5d645 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103354 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx3
-rw-r--r--include/vcl/outdev.hxx6
-rw-r--r--vcl/backendtest/outputdevice/line.cxx2
-rw-r--r--vcl/quartz/salgdicommon.cxx4
-rw-r--r--vcl/source/outdev/line.cxx10
-rw-r--r--vcl/source/outdev/polygon.cxx9
-rw-r--r--vcl/source/outdev/polyline.cxx35
-rw-r--r--vcl/source/outdev/transparent.cxx3
8 files changed, 23 insertions, 49 deletions
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index d095270e2a26..ac1efe4d95b3 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -200,8 +200,7 @@ bool VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect(
rSource.getLineAttribute().getWidth(), fTransparency,
bStrokeAttributeNotUsed ? nullptr : &rSource.getStrokeAttribute().getDotDashArray(),
rSource.getLineAttribute().getLineJoin(), rSource.getLineAttribute().getLineCap(),
- rSource.getLineAttribute().getMiterMinimumAngle()
- /* false bBypassAACheck, default*/);
+ rSource.getLineAttribute().getMiterMinimumAngle());
}
namespace
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index e1cd36730d52..18f91b205faf 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -814,8 +814,7 @@ public:
const std::vector< double >* = nullptr, // MM01
basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::NONE,
css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
- double fMiterMinimumAngle = basegfx::deg2rad(15.0),
- bool bBypassAACheck = false);
+ double fMiterMinimumAngle = basegfx::deg2rad(15.0));
private:
@@ -834,8 +833,7 @@ private:
const std::vector< double >* = nullptr, // MM01
basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::NONE,
css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
- double fMiterMinimumAngle = basegfx::deg2rad(15.0),
- bool bBypassAACheck = false);
+ double fMiterMinimumAngle = basegfx::deg2rad(15.0));
/** @name Polygon functions
*/
diff --git a/vcl/backendtest/outputdevice/line.cxx b/vcl/backendtest/outputdevice/line.cxx
index 3ea81e178d39..df96c4593b98 100644
--- a/vcl/backendtest/outputdevice/line.cxx
+++ b/vcl/backendtest/outputdevice/line.cxx
@@ -132,7 +132,7 @@ Bitmap OutputDeviceTestLine::setupDashedLine()
rectangle.getY() + rectangle.getHeight()),
basegfx::B2DPoint(rectangle.getX() + rectangle.getWidth(), rectangle.getY()),
basegfx::B2DPoint(rectangle.getX(), rectangle.getY())},
- 1, 0, &stroke, basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, basegfx::deg2rad(15.0), true );
+ 1, 0, &stroke, basegfx::B2DLineJoin::NONE );
return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
}
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 1e3af5a0d3b3..7f96124f96ac 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -836,7 +836,7 @@ bool AquaSalGraphics::drawPolyLine(
CGContextBeginPath( maContextHolder.get() );
CGContextAddPath( maContextHolder.get(), xPath );
// draw path with antialiased line
- CGContextSetShouldAntialias( maContextHolder.get(), true );
+ CGContextSetShouldAntialias( maContextHolder.get(), getAntiAlias() );
CGContextSetAlpha( maContextHolder.get(), 1.0 - fTransparency );
CGContextSetLineJoin( maContextHolder.get(), aCGLineJoin );
CGContextSetLineCap( maContextHolder.get(), aCGLineCap );
@@ -921,7 +921,7 @@ bool AquaSalGraphics::drawPolyPolygon(
CGContextAddPath( maContextHolder.get(), xPath );
// draw path with antialiased polygon
- CGContextSetShouldAntialias( maContextHolder.get(), true );
+ CGContextSetShouldAntialias( maContextHolder.get(), getAntiAlias() );
CGContextSetAlpha( maContextHolder.get(), 1.0 - fTransparency );
CGContextDrawPath( maContextHolder.get(), eMode );
maContextHolder.restoreState();
diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx
index 6507c43408ed..f965f0fdd1fc 100644
--- a/vcl/source/outdev/line.cxx
+++ b/vcl/source/outdev/line.cxx
@@ -108,8 +108,7 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt )
InitLineColor();
// #i101598# support AA and snap for lines, too
- if((mnAntialiasing & AntialiasingFlags::Enable)
- && mpGraphics->supportsOperation(OutDevSupportType::B2DDraw)
+ if( mpGraphics->supportsOperation(OutDevSupportType::B2DDraw)
&& RasterOp::OverPaint == GetRasterOp()
&& IsLineColor())
{
@@ -151,8 +150,7 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt )
void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const LineInfo& rInfo )
{
- const bool bTryAA((mnAntialiasing & AntialiasingFlags::Enable)
- && mpGraphics->supportsOperation(OutDevSupportType::B2DDraw)
+ const bool bTryB2d(mpGraphics->supportsOperation(OutDevSupportType::B2DDraw)
&& RasterOp::OverPaint == GetRasterOp()
&& IsLineColor());
basegfx::B2DPolyPolygon aFillPolyPolygon;
@@ -234,7 +232,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);
bool bDone(false);
- if(bTryAA)
+ if(bTryB2d)
{
bDone = mpGraphics->DrawPolyLine(
basegfx::B2DHomMatrix(),
@@ -272,7 +270,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
bool bDone(false);
- if(bTryAA)
+ if(bTryB2d)
{
bDone = mpGraphics->DrawPolyPolygon(
basegfx::B2DHomMatrix(),
diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx
index 996af41c0506..4d76578d376a 100644
--- a/vcl/source/outdev/polygon.cxx
+++ b/vcl/source/outdev/polygon.cxx
@@ -62,8 +62,7 @@ void OutputDevice::DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly )
InitFillColor();
// use b2dpolygon drawing if possible
- if((mnAntialiasing & AntialiasingFlags::Enable) &&
- mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
+ if(mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
RasterOp::OverPaint == GetRasterOp() &&
(IsLineColor() || IsFillColor()))
{
@@ -182,8 +181,7 @@ void OutputDevice::DrawPolygon( const tools::Polygon& rPoly )
InitFillColor();
// use b2dpolygon drawing if possible
- if((mnAntialiasing & AntialiasingFlags::Enable) &&
- mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
+ if(mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
RasterOp::OverPaint == GetRasterOp() &&
(IsLineColor() || IsFillColor()))
{
@@ -292,8 +290,7 @@ void OutputDevice::ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyP
bool bSuccess(false);
- if((mnAntialiasing & AntialiasingFlags::Enable) &&
- mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
+ if(mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
RasterOp::OverPaint == GetRasterOp() &&
(IsLineColor() || IsFillColor()))
{
diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx
index e9b01f987f80..e52e42cc8ce6 100644
--- a/vcl/source/outdev/polyline.cxx
+++ b/vcl/source/outdev/polyline.cxx
@@ -117,8 +117,7 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly, const LineInfo& rL
// #i101491#
// Try direct Fallback to B2D-Version of DrawPolyLine
- if((mnAntialiasing & AntialiasingFlags::Enable) &&
- LineStyle::Solid == rLineInfo.GetStyle())
+ if(LineStyle::Solid == rLineInfo.GetStyle())
{
DrawPolyLine(
rPoly.getB2DPolygon(),
@@ -219,25 +218,13 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
SetFillColor(aOldFillColor);
InitFillColor();
- const bool bTryAA((mnAntialiasing & AntialiasingFlags::Enable) &&
- mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
- RasterOp::OverPaint == GetRasterOp() &&
- IsLineColor());
-
// when AA it is necessary to also paint the filled polygon's outline
// to avoid optical gaps
for(auto const& rPolygon : aAreaPolyPolygon)
{
(void)DrawPolyLineDirectInternal(
basegfx::B2DHomMatrix(),
- rPolygon,
- 0.0,
- 0.0,
- nullptr, // MM01
- basegfx::B2DLineJoin::NONE,
- css::drawing::LineCap_BUTT,
- basegfx::deg2rad(15.0) /*default, not used*/,
- bTryAA);
+ rPolygon);
}
}
else
@@ -308,11 +295,10 @@ bool OutputDevice::DrawPolyLineDirect(
const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
- double fMiterMinimumAngle,
- bool bBypassAACheck)
+ double fMiterMinimumAngle)
{
if(DrawPolyLineDirectInternal(rObjectTransform, rB2DPolygon, fLineWidth, fTransparency,
- pStroke, eLineJoin, eLineCap, fMiterMinimumAngle, bBypassAACheck))
+ pStroke, eLineJoin, eLineCap, fMiterMinimumAngle))
{
// Worked, add metafile action (if recorded). This is done only here,
// because this function is public, other OutDev functions already add metafile
@@ -342,8 +328,7 @@ bool OutputDevice::DrawPolyLineDirectInternal(
const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
- double fMiterMinimumAngle,
- bool bBypassAACheck)
+ double fMiterMinimumAngle)
{
assert(!is_double_buffered_window());
@@ -364,13 +349,11 @@ bool OutputDevice::DrawPolyLineDirectInternal(
if( mbInitLineColor )
InitLineColor();
- const bool bTryAA( bBypassAACheck ||
- ((mnAntialiasing & AntialiasingFlags::Enable) &&
- mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
+ const bool bTryB2d(mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
RasterOp::OverPaint == GetRasterOp() &&
- IsLineColor()));
+ IsLineColor());
- if(bTryAA)
+ if(bTryB2d)
{
// combine rObjectTransform with WorldToDevice
const basegfx::B2DHomMatrix aTransform(ImplGetDeviceTransformation() * rObjectTransform);
@@ -395,7 +378,7 @@ bool OutputDevice::DrawPolyLineDirectInternal(
if (mpAlphaVDev)
mpAlphaVDev->DrawPolyLineDirect(rObjectTransform, rB2DPolygon, fLineWidth,
fTransparency, pStroke, eLineJoin, eLineCap,
- fMiterMinimumAngle, bBypassAACheck);
+ fMiterMinimumAngle);
return true;
}
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index e7864820b6ba..b2496a726086 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -232,8 +232,7 @@ void OutputDevice::DrawTransparent(
if( mbInitFillColor )
InitFillColor();
- if((mnAntialiasing & AntialiasingFlags::Enable) &&
- mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
+ if(mpGraphics->supportsOperation(OutDevSupportType::B2DDraw) &&
(RasterOp::OverPaint == GetRasterOp()) )
{
// b2dpolygon support not implemented yet on non-UNX platforms