Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: src/effects/gradients/SkRadialGradient.cpp

Issue 1753133003: Fix SkRadialGradient center discontinuity (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: v2 Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkRadialGradient.h" 9 #include "SkRadialGradient.h"
10 #include "SkNx.h" 10 #include "SkNx.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void shadeSpan_radial_clamp2(SkScalar sfx, SkScalar sdx, SkScalar sfy, SkScalar sdy, 104 void shadeSpan_radial_clamp2(SkScalar sfx, SkScalar sdx, SkScalar sfy, SkScalar sdy,
105 SkPMColor* SK_RESTRICT dstC, const SkPMColor* SK_RE STRICT cache, 105 SkPMColor* SK_RESTRICT dstC, const SkPMColor* SK_RE STRICT cache,
106 int count, int toggle) { 106 int count, int toggle) {
107 if (radial_completely_pinned(sfx, sdx, sfy, sdy)) { 107 if (radial_completely_pinned(sfx, sdx, sfy, sdy)) {
108 unsigned fi = SkGradientShaderBase::kCache32Count - 1; 108 unsigned fi = SkGradientShaderBase::kCache32Count - 1;
109 sk_memset32_dither(dstC, 109 sk_memset32_dither(dstC,
110 cache[toggle + fi], 110 cache[toggle + fi],
111 cache[next_dither_toggle(toggle) + fi], 111 cache[next_dither_toggle(toggle) + fi],
112 count); 112 count);
113 } else { 113 } else {
114 const Sk4f min(SK_ScalarNearlyZero);
114 const Sk4f max(255); 115 const Sk4f max(255);
115 const float scale = 255; 116 const float scale = 255;
116 sfx *= scale; 117 sfx *= scale;
117 sfy *= scale; 118 sfy *= scale;
118 sdx *= scale; 119 sdx *= scale;
119 sdy *= scale; 120 sdy *= scale;
120 const Sk4f fx4(sfx, sfx + sdx, sfx + 2*sdx, sfx + 3*sdx); 121 const Sk4f fx4(sfx, sfx + sdx, sfx + 2*sdx, sfx + 3*sdx);
121 const Sk4f fy4(sfy, sfy + sdy, sfy + 2*sdy, sfy + 3*sdy); 122 const Sk4f fy4(sfy, sfy + sdy, sfy + 2*sdy, sfy + 3*sdy);
122 const Sk4f dx4(sdx * 4); 123 const Sk4f dx4(sdx * 4);
123 const Sk4f dy4(sdy * 4); 124 const Sk4f dy4(sdy * 4);
124 125
125 Sk4f tmpxy = fx4 * dx4 + fy4 * dy4; 126 Sk4f tmpxy = fx4 * dx4 + fy4 * dy4;
126 Sk4f tmpdxdy = sum_squares(dx4, dy4); 127 Sk4f tmpdxdy = sum_squares(dx4, dy4);
127 Sk4f R = sum_squares(fx4, fy4); 128 Sk4f R = Sk4f::Max(sum_squares(fx4, fy4), min);
128 Sk4f dR = tmpxy + tmpxy + tmpdxdy; 129 Sk4f dR = tmpxy + tmpxy + tmpdxdy;
129 const Sk4f ddR = tmpdxdy + tmpdxdy; 130 const Sk4f ddR = tmpdxdy + tmpdxdy;
130 131
131 for (int i = 0; i < (count >> 2); ++i) { 132 for (int i = 0; i < (count >> 2); ++i) {
132 Sk4f dist = Sk4f::Min(fast_sqrt(R), max); 133 Sk4f dist = Sk4f::Min(fast_sqrt(R), max);
133 R = R + dR; 134 R = Sk4f::Max(R + dR, min);
134 dR = dR + ddR; 135 dR = dR + ddR;
135 136
136 uint8_t fi[4]; 137 uint8_t fi[4];
137 SkNx_cast<uint8_t>(dist).store(fi); 138 SkNx_cast<uint8_t>(dist).store(fi);
138 139
139 for (int i = 0; i < 4; i++) { 140 for (int i = 0; i < 4; i++) {
140 *dstC++ = cache[toggle + fi[i]]; 141 *dstC++ = cache[toggle + fi[i]];
141 toggle = next_dither_toggle(toggle); 142 toggle = next_dither_toggle(toggle);
142 } 143 }
143 } 144 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 str->appendScalar(fCenter.fY); 377 str->appendScalar(fCenter.fY);
377 str->append(") radius: "); 378 str->append(") radius: ");
378 str->appendScalar(fRadius); 379 str->appendScalar(fRadius);
379 str->append(" "); 380 str->append(" ");
380 381
381 this->INHERITED::toString(str); 382 this->INHERITED::toString(str);
382 383
383 str->append(")"); 384 str->append(")");
384 } 385 }
385 #endif 386 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698