From d0b568b52910712e5a0da32ca73740ec17d4d9a0 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Mon, 30 Mar 2020 08:11:15 -0500 Subject: [PATCH] remove negate() negate(x) -> -x Change-Id: I920b1abe473325309562ca29be6384bedd7e6a42 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280317 Commit-Queue: Mike Klein Reviewed-by: Mike Reed --- src/core/SkVM.h | 7 ++++--- src/shaders/gradients/SkTwoPointConicalGradient.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/SkVM.h b/src/core/SkVM.h index d8278f9cc1..d4e74720dc 100644 --- a/src/core/SkVM.h +++ b/src/core/SkVM.h @@ -504,9 +504,7 @@ namespace skvm { F32 mad(F32 x, F32 y, F32 z) { return add(mul(x,y), z); } F32 mad(F32a x, F32a y, F32a z) { return mad(_(x), _(y), _(z)); } - F32 negate(F32 x) { return sub(0.0f, x); } - F32 sqrt(F32); - + F32 sqrt(F32); F32 approx_log2(F32); F32 approx_pow2(F32); F32 approx_log (F32 x) { return mul(0.69314718f, approx_log2(x)); } @@ -868,6 +866,9 @@ namespace skvm { static inline F32& operator-=(F32& x, F32a y) { return (x = x - y); } static inline F32& operator*=(F32& x, F32a y) { return (x = x * y); } + static inline I32 operator-(I32 x) { return 0-x; } + static inline F32 operator-(F32 x) { return 0-x; } + } #endif//SkVM_DEFINED diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp index e6533518c8..9d3f89589a 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp +++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp @@ -268,7 +268,7 @@ skvm::F32 SkTwoPointConicalGradient::transformT(skvm::Builder* p, skvm::Uniforms skvm::F32 k = p->sqrt(p->sub(p->mul(x,x), p->mul(y,y))); if (fFocalData.isSwapped() || 1 - fFocalData.fFocalX < 0) { - k = p->negate(k); + k = -k; } t = p->sub(k, p->mul(x, invR1)); } @@ -279,7 +279,7 @@ skvm::F32 SkTwoPointConicalGradient::transformT(skvm::Builder* p, skvm::Uniforms } const skvm::F32 focalX = p->uniformF(uniforms->pushF(fFocalData.fFocalX)); - if (1 - fFocalData.fFocalX < 0) { t = p->negate(t); } + if (1 - fFocalData.fFocalX < 0) { t = -t; } if (!fFocalData.isNativelyFocal()) { t = p->add(t, focalX); } if (fFocalData.isSwapped()) { t = p->sub(p->splat(1.0f), t); } return t;