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

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

Issue 1287423002: Scanline decoding for bmp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments - Does not compile - Needs rebase for conv_poss update Created 5 years, 4 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
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 27 matching lines...) Expand all
38 default: 38 default:
39 return false; 39 return false;
40 } 40 }
41 } 41 }
42 42
43 /* 43 /*
44 * Creates an instance of the decoder 44 * Creates an instance of the decoder
45 * Called only by NewFromStream 45 * Called only by NewFromStream
46 */ 46 */
47 SkBmpStandardCodec::SkBmpStandardCodec(const SkImageInfo& info, SkStream* stream , 47 SkBmpStandardCodec::SkBmpStandardCodec(const SkImageInfo& info, SkStream* stream ,
48 SkBmpCodec::BmpInputFormat inputFormat,
48 uint16_t bitsPerPixel, uint32_t numColors , 49 uint16_t bitsPerPixel, uint32_t numColors ,
49 uint32_t bytesPerColor, uint32_t offset, 50 uint32_t bytesPerColor, uint32_t offset,
50 SkBmpCodec::RowOrder rowOrder, bool inIco ) 51 SkBmpCodec::RowOrder rowOrder, bool inIco )
51 : INHERITED(info, stream, bitsPerPixel, rowOrder) 52 : INHERITED(info, stream, inputFormat, bitsPerPixel, rowOrder)
52 , fColorTable(NULL) 53 , fColorTable(NULL)
53 , fNumColors(this->computeNumColors(numColors)) 54 , fNumColors(this->computeNumColors(numColors))
54 , fBytesPerColor(bytesPerColor) 55 , fBytesPerColor(bytesPerColor)
55 , fOffset(offset) 56 , fOffset(offset)
56 , fSwizzler(NULL) 57 , fSwizzler(NULL)
57 , fSrcBuffer(NULL) 58 , fSrcBuffer(NULL)
58 , fInIco(inIco) 59 , fInIco(inIco)
59 {} 60 {}
60 61
61 /* 62 /*
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 SkASSERT(false); 274 SkASSERT(false);
274 return 0; 275 return 0;
275 } 276 }
276 return fillColorOrIndex; 277 return fillColorOrIndex;
277 } 278 }
278 279
279 /* 280 /*
280 * Performs the bitmap decoding for standard input format 281 * Performs the bitmap decoding for standard input format
281 */ 282 */
282 SkCodec::Result SkBmpStandardCodec::decode(const SkImageInfo& dstInfo, 283 SkCodec::Result SkBmpStandardCodec::decode(const SkImageInfo& dstInfo,
283 void* dst, size_t dstRowBytes, 284 void* dst, size_t dstRowBytes,
284 const Options& opts) { 285 const Options& opts) {
285 // Set constant values 286 // Set constant values
286 const int width = dstInfo.width(); 287 const int width = dstInfo.width();
287 const int height = dstInfo.height(); 288 const int height = dstInfo.height();
288 const size_t rowBytes = SkAlign4(compute_row_bytes(width, this->bitsPerPixel ())); 289 const size_t rowBytes = SkAlign4(compute_row_bytes(width, this->bitsPerPixel ()));
289 290
290 // Iterate over rows of the image 291 // Iterate over rows of the image
291 for (int y = 0; y < height; y++) { 292 for (int y = 0; y < height; y++) {
292 // Read a row of the input 293 // Read a row of the input
293 if (this->stream()->read(fSrcBuffer.get(), rowBytes) != rowBytes) { 294 if (this->stream()->read(fSrcBuffer.get(), rowBytes) != rowBytes) {
294 SkCodecPrintf("Warning: incomplete input stream.\n"); 295 SkCodecPrintf("Warning: incomplete input stream.\n");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 uint32_t alphaBit = 353 uint32_t alphaBit =
353 (fSrcBuffer.get()[quotient] >> shift) & 0x1; 354 (fSrcBuffer.get()[quotient] >> shift) & 0x1;
354 dstRow[x] &= alphaBit - 1; 355 dstRow[x] &= alphaBit - 1;
355 } 356 }
356 } 357 }
357 } 358 }
358 359
359 // Finished decoding the entire image 360 // Finished decoding the entire image
360 return kSuccess; 361 return kSuccess;
361 } 362 }
363
364 SkCodec::Result SkBmpStandardCodec::onStart(const SkImageInfo& dstInfo,
365 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
366 // Create the color table if necessary and prepare the stream for decode
367 // Note that if it is non-NULL, inputColorCount will be modified
368 if (!this->createColorTable(dstInfo.alphaType(), inputColorCount)) {
369 SkCodecPrintf("Error: could not create color table.\n");
370 return SkCodec::kInvalidInput;
371 }
372
373 // Copy the color table to the client if necessary
374 copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount) ;
375
376 // Initialize a swizzler if necessary
377 if (!this->initializeSwizzler(dstInfo, options)) {
378 SkCodecPrintf("Error: cannot initialize swizzler.\n");
379 return SkCodec::kInvalidConversion;
380 }
381
382 return SkCodec::kSuccess;
383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698