OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
10 #include "SkTableMaskFilter.h" | 10 #include "SkTableMaskFilter.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 /////////////////////////////////////////////////////////////////////////////// | 85 /////////////////////////////////////////////////////////////////////////////// |
86 | 86 |
87 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { | 87 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { |
88 const float dx = 1 / 255.0f; | 88 const float dx = 1 / 255.0f; |
89 const float g = SkScalarToFloat(gamma); | 89 const float g = SkScalarToFloat(gamma); |
90 | 90 |
91 float x = 0; | 91 float x = 0; |
92 for (int i = 0; i < 256; i++) { | 92 for (int i = 0; i < 256; i++) { |
93 // float ee = powf(x, g) * 255; | 93 // float ee = powf(x, g) * 255; |
94 table[i] = SkPin32(sk_float_round2int(powf(x, g) * 255), 0, 255); | 94 table[i] = SkTPin(sk_float_round2int(powf(x, g) * 255), 0, 255); |
95 x += dx; | 95 x += dx; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void SkTableMaskFilter::MakeClipTable(uint8_t table[256], uint8_t min, | 99 void SkTableMaskFilter::MakeClipTable(uint8_t table[256], uint8_t min, |
100 uint8_t max) { | 100 uint8_t max) { |
101 if (0 == max) { | 101 if (0 == max) { |
102 max = 1; | 102 max = 1; |
103 } | 103 } |
104 if (min >= max) { | 104 if (min >= max) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 str->append("table: "); | 137 str->append("table: "); |
138 for (int i = 0; i < 255; ++i) { | 138 for (int i = 0; i < 255; ++i) { |
139 str->appendf("%d, ", fTable[i]); | 139 str->appendf("%d, ", fTable[i]); |
140 } | 140 } |
141 str->appendf("%d", fTable[255]); | 141 str->appendf("%d", fTable[255]); |
142 | 142 |
143 str->append(")"); | 143 str->append(")"); |
144 } | 144 } |
145 #endif | 145 #endif |
OLD | NEW |