| 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 543 |
| 544 int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const { | 544 int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const { |
| 545 if (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) { | 545 if (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) { |
| 546 return y; | 546 return y; |
| 547 } | 547 } |
| 548 SkASSERT(SkCodec::kBottomUp_SkScanlineOrder == fRowOrder); | 548 SkASSERT(SkCodec::kBottomUp_SkScanlineOrder == fRowOrder); |
| 549 return height - y - 1; | 549 return height - y - 1; |
| 550 } | 550 } |
| 551 | 551 |
| 552 /* | 552 /* |
| 553 * Get the destination row to start filling from | |
| 554 * Used to fill the remainder of the image on incomplete input for bmps | |
| 555 * This is tricky since bmps may be kTopDown or kBottomUp. For kTopDown, | |
| 556 * we start filling from where we left off, but for kBottomUp we start | |
| 557 * filling at the top of the image. | |
| 558 */ | |
| 559 void* SkBmpCodec::getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const
{ | |
| 560 return (SkCodec::kTopDown_SkScanlineOrder == fRowOrder) ? | |
| 561 SkTAddOffset<void*>(dst, y * dstRowBytes) : dst; | |
| 562 } | |
| 563 | |
| 564 /* | |
| 565 * Compute the number of colors in the color table | 553 * Compute the number of colors in the color table |
| 566 */ | 554 */ |
| 567 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { | 555 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { |
| 568 // Zero is a default for maxColors | 556 // Zero is a default for maxColors |
| 569 // Also set numColors to maxColors when it is too large | 557 // Also set numColors to maxColors when it is too large |
| 570 uint32_t maxColors = 1 << fBitsPerPixel; | 558 uint32_t maxColors = 1 << fBitsPerPixel; |
| 571 if (numColors == 0 || numColors >= maxColors) { | 559 if (numColors == 0 || numColors >= maxColors) { |
| 572 return maxColors; | 560 return maxColors; |
| 573 } | 561 } |
| 574 return numColors; | 562 return numColors; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 586 } | 574 } |
| 587 } | 575 } |
| 588 if (!conversion_possible(dstInfo, this->getInfo())) { | 576 if (!conversion_possible(dstInfo, this->getInfo())) { |
| 589 SkCodecPrintf("Error: cannot convert input type to output type.\n"); | 577 SkCodecPrintf("Error: cannot convert input type to output type.\n"); |
| 590 return kInvalidConversion; | 578 return kInvalidConversion; |
| 591 } | 579 } |
| 592 | 580 |
| 593 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); | 581 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); |
| 594 } | 582 } |
| 595 | 583 |
| 596 SkCodec::Result SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes
) { | 584 uint32_t SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { |
| 597 // Create a new image info representing the portion of the image to decode | 585 // Create a new image info representing the portion of the image to decode |
| 598 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count)
; | 586 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count)
; |
| 599 | 587 |
| 600 // Decode the requested rows | 588 // Decode the requested rows |
| 601 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); | 589 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); |
| 602 } | 590 } |
| 603 | |
| 604 int SkBmpCodec::onNextScanline() const { | |
| 605 return this->getDstRow(this->INHERITED::onNextScanline(), this->dstInfo().he
ight()); | |
| 606 } | |
| OLD | NEW |