| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 SkCodecPrintf("Error: unable to skip to image data.\n"); | 143 SkCodecPrintf("Error: unable to skip to image data.\n"); |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Return true on success | 148 // Return true on success |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
tions& opts) { | 152 void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
tions& opts) { |
| 153 // In the case of paletted ico-in-bmps, we will report BGRA to the client, | 153 // In the case of bmp-in-icos, we will report BGRA to the client, |
| 154 // since we may be required to apply an alpha mask after the decode. But | 154 // since we may be required to apply an alpha mask after the decode. |
| 155 // the swizzler needs to know the actual format of the bmp. | 155 // However, the swizzler needs to know the actual format of the bmp. |
| 156 SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); | 156 SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); |
| 157 if (fInIco && this->bitsPerPixel() <= 8) { | 157 if (fInIco) { |
| 158 swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, swizzl
erInfo.alpha(), | 158 if (this->bitsPerPixel() <= 8) { |
| 159 this->bitsPerPixel()); | 159 swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, |
| 160 swizzlerInfo.alpha(), this->bitsPerPixel()); |
| 161 } else if (this->bitsPerPixel() == 24) { |
| 162 swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kBGR_Color, |
| 163 SkEncodedInfo::kOpaque_Alpha, 8); |
| 164 } |
| 160 } | 165 } |
| 161 | 166 |
| 162 // Get a pointer to the color table if it exists | 167 // Get a pointer to the color table if it exists |
| 163 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 168 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 164 | 169 |
| 165 // Create swizzler | 170 // Create swizzler |
| 166 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, colorPtr, dstInfo,
opts)); | 171 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, colorPtr, dstInfo,
opts)); |
| 167 SkASSERT(fSwizzler); | 172 SkASSERT(fSwizzler); |
| 168 } | 173 } |
| 169 | 174 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 } | 302 } |
| 298 } | 303 } |
| 299 | 304 |
| 300 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { | 305 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { |
| 301 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 306 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
| 302 if (colorPtr) { | 307 if (colorPtr) { |
| 303 return get_color_table_fill_value(colorType, colorPtr, 0); | 308 return get_color_table_fill_value(colorType, colorPtr, 0); |
| 304 } | 309 } |
| 305 return INHERITED::onGetFillValue(colorType); | 310 return INHERITED::onGetFillValue(colorType); |
| 306 } | 311 } |
| OLD | NEW |