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

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

Issue 1314583003: Replace SkPin32 with SkTPin and remove. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment. Created 5 years, 3 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/SkTableMaskFilter.cpp ('k') | 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 "SkRadialGradient_Table.h" 10 #include "SkRadialGradient_Table.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 we could (it seems) put this scale-down into fDstToIndex, 85 we could (it seems) put this scale-down into fDstToIndex,
86 to avoid having to do these extra shifts each time. 86 to avoid having to do these extra shifts each time.
87 */ 87 */
88 SkFixed fx = SkScalarToFixed(sfx) >> 1; 88 SkFixed fx = SkScalarToFixed(sfx) >> 1;
89 SkFixed dx = SkScalarToFixed(sdx) >> 1; 89 SkFixed dx = SkScalarToFixed(sdx) >> 1;
90 SkFixed fy = SkScalarToFixed(sfy) >> 1; 90 SkFixed fy = SkScalarToFixed(sfy) >> 1;
91 SkFixed dy = SkScalarToFixed(sdy) >> 1; 91 SkFixed dy = SkScalarToFixed(sdy) >> 1;
92 // might perform this check for the other modes, 92 // might perform this check for the other modes,
93 // but the win will be a smaller % of the total 93 // but the win will be a smaller % of the total
94 if (dy == 0) { 94 if (dy == 0) {
95 fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1); 95 fy = SkTPin(fy, -0xFFFF >> 1, 0xFFFF >> 1);
96 fy *= fy; 96 fy *= fy;
97 do { 97 do {
98 unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1); 98 unsigned xx = SkTPin(fx, -0xFFFF >> 1, 0xFFFF >> 1);
99 unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS); 99 unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS);
100 fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS)); 100 fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
101 fx += dx; 101 fx += dx;
102 *dstC++ = cache[toggle + 102 *dstC++ = cache[toggle +
103 (sqrt_table[fi] >> SkGradientShaderBase::kSqrt16Shif t)]; 103 (sqrt_table[fi] >> SkGradientShaderBase::kSqrt16Shif t)];
104 toggle = next_dither_toggle16(toggle); 104 toggle = next_dither_toggle16(toggle);
105 } while (--count != 0); 105 } while (--count != 0);
106 } else { 106 } else {
107 do { 107 do {
108 unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1); 108 unsigned xx = SkTPin(fx, -0xFFFF >> 1, 0xFFFF >> 1);
109 unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1); 109 unsigned fi = SkTPin(fy, -0xFFFF >> 1, 0xFFFF >> 1);
110 fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS); 110 fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS);
111 fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS)); 111 fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
112 fx += dx; 112 fx += dx;
113 fy += dy; 113 fy += dy;
114 *dstC++ = cache[toggle + 114 *dstC++ = cache[toggle +
115 (sqrt_table[fi] >> SkGradientShaderBase::kSqrt16Shif t)]; 115 (sqrt_table[fi] >> SkGradientShaderBase::kSqrt16Shif t)];
116 toggle = next_dither_toggle16(toggle); 116 toggle = next_dither_toggle16(toggle);
117 } while (--count != 0); 117 } while (--count != 0);
118 } 118 }
119 } 119 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 str->appendScalar(fCenter.fY); 561 str->appendScalar(fCenter.fY);
562 str->append(") radius: "); 562 str->append(") radius: ");
563 str->appendScalar(fRadius); 563 str->appendScalar(fRadius);
564 str->append(" "); 564 str->append(" ");
565 565
566 this->INHERITED::toString(str); 566 this->INHERITED::toString(str);
567 567
568 str->append(")"); 568 str->append(")");
569 } 569 }
570 #endif 570 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTableMaskFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698