[Libreoffice-commits] core.git: 2 commits - vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 20 12:21:58 UTC 2020


 vcl/skia/gdiimpl.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 4a8d86d490743022699b3333fe1a053cae63a1d3
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Jan 20 11:49:41 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Jan 20 13:21:40 2020 +0100

    fix Skia bitmap blending
    
    SkBlendMode::kSrc does not clear actual colors if the source is just
    an alpha channel.
    
    Change-Id: I3e012cac78d95bf6a7407f192c11194af5e72355
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87061
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 1475d7cabde8..1c5474301034 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -881,6 +881,7 @@ bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect& rPosAry,
     // "result_alpha = 1.0 - (1.0 - floor(alpha)) * mask".
     // See also blendBitmap().
     SkCanvas* aCanvas = tmpSurface->getCanvas();
+    aCanvas->clear(SK_ColorTRANSPARENT);
     SkPaint aPaint;
     // First copy the mask as is.
     aPaint.setBlendMode(SkBlendMode::kSrc);
commit 161d533adf3c2ba1321c0fb0adf863eb766fb5ae
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Jan 20 11:32:33 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Jan 20 13:21:26 2020 +0100

    tweak Skia raster line drawing
    
    At least according to visualbackendtest it works best with 0.25 offset,
    although it's still not perfect, but the test at least passes this way.
    
    Change-Id: I15fdc39c91399efaae41ce7c10635028faf0486d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87060
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 9e513290f959..1475d7cabde8 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -542,7 +542,11 @@ void SkiaSalGraphicsImpl::drawLine(long nX1, long nY1, long nX2, long nY2)
     SkPaint paint;
     paint.setColor(toSkColor(mLineColor));
     paint.setAntiAlias(mParent.getAntiAliasB2DDraw());
-    getDrawCanvas()->drawLine(toSkX(nX1), toSkY(nY1), toSkX(nX2), toSkY(nY2), paint);
+    // Raster has better results if shifted by 0.25 (unlike the 0.5 done by toSkX/toSkY).
+    if (!isGPU())
+        getDrawCanvas()->drawLine(nX1 + 0.25, nY1 + 0.25, nX2 + 0.25, nY2 + 0.25, paint);
+    else
+        getDrawCanvas()->drawLine(toSkX(nX1), toSkY(nY1), toSkX(nX2), toSkY(nY2), paint);
     if (mXorMode) // limit xor area update
         mXorExtents = SkRect::MakeLTRB(nX1, nY1, nX2 + 1, nY2 + 1);
     postDraw();
@@ -656,7 +660,10 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectTo
     }
     if (mLineColor != SALCOLOR_NONE)
     {
-        if (isGPU()) // Apply the same adjustment as toSkX()/toSkY() do.
+        // Raster has better results if shifted by 0.25 (unlike the 0.5 done by toSkX/toSkY).
+        if (!isGPU())
+            aPath.offset(0.25, 0.25, nullptr);
+        else // Apply the same adjustment as toSkX()/toSkY() do.
             aPath.offset(0.5, 0.5, nullptr);
         aPaint.setColor(toSkColorWithTransparency(mLineColor, fTransparency));
         aPaint.setStyle(SkPaint::kStroke_Style);


More information about the Libreoffice-commits mailing list