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>
This commit is contained in:
Yuqian Li 2017-12-11 14:17:47 -05:00 committed by Skia Commit-Bot
parent 73822257cb
commit 7741c75152
6 changed files with 8778 additions and 8865 deletions

View File

@ -85,8 +85,8 @@ struct SkJumper_Engine;
M(evenly_spaced_2_stop_gradient) \
M(xy_to_unit_angle) \
M(xy_to_radius) \
M(xy_to_2pt_conical_quadratic_min) \
M(xy_to_2pt_conical_quadratic_max) \
M(xy_to_2pt_conical_quadratic_first) \
M(xy_to_2pt_conical_quadratic_second) \
M(xy_to_2pt_conical_linear) \
M(mask_2pt_conical_degenerates) M(apply_vector_mask) \
M(byte_tables) M(byte_tables_rgb) \

View File

@ -259,8 +259,8 @@ extern "C" {
LOWP(evenly_spaced_2_stop_gradient)
LOWP(xy_to_unit_angle)
LOWP(xy_to_radius)
TODO(xy_to_2pt_conical_quadratic_min)
TODO(xy_to_2pt_conical_quadratic_max)
TODO(xy_to_2pt_conical_quadratic_first)
TODO(xy_to_2pt_conical_quadratic_second)
TODO(xy_to_2pt_conical_linear)
TODO(mask_2pt_conical_degenerates) TODO(apply_vector_mask)
TODO(byte_tables) TODO(byte_tables_rgb)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -304,6 +304,9 @@ STAGE(store_rgba, float* ptr) {
SI F inv(F x) { return 1.0f - x; }
SI F two(F x) { return x + x; }
SI F first (F a, F b) { return a; }
SI F second(F a, F b) { return b; }
BLEND_MODE(clear) { return 0; }
BLEND_MODE(srcatop) { return s*da + d*inv(sa); }
@ -1287,12 +1290,12 @@ SI F solve_2pt_conical_quadratic(const SkJumper_2PtConicalCtx* c, F x, F y, F (*
(-coeffB - sqrt_disc) * (invCoeffA * 0.5f));
}
STAGE(xy_to_2pt_conical_quadratic_max, const SkJumper_2PtConicalCtx* ctx) {
r = solve_2pt_conical_quadratic(ctx, r, g, max);
STAGE(xy_to_2pt_conical_quadratic_first, const SkJumper_2PtConicalCtx* ctx) {
r = solve_2pt_conical_quadratic(ctx, r, g, first);
}
STAGE(xy_to_2pt_conical_quadratic_min, const SkJumper_2PtConicalCtx* ctx) {
r = solve_2pt_conical_quadratic(ctx, r, g, min);
STAGE(xy_to_2pt_conical_quadratic_second, const SkJumper_2PtConicalCtx* ctx) {
r = solve_2pt_conical_quadratic(ctx, r, g, second);
}
STAGE(xy_to_2pt_conical_linear, const SkJumper_2PtConicalCtx* c) {

View File

@ -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) {