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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 SkFlattenable* SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) { | 77 SkFlattenable* SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) { |
78 uint8_t table[256]; | 78 uint8_t table[256]; |
79 if (!buffer.readByteArray(table, 256)) { | 79 if (!buffer.readByteArray(table, 256)) { |
80 return NULL; | 80 return NULL; |
81 } | 81 } |
82 return Create(table); | 82 return Create(table); |
83 } | 83 } |
84 | 84 |
85 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
86 SkTableMaskFilter::SkTableMaskFilter(SkReadBuffer& rb) : INHERITED(rb) { | |
87 SkASSERT(256 == rb.getArrayCount()); | |
88 rb.readByteArray(fTable, 256); | |
89 } | |
90 #endif | |
91 | |
92 /////////////////////////////////////////////////////////////////////////////// | 85 /////////////////////////////////////////////////////////////////////////////// |
93 | 86 |
94 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { | 87 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { |
95 const float dx = 1 / 255.0f; | 88 const float dx = 1 / 255.0f; |
96 const float g = SkScalarToFloat(gamma); | 89 const float g = SkScalarToFloat(gamma); |
97 | 90 |
98 float x = 0; | 91 float x = 0; |
99 for (int i = 0; i < 256; i++) { | 92 for (int i = 0; i < 256; i++) { |
100 // float ee = powf(x, g) * 255; | 93 // float ee = powf(x, g) * 255; |
101 table[i] = SkPin32(sk_float_round2int(powf(x, g) * 255), 0, 255); | 94 table[i] = SkPin32(sk_float_round2int(powf(x, g) * 255), 0, 255); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 136 |
144 str->append("table: "); | 137 str->append("table: "); |
145 for (int i = 0; i < 255; ++i) { | 138 for (int i = 0; i < 255; ++i) { |
146 str->appendf("%d, ", fTable[i]); | 139 str->appendf("%d, ", fTable[i]); |
147 } | 140 } |
148 str->appendf("%d", fTable[255]); | 141 str->appendf("%d", fTable[255]); |
149 | 142 |
150 str->append(")"); | 143 str->append(")"); |
151 } | 144 } |
152 #endif | 145 #endif |
OLD | NEW |