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 "SkBmpStandardCodec.h" | 8 #include "SkBmpStandardCodec.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 SkCodecPrintf("Error: unable to skip to image data.\n"); | 146 SkCodecPrintf("Error: unable to skip to image data.\n"); |
147 return false; | 147 return false; |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 // Return true on success | 151 // Return true on success |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
tions& opts) { | 155 void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
tions& opts) { |
156 // Get swizzler configuration | |
157 SkSwizzler::SrcConfig config = SkSwizzler::kUnknown; | |
158 switch (this->bitsPerPixel()) { | |
159 case 1: | |
160 config = SkSwizzler::kIndex1; | |
161 break; | |
162 case 2: | |
163 config = SkSwizzler::kIndex2; | |
164 break; | |
165 case 4: | |
166 config = SkSwizzler::kIndex4; | |
167 break; | |
168 case 8: | |
169 config = SkSwizzler::kIndex; | |
170 break; | |
171 case 24: | |
172 config = SkSwizzler::kBGR; | |
173 break; | |
174 case 32: | |
175 if (fIsOpaque) { | |
176 config = SkSwizzler::kBGRX; | |
177 } else { | |
178 config = SkSwizzler::kBGRA; | |
179 } | |
180 break; | |
181 default: | |
182 SkASSERT(false); | |
183 } | |
184 | |
185 // Get a pointer to the color table if it exists | 156 // Get a pointer to the color table if it exists |
186 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 157 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
187 | 158 |
188 // Create swizzler | 159 // Create swizzler |
189 fSwizzler.reset(SkSwizzler::CreateSwizzler(config, colorPtr, dstInfo, opts))
; | 160 fSwizzler.reset(SkSwizzler::CreateSwizzler(this->getEncodedInfo(), colorPtr,
dstInfo, opts)); |
190 SkASSERT(fSwizzler); | 161 SkASSERT(fSwizzler); |
191 } | 162 } |
192 | 163 |
193 SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, | 164 SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, |
194 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount) { | 165 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount) { |
195 // Create the color table if necessary and prepare the stream for decode | 166 // Create the color table if necessary and prepare the stream for decode |
196 // Note that if it is non-NULL, inputColorCount will be modified | 167 // Note that if it is non-NULL, inputColorCount will be modified |
197 if (!this->createColorTable(dstInfo.alphaType(), inputColorCount)) { | 168 if (!this->createColorTable(dstInfo.alphaType(), inputColorCount)) { |
198 SkCodecPrintf("Error: could not create color table.\n"); | 169 SkCodecPrintf("Error: could not create color table.\n"); |
199 return SkCodec::kInvalidInput; | 170 return SkCodec::kInvalidInput; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } | 290 } |
320 } | 291 } |
321 | 292 |
322 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { | 293 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { |
323 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 294 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
324 if (colorPtr) { | 295 if (colorPtr) { |
325 return get_color_table_fill_value(colorType, colorPtr, 0); | 296 return get_color_table_fill_value(colorType, colorPtr, 0); |
326 } | 297 } |
327 return INHERITED::onGetFillValue(colorType); | 298 return INHERITED::onGetFillValue(colorType); |
328 } | 299 } |
OLD | NEW |