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 ico-in-bmps, we will report BGRA to the client, |
scroggo
2016/05/04 13:02:19
nit: Shouldn't this be bmp-in-icos?
msarett
2016/05/04 19:27:49
Done.
| |
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 switch (this->bitsPerPixel()) { |
159 this->bitsPerPixel()); | 159 case 8: |
scroggo
2016/05/04 13:02:19
We used to handle <= 8. I take it < was unnecessar
msarett
2016/05/04 19:27:49
Nice catch! This is me trying to introduce a new
| |
160 swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color , | |
161 swizzlerInfo.alpha(), this->bitsPerPixel()); | |
scroggo
2016/05/04 13:02:19
8?
msarett
2016/05/04 19:27:49
It could be 1, 2, 4, or 8.
| |
162 break; | |
163 case 24: | |
164 swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kBGR_Color, | |
165 SkEncodedInfo::kOpaque_Alpha, swizzlerInfo.bitsPerCompon ent()); | |
scroggo
2016/05/04 13:02:19
Why do you need to check bitsPerComponent here? Wi
msarett
2016/05/04 19:27:49
It will always be 8. I'll put 8.
| |
166 break; | |
167 default: | |
168 break; | |
169 } | |
160 } | 170 } |
161 | 171 |
162 // Get a pointer to the color table if it exists | 172 // Get a pointer to the color table if it exists |
163 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 173 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
164 | 174 |
165 // Create swizzler | 175 // Create swizzler |
166 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, colorPtr, dstInfo, opts)); | 176 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, colorPtr, dstInfo, opts)); |
167 SkASSERT(fSwizzler); | 177 SkASSERT(fSwizzler); |
168 } | 178 } |
169 | 179 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 } | 307 } |
298 } | 308 } |
299 | 309 |
300 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { | 310 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { |
301 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); | 311 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); |
302 if (colorPtr) { | 312 if (colorPtr) { |
303 return get_color_table_fill_value(colorType, colorPtr, 0); | 313 return get_color_table_fill_value(colorType, colorPtr, 0); |
304 } | 314 } |
305 return INHERITED::onGetFillValue(colorType); | 315 return INHERITED::onGetFillValue(colorType); |
306 } | 316 } |
OLD | NEW |