diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-11-07 11:59:13 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:16 +0100 |
commit | 36d0e875c72341ee0305c2840556e3839f136034 (patch) | |
tree | 4f78598e369dc72885730188787ea3f6b0c1f21c /vcl/inc | |
parent | 54be644c092eebb8be57a251556fe3f0e5f99e57 (diff) |
use center of pixels when doing GPU drawing using Skia
According to https://bugs.chromium.org/p/skia/issues/detail?id=9611
rounding errors may cause off-by-one errors, so compensate when
converting int->SkScalar in relevant cases.
Change-Id: I72a579064206c216c9f99adc7d7c2c57bbe567d6
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/skia/gdiimpl.hxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index f45b29abb07e..8225e76d27ff 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -215,8 +215,7 @@ protected: void setProvider(SalGeometryProvider* provider) { mProvider = provider; } bool isOffscreen() const { return mProvider == nullptr || mProvider->IsOffScreen(); } - // TODO mainly for debugging purposes - bool isGPU() const; + bool isGPU() const { return mIsGPU; } void invert(basegfx::B2DPolygon const& rPoly, SalInvert eFlags); @@ -231,6 +230,13 @@ protected: void drawMask(const SalTwoRect& rPosAry, const SkBitmap& rBitmap, Color nMaskColor); + // When drawing using GPU, rounding errors may result in off-by-one errors, + // see https://bugs.chromium.org/p/skia/issues/detail?id=9611 . Compensate for + // it by using centers of pixels (Skia uses float coordinates). In raster case + // it seems better to not do this though. + SkScalar toSkX(long x) const { return mIsGPU ? x + 0.5 : x; } + SkScalar toSkY(long y) const { return mIsGPU ? y + 0.5 : y; } + // Which Skia backend to use. enum RenderMethod { @@ -256,6 +262,7 @@ protected: SalGeometryProvider* mProvider; // The Skia surface that is target of all the rendering. sk_sp<SkSurface> mSurface; + bool mIsGPU; // whether the surface is GPU-backed vcl::Region mClipRegion; Color mLineColor; Color mFillColor; |