| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 bool SkTableMaskFilter::filterMask(SkMask* dst, const SkMask& src, | 27 bool SkTableMaskFilter::filterMask(SkMask* dst, const SkMask& src, |
| 28 const SkMatrix&, SkIPoint* margin) const { | 28 const SkMatrix&, SkIPoint* margin) const { |
| 29 if (src.fFormat != SkMask::kA8_Format) { | 29 if (src.fFormat != SkMask::kA8_Format) { |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 | 32 |
| 33 dst->fBounds = src.fBounds; | 33 dst->fBounds = src.fBounds; |
| 34 dst->fRowBytes = SkAlign4(dst->fBounds.width()); | 34 dst->fRowBytes = SkAlign4(dst->fBounds.width()); |
| 35 dst->fFormat = SkMask::kA8_Format; | 35 dst->fFormat = SkMask::kA8_Format; |
| 36 dst->fImage = NULL; | 36 dst->fImage = nullptr; |
| 37 | 37 |
| 38 if (src.fImage) { | 38 if (src.fImage) { |
| 39 dst->fImage = SkMask::AllocImage(dst->computeImageSize()); | 39 dst->fImage = SkMask::AllocImage(dst->computeImageSize()); |
| 40 | 40 |
| 41 const uint8_t* srcP = src.fImage; | 41 const uint8_t* srcP = src.fImage; |
| 42 uint8_t* dstP = dst->fImage; | 42 uint8_t* dstP = dst->fImage; |
| 43 const uint8_t* table = fTable; | 43 const uint8_t* table = fTable; |
| 44 int dstWidth = dst->fBounds.width(); | 44 int dstWidth = dst->fBounds.width(); |
| 45 int extraZeros = dst->fRowBytes - dstWidth; | 45 int extraZeros = dst->fRowBytes - dstWidth; |
| 46 | 46 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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 wb.writeByteArray(fTable, 256); | 74 wb.writeByteArray(fTable, 256); |
| 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 nullptr; |
| 81 } | 81 } |
| 82 return Create(table); | 82 return Create(table); |
| 83 } | 83 } |
| 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 |
| (...skipping 45 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 |