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

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

Issue 2424353003: Consider the start_coord in interlaced PNG (Closed)
Patch Set: Created 4 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 | « no previous file | no next file » | 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 719 }
720 return SkCodec::kIncompleteInput; 720 return SkCodec::kIncompleteInput;
721 } 721 }
722 722
723 const int sampleY = this->swizzler() ? this->swizzler()->sampleY() : 1; 723 const int sampleY = this->swizzler() ? this->swizzler()->sampleY() : 1;
724 const int rowsNeeded = get_scaled_dimension(fLastRow - fFirstRow + 1, sa mpleY); 724 const int rowsNeeded = get_scaled_dimension(fLastRow - fFirstRow + 1, sa mpleY);
725 int rowsWrittenToOutput = 0; 725 int rowsWrittenToOutput = 0;
726 726
727 // FIXME: For resuming interlace, we may swizzle a row that hasn't chang ed. But it 727 // FIXME: For resuming interlace, we may swizzle a row that hasn't chang ed. But it
728 // may be too tricky/expensive to handle that correctly. 728 // may be too tricky/expensive to handle that correctly.
729 png_bytep srcRow = fInterlaceBuffer.get(); 729
730 // Offset srcRow by get_start_coord rows. We do not need to account for fFirstRow,
731 // since the first row in fInterlaceBuffer corresponds to fFirstRow.
732 png_bytep srcRow = SkTAddOffset<png_byte>(fInterlaceBuffer.get(),
733 fPng_rowbytes * get_start_coor d(sampleY));
730 void* dst = fDst; 734 void* dst = fDst;
731 for (int rowNum = fFirstRow + get_start_coord(sampleY); rowsWrittenToOut put < rowsNeeded; 735 for (; rowsWrittenToOutput < rowsNeeded; rowsWrittenToOutput++) {
scroggo_chromium 2016/10/18 14:32:19 Notice that I used get_start_coord to compute rowN
732 rowNum += sampleY) {
733 this->applyXformRow(dst, srcRow); 736 this->applyXformRow(dst, srcRow);
734 dst = SkTAddOffset<void>(dst, fRowBytes); 737 dst = SkTAddOffset<void>(dst, fRowBytes);
735 srcRow = SkTAddOffset<png_byte>(srcRow, fPng_rowbytes * sampleY); 738 srcRow = SkTAddOffset<png_byte>(srcRow, fPng_rowbytes * sampleY);
736 rowsWrittenToOutput++;
737 } 739 }
738 740
739 if (fInterlacedComplete) { 741 if (fInterlacedComplete) {
740 return SkCodec::kSuccess; 742 return SkCodec::kSuccess;
741 } 743 }
742 744
743 if (rowsDecoded) { 745 if (rowsDecoded) {
744 *rowsDecoded = rowsWrittenToOutput; 746 *rowsDecoded = rowsWrittenToOutput;
745 } 747 }
746 return SkCodec::kIncompleteInput; 748 return SkCodec::kIncompleteInput;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 SkCodec* outCodec = nullptr; 1258 SkCodec* outCodec = nullptr;
1257 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt r)) { 1259 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt r)) {
1258 // Codec has taken ownership of the stream. 1260 // Codec has taken ownership of the stream.
1259 SkASSERT(outCodec); 1261 SkASSERT(outCodec);
1260 streamDeleter.release(); 1262 streamDeleter.release();
1261 return outCodec; 1263 return outCodec;
1262 } 1264 }
1263 1265
1264 return nullptr; 1266 return nullptr;
1265 } 1267 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698