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

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 17 18:26:21 UTC 2020


 vcl/backendtest/outputdevice/common.cxx |    6 +++---
 vcl/skia/gdiimpl.cxx                    |   13 +++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

New commits:
commit 8b8a988f38b704e466211bb91a3269756c34222b
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 17 16:49:19 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 17 19:25:42 2020 +0100

    implement also axial gradient for skia
    
    Change-Id: Ie708250f970f2ce08c8c89e4bf001a5df23b99bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106015
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx
index a002868715b8..2f893141e895 100644
--- a/vcl/backendtest/outputdevice/common.cxx
+++ b/vcl/backendtest/outputdevice/common.cxx
@@ -642,9 +642,9 @@ TestResult OutputDeviceTestCommon::checkAxialGradient(Bitmap& bitmap)
     for(int y = 1; y <= 11; ++y)
     {
         // Middle horizontal line is white, gradients to the sides.
-        checkValue(pAccess, 6, y, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, false);
-        checkValue(pAccess, 1, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, false);
-        checkValue(pAccess, 11, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, false);
+        checkValue(pAccess, 6, y, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
+        checkValue(pAccess, 1, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
+        checkValue(pAccess, 11, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
         if( !checkGradient( pAccess, 1, y, 6, 1, 0 ))
             return TestResult::Failed;
         if( !checkGradient( pAccess, 11, y, 6, -1, 0 ))
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index d89ec093a964..1f1c4002f94d 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1807,6 +1807,7 @@ bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPolygon,
                                        const Gradient& rGradient)
 {
     if (rGradient.GetStyle() != GradientStyle::Linear
+        && rGradient.GetStyle() != GradientStyle::Axial
         && rGradient.GetStyle() != GradientStyle::Radial)
         return false; // unsupported
     if (rGradient.GetSteps() != 0)
@@ -1852,6 +1853,18 @@ bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPolygon,
         SkScalar pos[2] = { SkDoubleToScalar(aGradient.GetBorder() / 100.0), 1.0 };
         shader = SkGradientShader::MakeLinear(points, colors, pos, 2, SkTileMode::kClamp);
     }
+    else if (rGradient.GetStyle() == GradientStyle::Axial)
+    {
+        tools::Polygon aPoly(aBoundRect);
+        aPoly.Rotate(aCenter, aGradient.GetAngle() % Degree10(3600));
+        SkPoint points[2] = { SkPoint::Make(toSkX(aPoly[0].X()), toSkY(aPoly[0].Y())),
+                              SkPoint::Make(toSkX(aPoly[1].X()), toSkY(aPoly[1].Y())) };
+        SkColor colors[3] = { endColor, startColor, endColor };
+        SkScalar border = SkDoubleToScalar(aGradient.GetBorder() / 100.0);
+        SkScalar pos[3]
+            = { std::min<SkScalar>(border, 0.5), 0.5, std::max<SkScalar>(1 - border, 0.5) };
+        shader = SkGradientShader::MakeLinear(points, colors, pos, 3, SkTileMode::kClamp);
+    }
     else
     {
         // Move the center by (-1,-1) (the default VCL algorithm is a bit off-center that way,


More information about the Libreoffice-commits mailing list