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 "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
9 #include "SkBmpMaskCodec.h" | 9 #include "SkBmpMaskCodec.h" |
10 #include "SkBmpRLECodec.h" | 10 #include "SkBmpRLECodec.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 return codec; | 528 return codec; |
529 } | 529 } |
530 return nullptr; | 530 return nullptr; |
531 } | 531 } |
532 | 532 |
533 SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream, | 533 SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream, |
534 uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder) | 534 uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder) |
535 : INHERITED(info, stream) | 535 : INHERITED(info, stream) |
536 , fBitsPerPixel(bitsPerPixel) | 536 , fBitsPerPixel(bitsPerPixel) |
537 , fRowOrder(rowOrder) | 537 , fRowOrder(rowOrder) |
| 538 , fSubsetLeft(0) |
| 539 , fSubsetWidth(this->getInfo().width()) |
538 {} | 540 {} |
539 | 541 |
540 bool SkBmpCodec::onRewind() { | 542 bool SkBmpCodec::onRewind() { |
541 return SkBmpCodec::ReadHeader(this->stream(), this->inIco(), nullptr); | 543 if (!SkBmpCodec::ReadHeader(this->stream(), this->inIco(), nullptr)) { |
| 544 return false; |
| 545 } |
| 546 |
| 547 fSubsetLeft = 0; |
| 548 fSubsetWidth = this->getInfo().width(); |
| 549 return true; |
542 } | 550 } |
543 | 551 |
544 int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const { | 552 int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const { |
545 if (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) { | 553 if (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) { |
546 return y; | 554 return y; |
547 } | 555 } |
548 SkASSERT(SkCodec::kBottomUp_SkScanlineOrder == fRowOrder); | 556 SkASSERT(SkCodec::kBottomUp_SkScanlineOrder == fRowOrder); |
549 return height - y - 1; | 557 return height - y - 1; |
550 } | 558 } |
551 | 559 |
552 /* | 560 /* |
553 * Compute the number of colors in the color table | 561 * Compute the number of colors in the color table |
554 */ | 562 */ |
555 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { | 563 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { |
556 // Zero is a default for maxColors | 564 // Zero is a default for maxColors |
557 // Also set numColors to maxColors when it is too large | 565 // Also set numColors to maxColors when it is too large |
558 uint32_t maxColors = 1 << fBitsPerPixel; | 566 uint32_t maxColors = 1 << fBitsPerPixel; |
559 if (numColors == 0 || numColors >= maxColors) { | 567 if (numColors == 0 || numColors >= maxColors) { |
560 return maxColors; | 568 return maxColors; |
561 } | 569 } |
562 return numColors; | 570 return numColors; |
563 } | 571 } |
564 | 572 |
565 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, | 573 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, |
566 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount) { | 574 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount, |
| 575 int subsetLeft, int subsetWidth) { |
567 if (options.fSubset) { | 576 if (options.fSubset) { |
568 // Subsets are not supported. | 577 // Subsets are not supported. |
569 return kUnimplemented; | 578 return kUnimplemented; |
570 } | 579 } |
571 if (!conversion_possible(dstInfo, this->getInfo())) { | 580 if (!conversion_possible(dstInfo, this->getInfo())) { |
572 SkCodecPrintf("Error: cannot convert input type to output type.\n"); | 581 SkCodecPrintf("Error: cannot convert input type to output type.\n"); |
573 return kInvalidConversion; | 582 return kInvalidConversion; |
574 } | 583 } |
575 | 584 |
576 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); | 585 this->fSubsetLeft = subsetLeft; |
| 586 this->fSubsetWidth = subsetWidth; |
| 587 return this->prepareToDecode(dstInfo, options, inputColorPtr, inputColorCoun
t); |
577 } | 588 } |
578 | 589 |
579 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { | 590 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
580 // Create a new image info representing the portion of the image to decode | 591 // Create a new image info representing the portion of the image to decode |
581 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count)
; | 592 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count)
; |
582 | 593 |
583 // Decode the requested rows | 594 // Decode the requested rows |
584 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); | 595 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); |
585 } | 596 } |
OLD | NEW |