summaryrefslogtreecommitdiff
path: root/drawinglayer/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-05-09 09:18:00 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-09 10:46:55 +0200
commitf8b4d371eddd27594d549fb00294c01229a9bd24 (patch)
tree424a678ec749aca0431ef09d3eafff54d8c3eb13 /drawinglayer/source
parentc1bcdf9aa5d8ea99435906ffa9787232a909ff0f (diff)
drawinglayer: avoid AA for hairline polygons built from hori/vert lines only
For one, it seems this was the intention already since commit 85c70f37b56299f6fa02312c0fb73cc55af084ef (CWS-TOOLING: integrate CWS aw063, 2009-03-04): "suppress AntiAliasing for pure horizontal or vertical lines". For another, this fixes the TileCacheTests::testTileWireIDHandling() testcase in online.git, which assumes that the indicators at the corners of the Writer body frame (paragraph marks hidden / default case) can be painted multiple times, producing pixel-by-pixel matching results. But in reality AA breaks that assumption, and we know these indicators are never diagonal lines. Change-Id: Ib74f823165799991296b64cee58ec106dbdcedcf Reviewed-on: https://gerrit.libreoffice.org/72000 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'drawinglayer/source')
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx10
-rw-r--r--drawinglayer/source/processor2d/vclprocessor2d.cxx10
2 files changed, 20 insertions, 0 deletions
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 03012fb5d35a..db65dc3de4bb 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -140,6 +140,16 @@ namespace drawinglayer
mpOutputDevice->SetLineColor(Color(aLineColor));
//aLocalPolygon.transform(maCurrentTransformation);
+ if (getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete())
+ {
+ if (basegfx::utils::containsOnlyHorizontalOrVerticalLines(rLocalPolygon))
+ {
+ // DrawPolyLineDirect() only works in AA mode, but pure horizontal or vertical
+ // lines are better with AA off.
+ return false;
+ }
+ }
+
// try drawing; if it did not work, use standard fallback
return mpOutputDevice->DrawPolyLineDirect(
maCurrentTransformation,
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 361f7a5bd5a3..335e30a56ce9 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -331,6 +331,7 @@ namespace drawinglayer
basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
aLocalPolygon.transform(maCurrentTransformation);
+ bool bDisableAA = false;
if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete())
{
// #i98289#
@@ -339,9 +340,18 @@ namespace drawinglayer
// not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This
// NEEDS to be done in discrete coordinates, so only useful for pixel based rendering.
aLocalPolygon = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon);
+
+ // Also disable AA, snap would leave the start/end of lines still anti-aliased when
+ // their coordinates are provided in logic units.
+ bDisableAA = basegfx::utils::containsOnlyHorizontalOrVerticalLines(aLocalPolygon);
}
+ const AntialiasingFlags nOriginalAA(mpOutputDevice->GetAntialiasing());
+ if (bDisableAA && (nOriginalAA & AntialiasingFlags::EnableB2dDraw))
+ mpOutputDevice->SetAntialiasing(nOriginalAA & ~AntialiasingFlags::EnableB2dDraw);
mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0);
+ if (bDisableAA && (nOriginalAA & AntialiasingFlags::EnableB2dDraw))
+ mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() | AntialiasingFlags::EnableB2dDraw);
}
// direct draw of transformed BitmapEx primitive