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

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: Scanline decoding for bmp without reordering 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 SkBmpRLEScanlineDecoder::SkBmpRLEScanlineDecoder(SkBmpRLECodec* codec)
481 : INHERITED(codec->getInfo())
482 , fCodec(codec)
483 {}
484
485 SkCodec::Result SkBmpRLEScanlineDecoder::onStart(const SkImageInfo& dstInfo,
486 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
487 if (!fCodec->rewindIfNeeded()) {
488 return SkCodec::kCouldNotRewind;
489 }
490 if (options.fSubset) {
491 // Subsets are not supported.
492 return SkCodec::kUnimplemented;
493 }
494 if (dstInfo.dimensions() != fCodec->getInfo().dimensions()) {
495 SkCodecPrintf("Error: scaling not supported.\n");
496 return SkCodec::kInvalidScale;
497 }
498 if (!conversion_possible(dstInfo, fCodec->getInfo())) {
499 SkCodecPrintf("Error: cannot convert input type to output type.\n");
500 return SkCodec::kInvalidConversion;
501 }
502
503 // Create the color table if necessary and prepare the stream for decode
504 // Note that if it is non-NULL, inputColorCount will be modified
505 if (!fCodec->createColorTable(inputColorCount)) {
506 SkCodecPrintf("Error: could not create color table.\n");
507 return SkCodec::kInvalidInput;
508 }
509
510 // Copy the color table to the client if necessary
511 copy_color_table(dstInfo, fCodec->fColorTable, inputColorPtr, inputColorCoun t);
512
513 // Initialize a swizzler if necessary
514 if (!fCodec->initializeStreamBuffer()) {
515 SkCodecPrintf("Error: cannot initialize swizzler.\n");
516 return SkCodec::kInvalidConversion;
517 }
518
519 fDstInfo = dstInfo;
520 fOpts = options;
521
522 return SkCodec::kSuccess;
523 }
524
525 SkCodec::Result SkBmpRLEScanlineDecoder::onGetScanlines(void* dst,
526 int count, size_t rowBytes) {
527 // Create a new image info representing the portion of the image to decode
528 SkImageInfo rowInfo = fDstInfo.makeWH(dstInfo().width(), count);
529
530 // Decode the requested rows
531 SkCodec::Result r = fCodec->decode(rowInfo, dst, rowBytes, fOpts);
532 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698