From 67e322ed97bbed7e262e2f2214b2e9234a67c84d Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sun, 9 Aug 2020 21:46:45 +0200 Subject: [PATCH] Revert the code for SetScaleTranslate (#1452) --- binding/Binding/SKMatrix.cs | 16 ++++++++++++++-- tests/Tests/SKMatrixTests.cs | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/binding/Binding/SKMatrix.cs b/binding/Binding/SKMatrix.cs index e25916a8..6388e814 100644 --- a/binding/Binding/SKMatrix.cs +++ b/binding/Binding/SKMatrix.cs @@ -288,8 +288,20 @@ namespace SkiaSharp [EditorBrowsable (EditorBrowsableState.Never)] [Obsolete ("Use CreateScaleTranslation(float, float, float, float) instead.")] - public void SetScaleTranslate (float sx, float sy, float tx, float ty) => - CreateScaleTranslation (sx, sy, tx, ty); + public void SetScaleTranslate (float sx, float sy, float tx, float ty) + { + scaleX = sx; + skewX = 0; + transX = tx; + + skewY = 0; + scaleY = sy; + transY = ty; + + persp0 = 0; + persp1 = 0; + persp2 = 1; + } // Rotate diff --git a/tests/Tests/SKMatrixTests.cs b/tests/Tests/SKMatrixTests.cs index 68545eab..c78b87d2 100644 --- a/tests/Tests/SKMatrixTests.cs +++ b/tests/Tests/SKMatrixTests.cs @@ -227,5 +227,20 @@ namespace SkiaSharp.Tests Assert.Equal(10, newPoint.X, PRECISION); Assert.Equal(40, newPoint.Y, PRECISION); } + + [Obsolete] + [SkippableFact] + public void SetScaleTranslateWorksCorrectly() + { + var tempMatrix = SKMatrix.MakeIdentity(); + + tempMatrix.Values = new float[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 }; + + SKMatrix.RotateDegrees(ref tempMatrix, 0); + + tempMatrix.SetScaleTranslate(1.2f, 1.0f, 0, 0); + + Assert.Equal(1.2f, tempMatrix.Values[0]); + } } }