From 5127fcba572bb93684b394a129e23d06bed281a1 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 25 Jul 2017 13:53:04 -0400 Subject: Always postConcat() pipeline gradient matrices In order to unblock https://skia-review.googlesource.com/c/26564 & https://skia-review.googlesource.com/c/26427, switch all impls to use a single/atomic postConcat for the gradient matrix. This is much easier to guard than the changes above. Change-Id: Ib72dbc7b5a56a96390f4468fd12caf8b6a0e46ef Reviewed-on: https://skia-review.googlesource.com/26620 Reviewed-by: Mike Klein Commit-Queue: Florin Malita --- src/shaders/gradients/SkLinearGradient.cpp | 4 ++++ src/shaders/gradients/SkRadialGradient.cpp | 4 ++++ src/shaders/gradients/SkSweepGradient.cpp | 4 ++++ src/shaders/gradients/SkTwoPointConicalGradient.cpp | 6 ++++++ 4 files changed, 18 insertions(+) (limited to 'src/shaders/gradients') diff --git a/src/shaders/gradients/SkLinearGradient.cpp b/src/shaders/gradients/SkLinearGradient.cpp index fc49d3430d..d127f8d06b 100644 --- a/src/shaders/gradients/SkLinearGradient.cpp +++ b/src/shaders/gradients/SkLinearGradient.cpp @@ -83,7 +83,11 @@ bool SkLinearGradient::adjustMatrixAndAppendStages(SkArenaAlloc*, SkMatrix* matrix, SkRasterPipeline*, SkRasterPipeline*) const { +#ifdef SK_SUPPORT_LEGACY_GRADIENT_MATRIX_MATH *matrix = SkMatrix::Concat(fPtsToUnit, *matrix); +#else + matrix->postConcat(fPtsToUnit); +#endif return true; } diff --git a/src/shaders/gradients/SkRadialGradient.cpp b/src/shaders/gradients/SkRadialGradient.cpp index faf0f69d0d..c2ca2fa64f 100644 --- a/src/shaders/gradients/SkRadialGradient.cpp +++ b/src/shaders/gradients/SkRadialGradient.cpp @@ -375,8 +375,12 @@ bool SkRadialGradient::adjustMatrixAndAppendStages(SkArenaAlloc* alloc, SkMatrix* matrix, SkRasterPipeline* p, SkRasterPipeline*) const { +#ifdef SK_SUPPORT_LEGACY_GRADIENT_MATRIX_MATH matrix->postTranslate(-fCenter.fX, -fCenter.fY); matrix->postScale(1/fRadius, 1/fRadius); +#else + matrix->postConcat(fPtsToUnit); +#endif p->append(SkRasterPipeline::xy_to_radius); return true; diff --git a/src/shaders/gradients/SkSweepGradient.cpp b/src/shaders/gradients/SkSweepGradient.cpp index f984542010..0a1d83ec70 100644 --- a/src/shaders/gradients/SkSweepGradient.cpp +++ b/src/shaders/gradients/SkSweepGradient.cpp @@ -222,7 +222,11 @@ bool SkSweepGradient::adjustMatrixAndAppendStages(SkArenaAlloc* alloc, SkMatrix* matrix, SkRasterPipeline* p, SkRasterPipeline*) const { +#ifdef SK_SUPPORT_LEGACY_GRADIENT_MATRIX_MATH matrix->postTranslate(-fCenter.fX, -fCenter.fY); +#else + matrix->postConcat(fPtsToUnit); +#endif p->append(SkRasterPipeline::xy_to_unit_angle); return true; diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp index f355971e43..65842f2b5f 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp +++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp @@ -182,8 +182,14 @@ bool SkTwoPointConicalGradient::adjustMatrixAndAppendStages(SkArenaAlloc* alloc, // When the two circles are concentric, we can pretend we're radial (with a tiny *twist). if (SkScalarNearlyZero(dCenter)) { +#ifdef SK_SUPPORT_LEGACY_GRADIENT_MATRIX_MATH matrix->postTranslate(-fCenter1.fX, -fCenter1.fY); matrix->postScale(1 / fRadius2, 1 / fRadius2); +#else + const SkMatrix tmp = SkMatrix::Concat(SkMatrix::MakeScale(1 / fRadius2, 1 / fRadius2), + SkMatrix::MakeTrans(-fCenter1.fX, -fCenter1.fY)); + matrix->postConcat(tmp); +#endif p->append(SkRasterPipeline::xy_to_radius); // Tiny twist: radial computes a t for [0, r2], but we want a t for [r1, r2]. -- cgit v1.2.3