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

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

Issue 886473003: add more checks for computing clamp counts, remove dead code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update comment on overflow test Created 5 years, 10 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 | « src/effects/gradients/SkClampRange.cpp ('k') | tests/GradientTest.cpp » ('j') | 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 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLinearGradient.h" 8 #include "SkLinearGradient.h"
9 9
10 static inline int repeat_bits(int x, const int bits) { 10 static inline int repeat_bits(int x, const int bits) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 SkPMColor dlerp = SkFastFourByteInterp(cache[index1], cache[index0], remaind er); 142 SkPMColor dlerp = SkFastFourByteInterp(cache[index1], cache[index0], remaind er);
143 sk_memset32_dither(dstC, lerp, dlerp, count); 143 sk_memset32_dither(dstC, lerp, dlerp, count);
144 } 144 }
145 145
146 void shadeSpan_linear_clamp(TileProc proc, SkGradFixed dx, SkGradFixed fx, 146 void shadeSpan_linear_clamp(TileProc proc, SkGradFixed dx, SkGradFixed fx,
147 SkPMColor* SK_RESTRICT dstC, 147 SkPMColor* SK_RESTRICT dstC,
148 const SkPMColor* SK_RESTRICT cache, 148 const SkPMColor* SK_RESTRICT cache,
149 int toggle, int count) { 149 int toggle, int count) {
150 SkClampRange range; 150 SkClampRange range;
151 range.init(fx, dx, count, 0, SkGradientShaderBase::kCache32Count - 1); 151 range.init(fx, dx, count, 0, SkGradientShaderBase::kCache32Count - 1);
152 range.validate(count);
152 153
153 if ((count = range.fCount0) > 0) { 154 if ((count = range.fCount0) > 0) {
154 sk_memset32_dither(dstC, 155 sk_memset32_dither(dstC,
155 cache[toggle + range.fV0], 156 cache[toggle + range.fV0],
156 cache[next_dither_toggle(toggle) + range.fV0], 157 cache[next_dither_toggle(toggle) + range.fV0],
157 count); 158 count);
158 dstC += count; 159 dstC += count;
159 } 160 }
160 if ((count = range.fCount1) > 0) { 161 if ((count = range.fCount1) > 0) {
161 int unroll = count >> 3; 162 int unroll = count >> 3;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 dither_memset16(dstC, cache[toggle + fi], 326 dither_memset16(dstC, cache[toggle + fi],
326 cache[next_dither_toggle16(toggle) + fi], count); 327 cache[next_dither_toggle16(toggle) + fi], count);
327 } 328 }
328 329
329 void shadeSpan16_linear_clamp(TileProc proc, SkGradFixed dx, SkGradFixed fx, 330 void shadeSpan16_linear_clamp(TileProc proc, SkGradFixed dx, SkGradFixed fx,
330 uint16_t* SK_RESTRICT dstC, 331 uint16_t* SK_RESTRICT dstC,
331 const uint16_t* SK_RESTRICT cache, 332 const uint16_t* SK_RESTRICT cache,
332 int toggle, int count) { 333 int toggle, int count) {
333 SkClampRange range; 334 SkClampRange range;
334 range.init(fx, dx, count, 0, SkGradientShaderBase::kCache32Count - 1); 335 range.init(fx, dx, count, 0, SkGradientShaderBase::kCache32Count - 1);
336 range.validate(count);
335 337
336 if ((count = range.fCount0) > 0) { 338 if ((count = range.fCount0) > 0) {
337 dither_memset16(dstC, 339 dither_memset16(dstC,
338 cache[toggle + range.fV0], 340 cache[toggle + range.fV0],
339 cache[next_dither_toggle16(toggle) + range.fV0], 341 cache[next_dither_toggle16(toggle) + range.fV0],
340 count); 342 count);
341 dstC += count; 343 dstC += count;
342 } 344 }
343 if ((count = range.fCount1) > 0) { 345 if ((count = range.fCount1) > 0) {
344 int unroll = count >> 3; 346 int unroll = count >> 3;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 str->append("SkLinearGradient ("); 606 str->append("SkLinearGradient (");
605 607
606 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 608 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
607 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 609 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
608 610
609 this->INHERITED::toString(str); 611 this->INHERITED::toString(str);
610 612
611 str->append(")"); 613 str->append(")");
612 } 614 }
613 #endif 615 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkClampRange.cpp ('k') | tests/GradientTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698