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

Side by Side Diff: src/codec/SkBmpRLECodec.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 "SkBmpRLECodec.h" 8 #include "SkBmpRLECodec.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 SkBmpRLECodec::SkBmpRLECodec(const SkImageInfo& info, SkStream* stream, 47 SkBmpRLECodec::SkBmpRLECodec(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, size_t RLEBytes) 51 SkBmpCodec::RowOrder rowOrder, size_t RLEBytes)
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 , fStreamBuffer(SkNEW_ARRAY(uint8_t, RLEBytes)) 57 , fStreamBuffer(SkNEW_ARRAY(uint8_t, RLEBytes))
57 , fRLEBytes(RLEBytes) 58 , fRLEBytes(RLEBytes)
58 , fCurrRLEByte(0) 59 , fCurrRLEByte(0)
59 {} 60 {}
60 61
61 /* 62 /*
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // Set the indicated number of pixels 469 // Set the indicated number of pixels
469 for (int which = 0; x < endX; x++) { 470 for (int which = 0; x < endX; x++) {
470 setPixel(dst, dstRowBytes, dstInfo, x, y, 471 setPixel(dst, dstRowBytes, dstInfo, x, y,
471 indices[which]); 472 indices[which]);
472 which = !which; 473 which = !which;
473 } 474 }
474 } 475 }
475 } 476 }
476 } 477 }
477 } 478 }
479
480 SkCodec::Result SkBmpRLECodec::onStart(const SkImageInfo& dstInfo,
481 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
482 // Create the color table if necessary and prepare the stream for decode
483 // Note that if it is non-NULL, inputColorCount will be modified
484 if (!this->createColorTable(inputColorCount)) {
485 SkCodecPrintf("Error: could not create color table.\n");
486 return SkCodec::kInvalidInput;
487 }
488
489 // Copy the color table to the client if necessary
490 copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount) ;
491
492 // Initialize a buffer for encoded RLE data
493 if (!this->initializeStreamBuffer()) {
494 SkCodecPrintf("Error: cannot initialize swizzler.\n");
495 return SkCodec::kInvalidConversion;
496 }
497
498 return SkCodec::kSuccess;
499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698