OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (size) { | 63 if (size) { |
64 *size = SkISize::Make(SkToS32(width), SkToS32(height)); | 64 *size = SkISize::Make(SkToS32(width), SkToS32(height)); |
65 } | 65 } |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 bool SkWbmpCodec::onRewind() { | 69 bool SkWbmpCodec::onRewind() { |
70 return read_header(this->stream(), nullptr); | 70 return read_header(this->stream(), nullptr); |
71 } | 71 } |
72 | 72 |
73 SkSwizzler* SkWbmpCodec::initializeSwizzler(const SkImageInfo& info, | 73 SkSwizzler* SkWbmpCodec::initializeSwizzler(const SkImageInfo& info, const SkPMC
olor* ctable, |
74 const SkPMColor* ctable, const Options& opts) { | 74 const Options& opts) { |
75 // Create the swizzler based on the desired color type | 75 // Create the swizzler based on the desired color type |
76 switch (info.colorType()) { | 76 switch (info.colorType()) { |
77 case kIndex_8_SkColorType: | 77 case kIndex_8_SkColorType: |
78 case kN32_SkColorType: | 78 case kN32_SkColorType: |
79 case kRGB_565_SkColorType: | 79 case kRGB_565_SkColorType: |
80 case kGray_8_SkColorType: | 80 case kGray_8_SkColorType: |
81 break; | 81 break; |
82 default: | 82 default: |
83 return nullptr; | 83 return nullptr; |
84 } | 84 } |
85 return SkSwizzler::CreateSwizzler(SkSwizzler::kBit, ctable, info, | 85 return SkSwizzler::CreateSwizzler(SkSwizzler::kBit, ctable, info, opts); |
86 opts.fZeroInitialized); | |
87 } | 86 } |
88 | 87 |
89 bool SkWbmpCodec::readRow(uint8_t* row) { | 88 bool SkWbmpCodec::readRow(uint8_t* row) { |
90 return this->stream()->read(row, fSrcRowBytes) == fSrcRowBytes; | 89 return this->stream()->read(row, fSrcRowBytes) == fSrcRowBytes; |
91 } | 90 } |
92 | 91 |
93 SkWbmpCodec::SkWbmpCodec(const SkImageInfo& info, SkStream* stream) | 92 SkWbmpCodec::SkWbmpCodec(const SkImageInfo& info, SkStream* stream) |
94 : INHERITED(info, stream) | 93 : INHERITED(info, stream) |
95 , fSrcRowBytes(get_src_row_bytes(this->getInfo().width())) | 94 , fSrcRowBytes(get_src_row_bytes(this->getInfo().width())) |
96 , fColorTable(nullptr) | 95 , fColorTable(nullptr) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 180 |
182 // Fill in the color table | 181 // Fill in the color table |
183 setup_color_table(dstInfo.colorType(), inputColorTable, inputColorCount); | 182 setup_color_table(dstInfo.colorType(), inputColorTable, inputColorCount); |
184 | 183 |
185 // Copy the color table to a pointer that can be owned by the scanline decod
er | 184 // Copy the color table to a pointer that can be owned by the scanline decod
er |
186 if (kIndex_8_SkColorType == dstInfo.colorType()) { | 185 if (kIndex_8_SkColorType == dstInfo.colorType()) { |
187 fColorTable.reset(new SkColorTable(inputColorTable, 2)); | 186 fColorTable.reset(new SkColorTable(inputColorTable, 2)); |
188 } | 187 } |
189 | 188 |
190 // Initialize the swizzler | 189 // Initialize the swizzler |
191 fSwizzler.reset(this->initializeSwizzler(dstInfo, | 190 fSwizzler.reset(this->initializeSwizzler(dstInfo, get_color_ptr(fColorTable.
get()), options)); |
192 get_color_ptr(fColorTable.get()), options)); | |
193 if (nullptr == fSwizzler.get()) { | 191 if (nullptr == fSwizzler.get()) { |
194 return kInvalidConversion; | 192 return kInvalidConversion; |
195 } | 193 } |
196 | 194 |
197 fSrcBuffer.reset(fSrcRowBytes); | 195 fSrcBuffer.reset(fSrcRowBytes); |
198 | 196 |
199 return kSuccess; | 197 return kSuccess; |
200 } | 198 } |
OLD | NEW |