| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (stream()->skip(fOffset - colorBytes) != fOffset - colorBytes) { | 154 if (stream()->skip(fOffset - colorBytes) != fOffset - colorBytes) { |
| 155 SkCodecPrintf("Error: unable to skip to image data.\n"); | 155 SkCodecPrintf("Error: unable to skip to image data.\n"); |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Return true on success | 160 // Return true on success |
| 161 return true; | 161 return true; |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, | 164 bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
tions& opts) { |
| 165 const Options& opts) { | |
| 166 // Get swizzler configuration | 165 // Get swizzler configuration |
| 167 SkSwizzler::SrcConfig config; | 166 SkSwizzler::SrcConfig config; |
| 168 switch (this->bitsPerPixel()) { | 167 switch (this->bitsPerPixel()) { |
| 169 case 1: | 168 case 1: |
| 170 config = SkSwizzler::kIndex1; | 169 config = SkSwizzler::kIndex1; |
| 171 break; | 170 break; |
| 172 case 2: | 171 case 2: |
| 173 config = SkSwizzler::kIndex2; | 172 config = SkSwizzler::kIndex2; |
| 174 break; | 173 break; |
| 175 case 4: | 174 case 4: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 190 break; | 189 break; |
| 191 default: | 190 default: |
| 192 SkASSERT(false); | 191 SkASSERT(false); |
| 193 return false; | 192 return false; |
| 194 } | 193 } |
| 195 | 194 |
| 196 // Get a pointer to the color table if it exists | 195 // Get a pointer to the color table if it exists |
| 197 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 196 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 198 | 197 |
| 199 // Create swizzler | 198 // Create swizzler |
| 200 fSwizzler.reset(SkSwizzler::CreateSwizzler(config, | 199 fSwizzler.reset(SkSwizzler::CreateSwizzler(config, colorPtr, dstInfo, opts))
; |
| 201 colorPtr, dstInfo, opts.fZeroInitialized)); | |
| 202 | 200 |
| 203 if (nullptr == fSwizzler.get()) { | 201 if (nullptr == fSwizzler.get()) { |
| 204 return false; | 202 return false; |
| 205 } | 203 } |
| 206 return true; | 204 return true; |
| 207 } | 205 } |
| 208 | 206 |
| 209 SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, | 207 SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, |
| 210 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount) { | 208 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount) { |
| 211 // Create the color table if necessary and prepare the stream for decode | 209 // Create the color table if necessary and prepare the stream for decode |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return kSuccess; | 289 return kSuccess; |
| 292 } | 290 } |
| 293 | 291 |
| 294 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType, SkAlphaType a
lphaType) const { | 292 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType, SkAlphaType a
lphaType) const { |
| 295 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 293 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 296 if (colorPtr) { | 294 if (colorPtr) { |
| 297 return get_color_table_fill_value(colorType, colorPtr, 0); | 295 return get_color_table_fill_value(colorType, colorPtr, 0); |
| 298 } | 296 } |
| 299 return INHERITED::onGetFillValue(colorType, alphaType); | 297 return INHERITED::onGetFillValue(colorType, alphaType); |
| 300 } | 298 } |
| OLD | NEW |