OLD | NEW |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 , fNeedsRewind(false) | 135 , fNeedsRewind(false) |
136 , fOrigin(origin) | 136 , fOrigin(origin) |
137 , fDstInfo() | 137 , fDstInfo() |
138 , fOptions() | 138 , fOptions() |
139 , fCurrScanline(-1) | 139 , fCurrScanline(-1) |
140 {} | 140 {} |
141 | 141 |
142 SkCodec::~SkCodec() {} | 142 SkCodec::~SkCodec() {} |
143 | 143 |
144 bool SkCodec::rewindIfNeeded() { | 144 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 | 145 // Store the value of fNeedsRewind so we can update it. Next read will |
152 // require a rewind. | 146 // require a rewind. |
153 const bool needsRewind = fNeedsRewind; | 147 const bool needsRewind = fNeedsRewind; |
154 fNeedsRewind = true; | 148 fNeedsRewind = true; |
155 if (!needsRewind) { | 149 if (!needsRewind) { |
156 return true; | 150 return true; |
157 } | 151 } |
158 | 152 |
159 // startScanlineDecode will need to be called before decoding scanlines. | 153 // startScanlineDecode will need to be called before decoding scanlines. |
160 fCurrScanline = -1; | 154 fCurrScanline = -1; |
161 // startIncrementalDecode will need to be called before incrementalDecode. | 155 // startIncrementalDecode will need to be called before incrementalDecode. |
162 fStartedIncrementalDecode = false; | 156 fStartedIncrementalDecode = false; |
163 | 157 |
164 if (!fStream->rewind()) { | 158 // Some codecs do not have a stream. They may hold onto their own data or a
nother codec. |
| 159 // They must handle rewinding themselves. |
| 160 if (fStream && !fStream->rewind()) { |
165 return false; | 161 return false; |
166 } | 162 } |
167 | 163 |
168 return this->onRewind(); | 164 return this->onRewind(); |
169 } | 165 } |
170 | 166 |
171 #define CHECK_COLOR_TABLE \ | 167 #define CHECK_COLOR_TABLE \ |
172 if (kIndex_8_SkColorType == info.colorType()) { \ | 168 if (kIndex_8_SkColorType == info.colorType()) { \ |
173 if (nullptr == ctable || nullptr == ctableCount) { \ | 169 if (nullptr == ctable || nullptr == ctableCount) { \ |
174 return SkCodec::kInvalidParameters; \ | 170 return SkCodec::kInvalidParameters; \ |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes); | 461 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes); |
466 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler)
; | 462 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler)
; |
467 break; | 463 break; |
468 } | 464 } |
469 case kBottomUp_SkScanlineOrder: { | 465 case kBottomUp_SkScanlineOrder: { |
470 fillDst = dst; | 466 fillDst = dst; |
471 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining); | 467 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining); |
472 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler)
; | 468 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler)
; |
473 break; | 469 break; |
474 } | 470 } |
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 } | 471 } |
485 } | 472 } |
OLD | NEW |