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

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

Issue 2045293002: Add support for multiple frames in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix a test - we now draw transparent background for missing color table Created 4 years, 1 month 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/SkAndroidCodec.cpp ('k') | src/codec/SkCodecAnimation.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 "SkCodec.h" 9 #include "SkCodec.h"
10 #include "SkCodecPriv.h" 10 #include "SkCodecPriv.h"
(...skipping 17 matching lines...) Expand all
28 SkCodec* (*NewFromStream)(SkStream*); 28 SkCodec* (*NewFromStream)(SkStream*);
29 }; 29 };
30 30
31 static const DecoderProc gDecoderProcs[] = { 31 static const DecoderProc gDecoderProcs[] = {
32 #ifdef SK_HAS_JPEG_LIBRARY 32 #ifdef SK_HAS_JPEG_LIBRARY
33 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream }, 33 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream },
34 #endif 34 #endif
35 #ifdef SK_HAS_WEBP_LIBRARY 35 #ifdef SK_HAS_WEBP_LIBRARY
36 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream }, 36 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream },
37 #endif 37 #endif
38 #ifdef SK_HAS_GIF_LIBRARY
39 { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, 38 { SkGifCodec::IsGif, SkGifCodec::NewFromStream },
40 #endif
41 #ifdef SK_HAS_PNG_LIBRARY 39 #ifdef SK_HAS_PNG_LIBRARY
42 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, 40 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream },
43 #endif 41 #endif
44 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, 42 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream },
45 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream } 43 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream }
46 }; 44 };
47 45
48 size_t SkCodec::MinBufferedBytesNeeded() { 46 size_t SkCodec::MinBufferedBytesNeeded() {
49 return WEBP_VP8_HEADER_SIZE; 47 return WEBP_VP8_HEADER_SIZE;
50 } 48 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 , fNeedsRewind(false) 134 , fNeedsRewind(false)
137 , fOrigin(origin) 135 , fOrigin(origin)
138 , fDstInfo() 136 , fDstInfo()
139 , fOptions() 137 , fOptions()
140 , fCurrScanline(-1) 138 , fCurrScanline(-1)
141 {} 139 {}
142 140
143 SkCodec::~SkCodec() {} 141 SkCodec::~SkCodec() {}
144 142
145 bool SkCodec::rewindIfNeeded() { 143 bool SkCodec::rewindIfNeeded() {
146 if (!fStream) {
147 // Some codecs do not have a stream. They may hold onto their own data or another codec.
148 // They must handle rewinding themselves.
149 return true;
150 }
151
152 // Store the value of fNeedsRewind so we can update it. Next read will 144 // Store the value of fNeedsRewind so we can update it. Next read will
153 // require a rewind. 145 // require a rewind.
154 const bool needsRewind = fNeedsRewind; 146 const bool needsRewind = fNeedsRewind;
155 fNeedsRewind = true; 147 fNeedsRewind = true;
156 if (!needsRewind) { 148 if (!needsRewind) {
157 return true; 149 return true;
158 } 150 }
159 151
160 // startScanlineDecode will need to be called before decoding scanlines. 152 // startScanlineDecode will need to be called before decoding scanlines.
161 fCurrScanline = -1; 153 fCurrScanline = -1;
162 // startIncrementalDecode will need to be called before incrementalDecode. 154 // startIncrementalDecode will need to be called before incrementalDecode.
163 fStartedIncrementalDecode = false; 155 fStartedIncrementalDecode = false;
164 156
165 if (!fStream->rewind()) { 157 // Some codecs do not have a stream. They may hold onto their own data or a nother codec.
158 // They must handle rewinding themselves.
159 if (fStream && !fStream->rewind()) {
166 return false; 160 return false;
167 } 161 }
168 162
169 return this->onRewind(); 163 return this->onRewind();
170 } 164 }
171 165
172 #define CHECK_COLOR_TABLE \ 166 #define CHECK_COLOR_TABLE \
173 if (kIndex_8_SkColorType == info.colorType()) { \ 167 if (kIndex_8_SkColorType == info.colorType()) { \
174 if (nullptr == ctable || nullptr == ctableCount) { \ 168 if (nullptr == ctable || nullptr == ctableCount) { \
175 return SkCodec::kInvalidParameters; \ 169 return SkCodec::kInvalidParameters; \
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes); 460 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes);
467 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ; 461 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ;
468 break; 462 break;
469 } 463 }
470 case kBottomUp_SkScanlineOrder: { 464 case kBottomUp_SkScanlineOrder: {
471 fillDst = dst; 465 fillDst = dst;
472 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining); 466 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining);
473 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ; 467 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ;
474 break; 468 break;
475 } 469 }
476 case kOutOfOrder_SkScanlineOrder: {
477 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested);
478 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1);
479 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
480 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes);
481 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler);
482 }
483 break;
484 }
485 } 470 }
486 } 471 }
487 472
488 bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo) { 473 bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo) {
489 fColorXform = nullptr; 474 fColorXform = nullptr;
490 if (needs_color_xform(dstInfo, fSrcInfo)) { 475 if (needs_color_xform(dstInfo, fSrcInfo)) {
491 fColorXform = SkColorSpaceXform::New(fSrcInfo.colorSpace(), dstInfo.colo rSpace()); 476 fColorXform = SkColorSpaceXform::New(fSrcInfo.colorSpace(), dstInfo.colo rSpace());
492 if (!fColorXform) { 477 if (!fColorXform) {
493 return false; 478 return false;
494 } 479 }
495 } 480 }
496 481
497 return true; 482 return true;
498 } 483 }
OLDNEW
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/codec/SkCodecAnimation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698