Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: src/codec/SkBmpStandardCodec.cpp

Issue 1911613002: Use SkEncodedInfo in place of SkSwizzler::SrcConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bmp bug Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/codec/SkEncodedInfo.h ('k') | src/codec/SkGifCodec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 156 // In the case of paletted ico-in-bmps, we will report BGRA to the client,
157 SkSwizzler::SrcConfig config = SkSwizzler::kUnknown; 157 // since we may be required to apply an alpha mask after the decode. But
158 switch (this->bitsPerPixel()) { 158 // the swizzler needs to know the actual format of the bmp.
159 case 1: 159 SkEncodedInfo swizzlerInfo = this->getEncodedInfo();
160 config = SkSwizzler::kIndex1; 160 if (fInIco && this->bitsPerPixel() <= 8) {
161 break; 161 swizzlerInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, swizzl erInfo.alpha(),
162 case 2: 162 this->bitsPerPixel());
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 } 163 }
184 164
185 // Get a pointer to the color table if it exists 165 // Get a pointer to the color table if it exists
186 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); 166 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
187 167
188 // Create swizzler 168 // Create swizzler
189 fSwizzler.reset(SkSwizzler::CreateSwizzler(config, colorPtr, dstInfo, opts)) ; 169 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, colorPtr, dstInfo, opts));
190 SkASSERT(fSwizzler); 170 SkASSERT(fSwizzler);
191 } 171 }
192 172
193 SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, 173 SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo,
194 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) { 174 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
195 // Create the color table if necessary and prepare the stream for decode 175 // Create the color table if necessary and prepare the stream for decode
196 // Note that if it is non-NULL, inputColorCount will be modified 176 // Note that if it is non-NULL, inputColorCount will be modified
197 if (!this->createColorTable(dstInfo.alphaType(), inputColorCount)) { 177 if (!this->createColorTable(dstInfo.alphaType(), inputColorCount)) {
198 SkCodecPrintf("Error: could not create color table.\n"); 178 SkCodecPrintf("Error: could not create color table.\n");
199 return SkCodec::kInvalidInput; 179 return SkCodec::kInvalidInput;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 299 }
320 } 300 }
321 301
322 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const { 302 uint32_t SkBmpStandardCodec::onGetFillValue(SkColorType colorType) const {
323 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); 303 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
324 if (colorPtr) { 304 if (colorPtr) {
325 return get_color_table_fill_value(colorType, colorPtr, 0); 305 return get_color_table_fill_value(colorType, colorPtr, 0);
326 } 306 }
327 return INHERITED::onGetFillValue(colorType); 307 return INHERITED::onGetFillValue(colorType);
328 } 308 }
OLDNEW
« no previous file with comments | « include/codec/SkEncodedInfo.h ('k') | src/codec/SkGifCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698