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

Side by Side Diff: src/codec/SkBmpCodec.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use aligned memory in swizzler test Created 5 years, 2 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
« no previous file with comments | « src/codec/SkBmpCodec.h ('k') | src/codec/SkBmpMaskCodec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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;
575 } 563 }
576 564
577 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, 565 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
578 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) { 566 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
579 if (options.fSubset) { 567 if (options.fSubset) {
580 // Subsets are not supported. 568 // Subsets are not supported.
581 return kUnimplemented; 569 return kUnimplemented;
582 } 570 }
583 if (!conversion_possible(dstInfo, this->getInfo())) { 571 if (!conversion_possible(dstInfo, this->getInfo())) {
584 SkCodecPrintf("Error: cannot convert input type to output type.\n"); 572 SkCodecPrintf("Error: cannot convert input type to output type.\n");
585 return kInvalidConversion; 573 return kInvalidConversion;
586 } 574 }
587 575
588 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); 576 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
589 } 577 }
590 578
591 SkCodec::Result SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes ) { 579 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
592 // Create a new image info representing the portion of the image to decode 580 // Create a new image info representing the portion of the image to decode
593 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ; 581 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ;
594 582
595 // Decode the requested rows 583 // Decode the requested rows
596 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); 584 return this->decodeRows(rowInfo, dst, rowBytes, this->options());
597 } 585 }
598
599 int SkBmpCodec::onNextScanline() const {
600 return this->getDstRow(this->INHERITED::onNextScanline(), this->dstInfo().he ight());
601 }
OLDNEW
« no previous file with comments | « src/codec/SkBmpCodec.h ('k') | src/codec/SkBmpMaskCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698