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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 return NULL; | 526 return NULL; |
527 } | 527 } |
528 | 528 |
529 SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream, | 529 SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream, |
530 uint16_t bitsPerPixel, RowOrder rowOrder) | 530 uint16_t bitsPerPixel, RowOrder rowOrder) |
531 : INHERITED(info, stream) | 531 : INHERITED(info, stream) |
532 , fBitsPerPixel(bitsPerPixel) | 532 , fBitsPerPixel(bitsPerPixel) |
533 , fRowOrder(rowOrder) | 533 , fRowOrder(rowOrder) |
534 {} | 534 {} |
535 | 535 |
536 /* | 536 bool SkBmpCodec::onRewind() { |
537 * Rewinds the image stream if necessary | 537 return SkBmpCodec::ReadHeader(this->stream(), this->inIco(), NULL); |
538 */ | |
539 bool SkBmpCodec::handleRewind(bool inIco) { | |
540 SkCodec::RewindState rewindState = this->rewindIfNeeded(); | |
541 if (rewindState == kCouldNotRewind_RewindState) { | |
542 return false; | |
543 } else if (rewindState == kRewound_RewindState) { | |
544 if (!SkBmpCodec::ReadHeader(this->stream(), inIco, NULL)) { | |
545 return false; | |
546 } | |
547 } | |
548 return true; | |
549 } | 538 } |
550 | 539 |
551 /* | 540 /* |
552 * Get the destination row to start filling from | 541 * Get the destination row to start filling from |
553 * Used to fill the remainder of the image on incomplete input for bmps | 542 * Used to fill the remainder of the image on incomplete input for bmps |
554 * This is tricky since bmps may be kTopDown or kBottomUp. For kTopDown, | 543 * This is tricky since bmps may be kTopDown or kBottomUp. For kTopDown, |
555 * we start filling from where we left off, but for kBottomUp we start | 544 * we start filling from where we left off, but for kBottomUp we start |
556 * filling at the top of the image. | 545 * filling at the top of the image. |
557 */ | 546 */ |
558 void* SkBmpCodec::getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const
{ | 547 void* SkBmpCodec::getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const
{ |
559 return (kTopDown_RowOrder == fRowOrder) ? SkTAddOffset<void*>(dst, y * dstRo
wBytes) : dst; | 548 return (kTopDown_RowOrder == fRowOrder) ? SkTAddOffset<void*>(dst, y * dstRo
wBytes) : dst; |
560 } | 549 } |
561 | 550 |
562 /* | 551 /* |
563 * Compute the number of colors in the color table | 552 * Compute the number of colors in the color table |
564 */ | 553 */ |
565 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { | 554 uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { |
566 // Zero is a default for maxColors | 555 // Zero is a default for maxColors |
567 // Also set fNumColors to maxColors when it is too large | 556 // Also set fNumColors to maxColors when it is too large |
568 uint32_t maxColors = 1 << fBitsPerPixel; | 557 uint32_t maxColors = 1 << fBitsPerPixel; |
569 if (numColors == 0 || numColors >= maxColors) { | 558 if (numColors == 0 || numColors >= maxColors) { |
570 return maxColors; | 559 return maxColors; |
571 } | 560 } |
572 return numColors; | 561 return numColors; |
573 } | 562 } |
OLD | NEW |