OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |