OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
9 #include "SkTableMaskFilter.h" | 9 #include "SkTableMaskFilter.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 SkMask::Format SkTableMaskFilter::getFormat() const { | 68 SkMask::Format SkTableMaskFilter::getFormat() const { |
69 return SkMask::kA8_Format; | 69 return SkMask::kA8_Format; |
70 } | 70 } |
71 | 71 |
72 void SkTableMaskFilter::flatten(SkWriteBuffer& wb) const { | 72 void SkTableMaskFilter::flatten(SkWriteBuffer& wb) const { |
73 wb.writeByteArray(fTable, 256); | 73 wb.writeByteArray(fTable, 256); |
74 } | 74 } |
75 | 75 |
76 SkFlattenable* SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) { | 76 sk_sp<SkFlattenable> SkTableMaskFilter::CreateProc(SkReadBuffer& buffer) { |
77 uint8_t table[256]; | 77 uint8_t table[256]; |
78 if (!buffer.readByteArray(table, 256)) { | 78 if (!buffer.readByteArray(table, 256)) { |
79 return nullptr; | 79 return nullptr; |
80 } | 80 } |
81 return Create(table); | 81 return sk_sp<SkFlattenable>(Create(table)); |
82 } | 82 } |
83 | 83 |
84 /////////////////////////////////////////////////////////////////////////////// | 84 /////////////////////////////////////////////////////////////////////////////// |
85 | 85 |
86 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { | 86 void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) { |
87 const float dx = 1 / 255.0f; | 87 const float dx = 1 / 255.0f; |
88 const float g = SkScalarToFloat(gamma); | 88 const float g = SkScalarToFloat(gamma); |
89 | 89 |
90 float x = 0; | 90 float x = 0; |
91 for (int i = 0; i < 256; i++) { | 91 for (int i = 0; i < 256; i++) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 str->append("table: "); | 136 str->append("table: "); |
137 for (int i = 0; i < 255; ++i) { | 137 for (int i = 0; i < 255; ++i) { |
138 str->appendf("%d, ", fTable[i]); | 138 str->appendf("%d, ", fTable[i]); |
139 } | 139 } |
140 str->appendf("%d", fTable[255]); | 140 str->appendf("%d", fTable[255]); |
141 | 141 |
142 str->append(")"); | 142 str->append(")"); |
143 } | 143 } |
144 #endif | 144 #endif |
OLD | NEW |