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