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

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

Issue 980903002: Option for SkCodec to treat dst as all zeroes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkBmpCodec to use new ZeroInitialized API. Created 5 years, 9 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/SkCodec_libbmp.h ('k') | src/codec/SkCodec_libpng.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 "SkCodec_libbmp.h" 8 #include "SkCodec_libbmp.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 , fRemainingBytes(remainingBytes) 495 , fRemainingBytes(remainingBytes)
496 {} 496 {}
497 497
498 /* 498 /*
499 * 499 *
500 * Initiates the bitmap decode 500 * Initiates the bitmap decode
501 * 501 *
502 */ 502 */
503 SkCodec::Result SkBmpCodec::onGetPixels(const SkImageInfo& dstInfo, 503 SkCodec::Result SkBmpCodec::onGetPixels(const SkImageInfo& dstInfo,
504 void* dst, size_t dstRowBytes, 504 void* dst, size_t dstRowBytes,
505 const Options&,
505 SkPMColor*, int*) { 506 SkPMColor*, int*) {
506 if (!this->rewindIfNeeded()) { 507 if (!this->rewindIfNeeded()) {
507 return kCouldNotRewind; 508 return kCouldNotRewind;
508 } 509 }
509 if (dstInfo.dimensions() != this->getOriginalInfo().dimensions()) { 510 if (dstInfo.dimensions() != this->getOriginalInfo().dimensions()) {
510 SkDebugf("Error: scaling not supported.\n"); 511 SkDebugf("Error: scaling not supported.\n");
511 return kInvalidScale; 512 return kInvalidScale;
512 } 513 }
513 if (!conversion_possible(dstInfo, this->getOriginalInfo())) { 514 if (!conversion_possible(dstInfo, this->getOriginalInfo())) {
514 SkDebugf("Error: cannot convert input type to output type.\n"); 515 SkDebugf("Error: cannot convert input type to output type.\n");
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 config = SkSwizzler::kBGRA; 838 config = SkSwizzler::kBGRA;
838 } 839 }
839 break; 840 break;
840 default: 841 default:
841 SkASSERT(false); 842 SkASSERT(false);
842 return kInvalidInput; 843 return kInvalidInput;
843 } 844 }
844 845
845 // Create swizzler 846 // Create swizzler
846 SkSwizzler* swizzler = SkSwizzler::CreateSwizzler(config, fColorTable.get(), 847 SkSwizzler* swizzler = SkSwizzler::CreateSwizzler(config, fColorTable.get(),
847 dstInfo, dst, dstRowBytes, false); 848 dstInfo, dst, dstRowBytes, SkImageGenerator::kNo_ZeroInitialized);
848 849
849 // Allocate space for a row buffer and a source for the swizzler 850 // Allocate space for a row buffer and a source for the swizzler
850 SkAutoTDeleteArray<uint8_t> srcBuffer(SkNEW_ARRAY(uint8_t, rowBytes)); 851 SkAutoTDeleteArray<uint8_t> srcBuffer(SkNEW_ARRAY(uint8_t, rowBytes));
851 852
852 // Iterate over rows of the image 853 // Iterate over rows of the image
853 // FIXME: bool transparent = true; 854 // FIXME: bool transparent = true;
854 for (int y = 0; y < height; y++) { 855 for (int y = 0; y < height; y++) {
855 // Read a row of the input 856 // Read a row of the input
856 if (stream()->read(srcBuffer.get(), rowBytes) != rowBytes) { 857 if (stream()->read(srcBuffer.get(), rowBytes) != rowBytes) {
857 SkDebugf("Warning: incomplete input stream.\n"); 858 SkDebugf("Warning: incomplete input stream.\n");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 895 }
895 dstRow = SkTAddOffset<SkPMColor>(dstRow, dstRowBytes); 896 dstRow = SkTAddOffset<SkPMColor>(dstRow, dstRowBytes);
896 } 897 }
897 } 898 }
898 } 899 }
899 */ 900 */
900 901
901 // Finished decoding the entire image 902 // Finished decoding the entire image
902 return kSuccess; 903 return kSuccess;
903 } 904 }
OLDNEW
« no previous file with comments | « src/codec/SkCodec_libbmp.h ('k') | src/codec/SkCodec_libpng.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698