summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-04-26 20:25:03 -0400
committerAndras Timar <andras.timar@collabora.com>2024-05-17 19:57:45 +0200
commit528f74855bf2d7c772106900f66414d7116bb640 (patch)
treef5bd80bce202f7e0148fbb72e8ed541cb8d12b4a /vcl
parent8b6112e3455987413672f86dabf167767f477dfa (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: Ic1ac8a390df51c4aa1cc3183590dce72059af6b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166766 Reviewed-by: Patrick Luby <guibomacdev@gmail.com> Tested-by: Jenkins (cherry picked from commit 05d3a99aa687ee4e1706f9403651379b7ebdad89) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166722 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'vcl')
-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 f4ad57f715b0..5a04a08b6438 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1490,6 +1490,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.001);
+ getDrawCanvas()->concat(aMatrix);
+ }
+#endif
}
getDrawCanvas()->drawPath(aPath, aPaint);
postDraw();