Fix SkRadialGradient center discontinuity

(AKA let's slow down radial gradients!)

Avoid discontinuities when r ~= 0.

BUG=skia:5052
R=reed@google.com,mtklein@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1753133003

Review URL: https://codereview.chromium.org/1753133003
This commit is contained in:
fmalita 2016-03-04 06:29:35 -08:00 committed by Commit bot
parent 8ee78f31b2
commit 0032a302ca

View File

@ -111,6 +111,7 @@ void shadeSpan_radial_clamp2(SkScalar sfx, SkScalar sdx, SkScalar sfy, SkScalar
cache[next_dither_toggle(toggle) + fi],
count);
} else {
const Sk4f min(SK_ScalarNearlyZero);
const Sk4f max(255);
const float scale = 255;
sfx *= scale;
@ -124,13 +125,13 @@ void shadeSpan_radial_clamp2(SkScalar sfx, SkScalar sdx, SkScalar sfy, SkScalar
Sk4f tmpxy = fx4 * dx4 + fy4 * dy4;
Sk4f tmpdxdy = sum_squares(dx4, dy4);
Sk4f R = sum_squares(fx4, fy4);
Sk4f R = Sk4f::Max(sum_squares(fx4, fy4), min);
Sk4f dR = tmpxy + tmpxy + tmpdxdy;
const Sk4f ddR = tmpdxdy + tmpdxdy;
for (int i = 0; i < (count >> 2); ++i) {
Sk4f dist = Sk4f::Min(fast_sqrt(R), max);
R = R + dR;
R = Sk4f::Max(R + dR, min);
dR = dR + ddR;
uint8_t fi[4];