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

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: Disable DNG if Raw is disabled 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
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 16 matching lines...) Expand all
27 SkCodec* (*NewFromStream)(SkStream*); 27 SkCodec* (*NewFromStream)(SkStream*);
28 }; 28 };
29 29
30 static const DecoderProc gDecoderProcs[] = { 30 static const DecoderProc gDecoderProcs[] = {
31 #ifdef SK_HAS_JPEG_LIBRARY 31 #ifdef SK_HAS_JPEG_LIBRARY
32 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream }, 32 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream },
33 #endif 33 #endif
34 #ifdef SK_HAS_WEBP_LIBRARY 34 #ifdef SK_HAS_WEBP_LIBRARY
35 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream }, 35 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream },
36 #endif 36 #endif
37 #ifdef SK_HAS_GIF_LIBRARY
38 { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, 37 { SkGifCodec::IsGif, SkGifCodec::NewFromStream },
39 #endif
40 #ifdef SK_HAS_PNG_LIBRARY 38 #ifdef SK_HAS_PNG_LIBRARY
41 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, 39 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream },
42 #endif 40 #endif
43 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, 41 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream },
44 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream } 42 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream }
45 }; 43 };
46 44
47 size_t SkCodec::MinBufferedBytesNeeded() { 45 size_t SkCodec::MinBufferedBytesNeeded() {
48 return WEBP_VP8_HEADER_SIZE; 46 return WEBP_VP8_HEADER_SIZE;
49 } 47 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 , fNeedsRewind(false) 133 , fNeedsRewind(false)
136 , fOrigin(origin) 134 , fOrigin(origin)
137 , fDstInfo() 135 , fDstInfo()
138 , fOptions() 136 , fOptions()
139 , fCurrScanline(-1) 137 , fCurrScanline(-1)
140 {} 138 {}
141 139
142 SkCodec::~SkCodec() {} 140 SkCodec::~SkCodec() {}
143 141
144 bool SkCodec::rewindIfNeeded() { 142 bool SkCodec::rewindIfNeeded() {
145 if (!fStream) {
146 // Some codecs do not have a stream. They may hold onto their own data or another codec.
147 // They must handle rewinding themselves.
148 return true;
149 }
150
151 // Store the value of fNeedsRewind so we can update it. Next read will 143 // Store the value of fNeedsRewind so we can update it. Next read will
152 // require a rewind. 144 // require a rewind.
153 const bool needsRewind = fNeedsRewind; 145 const bool needsRewind = fNeedsRewind;
154 fNeedsRewind = true; 146 fNeedsRewind = true;
155 if (!needsRewind) { 147 if (!needsRewind) {
156 return true; 148 return true;
157 } 149 }
158 150
159 // startScanlineDecode will need to be called before decoding scanlines. 151 // startScanlineDecode will need to be called before decoding scanlines.
160 fCurrScanline = -1; 152 fCurrScanline = -1;
161 // startIncrementalDecode will need to be called before incrementalDecode. 153 // startIncrementalDecode will need to be called before incrementalDecode.
162 fStartedIncrementalDecode = false; 154 fStartedIncrementalDecode = false;
163 155
164 if (!fStream->rewind()) { 156 // Some codecs do not have a stream. They may hold onto their own data or a nother codec.
157 // They must handle rewinding themselves.
158 if (fStream && !fStream->rewind()) {
165 return false; 159 return false;
166 } 160 }
167 161
168 return this->onRewind(); 162 return this->onRewind();
169 } 163 }
170 164
171 #define CHECK_COLOR_TABLE \ 165 #define CHECK_COLOR_TABLE \
172 if (kIndex_8_SkColorType == info.colorType()) { \ 166 if (kIndex_8_SkColorType == info.colorType()) { \
173 if (nullptr == ctable || nullptr == ctableCount) { \ 167 if (nullptr == ctable || nullptr == ctableCount) { \
174 return SkCodec::kInvalidParameters; \ 168 return SkCodec::kInvalidParameters; \
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes); 459 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes);
466 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ; 460 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ;
467 break; 461 break;
468 } 462 }
469 case kBottomUp_SkScanlineOrder: { 463 case kBottomUp_SkScanlineOrder: {
470 fillDst = dst; 464 fillDst = dst;
471 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining); 465 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining);
472 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ; 466 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler) ;
473 break; 467 break;
474 } 468 }
475 case kOutOfOrder_SkScanlineOrder: {
476 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested);
477 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1);
478 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
479 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes);
480 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler);
481 }
482 break;
483 }
484 } 469 }
485 } 470 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698