summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-04-26 21:29:10 -0400
committerMichael Stahl <michael.stahl@allotropia.de>2024-05-03 11:51:37 +0200
commit9fc1e9e0d438a0a36e1e93826312170c9c2dac2a (patch)
treeefaa5e15b2dbd7e2a52b0e349890ad2934719833
parent63af9a5047da775442a04a583044712ab92aa9e6 (diff)
tdf#153306 prevent subpixel shifting of X coordinate
HACK: for some unknown reason, if the X coordinate of the path's bounds is more than 1024, SkBlendMode::kExclusion will shift by about a half a pixel to the right with Skia/Metal on a Retina display. Weirdly, if the same polygon is repeatedly drawn, the total shift is cumulative so if the drawn polygon is more than a few pixels wide, the blinking cursor in Writer will exhibit this bug but only for one thin vertical slice at a time. Apparently, shifting drawing a very tiny amount to the left seems to be enough to quell this runaway cumulative X coordinate shift. Change-Id: Iabe9078e416b0dde003ee61c88817ff970cc8d39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166768 Tested-by: Jenkins Reviewed-by: Patrick Luby <guibomacdev@gmail.com> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--vcl/skia/gdiimpl.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index a6e030924ab6..eb6faeaa99d2 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1489,6 +1489,26 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl
aPaint.setShader(
aBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions()));
}
+
+#ifdef SK_METAL
+ // tdf#153306 prevent subpixel shifting of X coordinate
+ // HACK: for some unknown reason, if the X coordinate of the
+ // path's bounds is more than 1024, SkBlendMode::kExclusion will
+ // shift by about a half a pixel to the right with Skia/Metal on
+ // a Retina display. Weirdly, if the same polygon is repeatedly
+ // drawn, the total shift is cumulative so if the drawn polygon
+ // is more than a few pixels wide, the blinking cursor in Writer
+ // will exhibit this bug but only for one thin vertical slice at
+ // a time. Apparently, shifting drawing a very tiny amount to
+ // the left seems to be enough to quell this runaway cumulative
+ // X coordinate shift.
+ if (isGPU())
+ {
+ SkMatrix aMatrix;
+ aMatrix.set(SkMatrix::kMTransX, -0.25);
+ getDrawCanvas()->concat(aMatrix);
+ }
+#endif
}
getDrawCanvas()->drawPath(aPath, aPaint);
postDraw();