aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2017-12-11 14:17:47 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-11 19:42:28 +0000
commit7741c75152658d0297eafd0a8bb8aa36dce26d4d (patch)
tree71d232fe45b2f5e4892c834834525e2f70fa8a2f /src/shaders
parent73822257cb01fb31c3ea90de0b88948def4caacf (diff)
Use first/second instead of min/max in 2pt conical gradient
Here's the tiny performance gain: $python tools/calmbench/calmbench.py firstsecond --extraarg "-m conic" firstsecond (compared to master) is likely 4.23% faster in gradient_conicalOut_clamp_3color 4.23% faster in gradient_conicalOutZero_clamp_3color 4.79% faster in gradient_conical_clamp_shallow_dither 6.04% faster in gradient_conical_clamp_3color 6.04% faster in gradient_conicalZero_clamp_3color 6.42% faster in gradient_conicalOut_clamp 6.43% faster in gradient_conicalOutZero_clamp 6.74% faster in gradient_conical_clamp 6.98% faster in gradient_conical_clamp_shallow 6.98% faster in gradient_conicalZero_clamp Bug: skia: Change-Id: Id74866908b99753ed8b16a657d3f67c9255d0043 Reviewed-on: https://skia-review.googlesource.com/76561 Commit-Queue: Yuqian Li <liyuqian@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/shaders')
-rw-r--r--src/shaders/gradients/SkTwoPointConicalGradient.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
index cd7bbb1252..8cf6409afe 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
@@ -210,6 +210,7 @@ void SkTwoPointConicalGradient::appendGradientStages(SkArenaAlloc* alloc, SkRast
} else {
isWellBehaved = SkScalarAbs(dRadius) >= dCenter;
bool isFlipped = isWellBehaved && dRadius < 0;
+ bool isFirst = (coeffA > 0) != isFlipped;
// We want the larger root, per spec:
// "For all values of ω where r(ω) > 0, starting with the value of ω nearest
@@ -221,8 +222,11 @@ void SkTwoPointConicalGradient::appendGradientStages(SkArenaAlloc* alloc, SkRast
// (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createradialgradient)
//
// ... except when the gradient is flipped.
- p->append(isFlipped ? SkRasterPipeline::xy_to_2pt_conical_quadratic_min
- : SkRasterPipeline::xy_to_2pt_conical_quadratic_max, ctx);
+ //
+ // The first root (-b + sqrt(...)) / 2a is larger if a (i.e. coeffA) > 0 and the second
+ // root (-b - sqrt(...)) / 2a is larger if a < 0.
+ p->append(isFirst ? SkRasterPipeline::xy_to_2pt_conical_quadratic_first
+ : SkRasterPipeline::xy_to_2pt_conical_quadratic_second, ctx);
}
if (!isWellBehaved) {