blob: 3c485c8beb9575c9d594b50a35e9a114f844e63c [file] [log] [blame]
scroggof24f2242015-03-03 08:59:20 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
msarettb46e5e22015-07-30 11:36:40 -07008#include "SkBmpCodec.h"
scroggof24f2242015-03-03 08:59:20 -08009#include "SkCodec.h"
msarett8c8f22a2015-04-01 06:58:48 -070010#include "SkCodecPriv.h"
msarettad8bcfe2016-03-07 07:09:03 -080011#include "SkColorSpace.h"
msarett1a464672016-01-07 13:17:19 -080012#include "SkData.h"
13#include "SkGifCodec.h"
14#include "SkIcoCodec.h"
msarette16b04a2015-04-15 07:32:19 -070015#include "SkJpegCodec.h"
msarettad3a5c62016-05-06 07:21:26 -070016#ifdef SK_HAS_PNG_LIBRARY
msarettbe1d5552016-01-21 09:05:23 -080017#include "SkPngCodec.h"
yujieqin916de9f2016-01-25 08:26:16 -080018#endif
msarett39b2d5a2016-02-17 08:26:31 -080019#include "SkRawCodec.h"
scroggof24f2242015-03-03 08:59:20 -080020#include "SkStream.h"
msarett1a464672016-01-07 13:17:19 -080021#include "SkWbmpCodec.h"
scroggo6f5e6192015-06-18 12:53:43 -070022#include "SkWebpCodec.h"
scroggof24f2242015-03-03 08:59:20 -080023
msarett74114382015-03-16 11:55:18 -070024struct DecoderProc {
scroggodb30be22015-12-08 18:54:13 -080025 bool (*IsFormat)(const void*, size_t);
msarett74114382015-03-16 11:55:18 -070026 SkCodec* (*NewFromStream)(SkStream*);
27};
28
29static const DecoderProc gDecoderProcs[] = {
msarettad3a5c62016-05-06 07:21:26 -070030#ifdef SK_HAS_JPEG_LIBRARY
msarette16b04a2015-04-15 07:32:19 -070031 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream },
msarett39b2d5a2016-02-17 08:26:31 -080032#endif
msarettad3a5c62016-05-06 07:21:26 -070033#ifdef SK_HAS_WEBP_LIBRARY
scroggo6f5e6192015-06-18 12:53:43 -070034 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream },
msarett39b2d5a2016-02-17 08:26:31 -080035#endif
msarettad3a5c62016-05-06 07:21:26 -070036#ifdef SK_HAS_GIF_LIBRARY
msarett8c8f22a2015-04-01 06:58:48 -070037 { SkGifCodec::IsGif, SkGifCodec::NewFromStream },
msarett39b2d5a2016-02-17 08:26:31 -080038#endif
msarettad3a5c62016-05-06 07:21:26 -070039#ifdef SK_HAS_PNG_LIBRARY
msarett9bde9182015-03-25 05:27:48 -070040 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream },
msarett39b2d5a2016-02-17 08:26:31 -080041#endif
halcanarya096d7a2015-03-27 12:16:53 -070042 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream },
43 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream }
msarett74114382015-03-16 11:55:18 -070044};
45
scroggodb30be22015-12-08 18:54:13 -080046size_t SkCodec::MinBufferedBytesNeeded() {
47 return WEBP_VP8_HEADER_SIZE;
48}
49
scroggocf98fa92015-11-23 08:14:40 -080050SkCodec* SkCodec::NewFromStream(SkStream* stream,
51 SkPngChunkReader* chunkReader) {
scroggof24f2242015-03-03 08:59:20 -080052 if (!stream) {
halcanary96fcdcc2015-08-27 07:41:13 -070053 return nullptr;
scroggof24f2242015-03-03 08:59:20 -080054 }
scroggo0a7e69c2015-04-03 07:22:22 -070055
56 SkAutoTDelete<SkStream> streamDeleter(stream);
scroggodb30be22015-12-08 18:54:13 -080057
58 // 14 is enough to read all of the supported types.
59 const size_t bytesToRead = 14;
60 SkASSERT(bytesToRead <= MinBufferedBytesNeeded());
61
62 char buffer[bytesToRead];
63 size_t bytesRead = stream->peek(buffer, bytesToRead);
64
65 // It is also possible to have a complete image less than bytesToRead bytes
66 // (e.g. a 1 x 1 wbmp), meaning peek() would return less than bytesToRead.
67 // Assume that if bytesRead < bytesToRead, but > 0, the stream is shorter
68 // than bytesToRead, so pass that directly to the decoder.
69 // It also is possible the stream uses too small a buffer for peeking, but
70 // we trust the caller to use a large enough buffer.
71
72 if (0 == bytesRead) {
scroggo3ab9f2e2016-01-06 09:53:34 -080073 // TODO: After implementing peek in CreateJavaOutputStreamAdaptor.cpp, this
74 // printf could be useful to notice failures.
75 // SkCodecPrintf("Encoded image data failed to peek!\n");
76
scroggodb30be22015-12-08 18:54:13 -080077 // It is possible the stream does not support peeking, but does support
78 // rewinding.
79 // Attempt to read() and pass the actual amount read to the decoder.
80 bytesRead = stream->read(buffer, bytesToRead);
81 if (!stream->rewind()) {
scroggo3ab9f2e2016-01-06 09:53:34 -080082 SkCodecPrintf("Encoded image data could not peek or rewind to determine format!\n");
scroggodb30be22015-12-08 18:54:13 -080083 return nullptr;
84 }
85 }
86
scroggocf98fa92015-11-23 08:14:40 -080087 // PNG is special, since we want to be able to supply an SkPngChunkReader.
88 // But this code follows the same pattern as the loop.
msarettad3a5c62016-05-06 07:21:26 -070089#ifdef SK_HAS_PNG_LIBRARY
scroggodb30be22015-12-08 18:54:13 -080090 if (SkPngCodec::IsPng(buffer, bytesRead)) {
mtklein18300a32016-03-16 13:53:35 -070091 return SkPngCodec::NewFromStream(streamDeleter.release(), chunkReader);
msarett39b2d5a2016-02-17 08:26:31 -080092 } else
93#endif
94 {
scroggocf98fa92015-11-23 08:14:40 -080095 for (DecoderProc proc : gDecoderProcs) {
scroggodb30be22015-12-08 18:54:13 -080096 if (proc.IsFormat(buffer, bytesRead)) {
mtklein18300a32016-03-16 13:53:35 -070097 return proc.NewFromStream(streamDeleter.release());
scroggocf98fa92015-11-23 08:14:40 -080098 }
msarett74114382015-03-16 11:55:18 -070099 }
yujieqin916de9f2016-01-25 08:26:16 -0800100
101#ifdef SK_CODEC_DECODES_RAW
102 // Try to treat the input as RAW if all the other checks failed.
mtklein18300a32016-03-16 13:53:35 -0700103 return SkRawCodec::NewFromStream(streamDeleter.release());
yujieqin916de9f2016-01-25 08:26:16 -0800104#endif
scroggof24f2242015-03-03 08:59:20 -0800105 }
msarett8c8f22a2015-04-01 06:58:48 -0700106
msarettf44631b2016-01-13 10:54:20 -0800107 return nullptr;
scroggof24f2242015-03-03 08:59:20 -0800108}
109
scroggocf98fa92015-11-23 08:14:40 -0800110SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) {
scroggof24f2242015-03-03 08:59:20 -0800111 if (!data) {
halcanary96fcdcc2015-08-27 07:41:13 -0700112 return nullptr;
scroggof24f2242015-03-03 08:59:20 -0800113 }
scroggocf98fa92015-11-23 08:14:40 -0800114 return NewFromStream(new SkMemoryStream(data), reader);
scroggof24f2242015-03-03 08:59:20 -0800115}
116
msarettc30c4182016-04-20 11:53:35 -0700117SkCodec::SkCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
118 sk_sp<SkColorSpace> colorSpace, Origin origin)
119 : fEncodedInfo(info)
msarett23c51102016-05-27 07:39:02 -0700120 , fSrcInfo(info.makeImageInfo(width, height, colorSpace))
scroggof24f2242015-03-03 08:59:20 -0800121 , fStream(stream)
122 , fNeedsRewind(false)
msarett23c51102016-05-27 07:39:02 -0700123 , fColorSpace(std::move(colorSpace))
msarett0e6274f2016-03-21 08:04:40 -0700124 , fOrigin(origin)
scroggo46c57472015-09-30 08:57:13 -0700125 , fDstInfo()
126 , fOptions()
127 , fCurrScanline(-1)
scroggof24f2242015-03-03 08:59:20 -0800128{}
129
scroggo9b2cdbf42015-07-10 12:07:02 -0700130SkCodec::~SkCodec() {}
scroggoeb602a52015-07-09 08:16:03 -0700131
scroggob427db12015-08-12 07:24:13 -0700132bool SkCodec::rewindIfNeeded() {
scroggo3a7701c2015-09-30 09:15:14 -0700133 if (!fStream) {
134 // Some codecs do not have a stream, but they hold others that do. They
135 // must handle rewinding themselves.
136 return true;
137 }
138
scroggof24f2242015-03-03 08:59:20 -0800139 // Store the value of fNeedsRewind so we can update it. Next read will
140 // require a rewind.
halcanarya096d7a2015-03-27 12:16:53 -0700141 const bool needsRewind = fNeedsRewind;
scroggof24f2242015-03-03 08:59:20 -0800142 fNeedsRewind = true;
halcanarya096d7a2015-03-27 12:16:53 -0700143 if (!needsRewind) {
scroggob427db12015-08-12 07:24:13 -0700144 return true;
halcanarya096d7a2015-03-27 12:16:53 -0700145 }
scroggob427db12015-08-12 07:24:13 -0700146
scroggo46c57472015-09-30 08:57:13 -0700147 // startScanlineDecode will need to be called before decoding scanlines.
148 fCurrScanline = -1;
149
scroggob427db12015-08-12 07:24:13 -0700150 if (!fStream->rewind()) {
151 return false;
152 }
153
154 return this->onRewind();
scroggof24f2242015-03-03 08:59:20 -0800155}
scroggo05245902015-03-25 11:11:52 -0700156
scroggo6fb23912016-06-02 14:16:43 -0700157#define CHECK_COLOR_TABLE \
158 if (kIndex_8_SkColorType == info.colorType()) { \
159 if (nullptr == ctable || nullptr == ctableCount) { \
160 return SkCodec::kInvalidParameters; \
161 } \
162 } else { \
163 if (ctableCount) { \
164 *ctableCount = 0; \
165 } \
166 ctableCount = nullptr; \
167 ctable = nullptr; \
168 }
169
170
scroggoeb602a52015-07-09 08:16:03 -0700171SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
172 const Options* options, SkPMColor ctable[], int* ctableCount) {
173 if (kUnknown_SkColorType == info.colorType()) {
174 return kInvalidConversion;
175 }
halcanary96fcdcc2015-08-27 07:41:13 -0700176 if (nullptr == pixels) {
scroggoeb602a52015-07-09 08:16:03 -0700177 return kInvalidParameters;
178 }
179 if (rowBytes < info.minRowBytes()) {
180 return kInvalidParameters;
181 }
182
scroggo6fb23912016-06-02 14:16:43 -0700183 CHECK_COLOR_TABLE;
scroggoeb602a52015-07-09 08:16:03 -0700184
scroggo3a7701c2015-09-30 09:15:14 -0700185 if (!this->rewindIfNeeded()) {
186 return kCouldNotRewind;
187 }
188
scroggoeb602a52015-07-09 08:16:03 -0700189 // Default options.
190 Options optsStorage;
halcanary96fcdcc2015-08-27 07:41:13 -0700191 if (nullptr == options) {
scroggoeb602a52015-07-09 08:16:03 -0700192 options = &optsStorage;
scroggoe7fc14b2015-10-02 13:14:46 -0700193 } else if (options->fSubset) {
194 SkIRect subset(*options->fSubset);
195 if (!this->onGetValidSubset(&subset) || subset != *options->fSubset) {
196 // FIXME: How to differentiate between not supporting subset at all
197 // and not supporting this particular subset?
198 return kUnimplemented;
199 }
scroggoeb602a52015-07-09 08:16:03 -0700200 }
scroggoe7fc14b2015-10-02 13:14:46 -0700201
202 // FIXME: Support subsets somehow? Note that this works for SkWebpCodec
203 // because it supports arbitrary scaling/subset combinations.
204 if (!this->dimensionsSupported(info.dimensions())) {
205 return kInvalidScale;
206 }
207
msarette6dd0042015-10-09 11:07:34 -0700208 // On an incomplete decode, the subclass will specify the number of scanlines that it decoded
209 // successfully.
210 int rowsDecoded = 0;
211 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount,
212 &rowsDecoded);
scroggoeb602a52015-07-09 08:16:03 -0700213
214 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
215 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
216 }
msarette6dd0042015-10-09 11:07:34 -0700217
218 // A return value of kIncompleteInput indicates a truncated image stream.
219 // In this case, we will fill any uninitialized memory with a default value.
220 // Some subclasses will take care of filling any uninitialized memory on
221 // their own. They indicate that all of the memory has been filled by
222 // setting rowsDecoded equal to the height.
223 if (kIncompleteInput == result && rowsDecoded != info.height()) {
224 this->fillIncompleteImage(info, pixels, rowBytes, options->fZeroInitialized, info.height(),
225 rowsDecoded);
226 }
227
scroggoeb602a52015-07-09 08:16:03 -0700228 return result;
229}
230
231SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
halcanary96fcdcc2015-08-27 07:41:13 -0700232 return this->getPixels(info, pixels, rowBytes, nullptr, nullptr, nullptr);
scroggoeb602a52015-07-09 08:16:03 -0700233}
scroggo46c57472015-09-30 08:57:13 -0700234
scroggo6fb23912016-06-02 14:16:43 -0700235SkCodec::Result SkCodec::startIncrementalDecode(const SkImageInfo& info, void* pixels,
236 size_t rowBytes, const SkCodec::Options* options, SkPMColor* ctable, int* ctableCount) {
237 fStartedIncrementalDecode = false;
238
239 if (kUnknown_SkColorType == info.colorType()) {
240 return kInvalidConversion;
241 }
242 if (nullptr == pixels) {
243 return kInvalidParameters;
244 }
245
246 // Ensure that valid color ptrs are passed in for kIndex8 color type
247 CHECK_COLOR_TABLE;
248
249 // FIXME: If the rows come after the rows of a previous incremental decode,
250 // we might be able to skip the rewind, but only the implementation knows
251 // that. (e.g. PNG will always need to rewind, since we called longjmp, but
252 // a bottom-up BMP could skip rewinding if the new rows are above the old
253 // rows.)
254 if (!this->rewindIfNeeded()) {
255 return kCouldNotRewind;
256 }
257
258 // Set options.
259 Options optsStorage;
260 if (nullptr == options) {
261 options = &optsStorage;
262 } else if (options->fSubset) {
263 SkIRect size = SkIRect::MakeSize(info.dimensions());
264 if (!size.contains(*options->fSubset)) {
265 return kInvalidParameters;
266 }
267
268 const int top = options->fSubset->top();
269 const int bottom = options->fSubset->bottom();
270 if (top < 0 || top >= info.height() || top >= bottom || bottom > info.height()) {
271 return kInvalidParameters;
272 }
273 }
274
275 if (!this->dimensionsSupported(info.dimensions())) {
276 return kInvalidScale;
277 }
278
279 fDstInfo = info;
280 fOptions = *options;
281
282 const Result result = this->onStartIncrementalDecode(info, pixels, rowBytes,
283 fOptions, ctable, ctableCount);
284 if (kSuccess == result) {
285 fStartedIncrementalDecode = true;
286 } else if (kUnimplemented == result) {
287 // FIXME: This is temporarily necessary, until we transition SkCodec
288 // implementations from scanline decoding to incremental decoding.
289 // SkAndroidCodec will first attempt to use incremental decoding, but
290 // will fall back to scanline decoding if incremental returns
291 // kUnimplemented. rewindIfNeeded(), above, set fNeedsRewind to true
292 // (after potentially rewinding), but we do not want the next call to
293 // startScanlineDecode() to do a rewind.
294 fNeedsRewind = false;
295 }
296 return result;
297}
298
299
300SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& info,
scroggo46c57472015-09-30 08:57:13 -0700301 const SkCodec::Options* options, SkPMColor ctable[], int* ctableCount) {
302 // Reset fCurrScanline in case of failure.
303 fCurrScanline = -1;
304 // Ensure that valid color ptrs are passed in for kIndex8 color type
scroggo6fb23912016-06-02 14:16:43 -0700305 CHECK_COLOR_TABLE;
scroggo46c57472015-09-30 08:57:13 -0700306
scroggo3a7701c2015-09-30 09:15:14 -0700307 if (!this->rewindIfNeeded()) {
308 return kCouldNotRewind;
309 }
310
scroggo46c57472015-09-30 08:57:13 -0700311 // Set options.
312 Options optsStorage;
313 if (nullptr == options) {
314 options = &optsStorage;
scroggoe7fc14b2015-10-02 13:14:46 -0700315 } else if (options->fSubset) {
scroggo6fb23912016-06-02 14:16:43 -0700316 SkIRect size = SkIRect::MakeSize(info.dimensions());
msarettfdb47572015-10-13 12:50:14 -0700317 if (!size.contains(*options->fSubset)) {
318 return kInvalidInput;
319 }
320
321 // We only support subsetting in the x-dimension for scanline decoder.
322 // Subsetting in the y-dimension can be accomplished using skipScanlines().
scroggo6fb23912016-06-02 14:16:43 -0700323 if (options->fSubset->top() != 0 || options->fSubset->height() != info.height()) {
msarettfdb47572015-10-13 12:50:14 -0700324 return kInvalidInput;
scroggoe7fc14b2015-10-02 13:14:46 -0700325 }
326 }
327
328 // FIXME: Support subsets somehow?
scroggo6fb23912016-06-02 14:16:43 -0700329 if (!this->dimensionsSupported(info.dimensions())) {
scroggoe7fc14b2015-10-02 13:14:46 -0700330 return kInvalidScale;
scroggo46c57472015-09-30 08:57:13 -0700331 }
332
scroggo6fb23912016-06-02 14:16:43 -0700333 const Result result = this->onStartScanlineDecode(info, *options, ctable, ctableCount);
scroggo46c57472015-09-30 08:57:13 -0700334 if (result != SkCodec::kSuccess) {
335 return result;
336 }
337
338 fCurrScanline = 0;
scroggo6fb23912016-06-02 14:16:43 -0700339 fDstInfo = info;
scroggo46c57472015-09-30 08:57:13 -0700340 fOptions = *options;
341 return kSuccess;
342}
343
scroggo6fb23912016-06-02 14:16:43 -0700344#undef CHECK_COLOR_TABLE
345
346SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& info) {
347 return this->startScanlineDecode(info, nullptr, nullptr, nullptr);
scroggo46c57472015-09-30 08:57:13 -0700348}
349
msarette6dd0042015-10-09 11:07:34 -0700350int SkCodec::getScanlines(void* dst, int countLines, size_t rowBytes) {
scroggo46c57472015-09-30 08:57:13 -0700351 if (fCurrScanline < 0) {
msarette6dd0042015-10-09 11:07:34 -0700352 return 0;
scroggo46c57472015-09-30 08:57:13 -0700353 }
354
355 SkASSERT(!fDstInfo.isEmpty());
scroggoe7fc14b2015-10-02 13:14:46 -0700356 if (countLines <= 0 || fCurrScanline + countLines > fDstInfo.height()) {
msarette6dd0042015-10-09 11:07:34 -0700357 return 0;
scroggo46c57472015-09-30 08:57:13 -0700358 }
359
msarette6dd0042015-10-09 11:07:34 -0700360 const int linesDecoded = this->onGetScanlines(dst, countLines, rowBytes);
361 if (linesDecoded < countLines) {
362 this->fillIncompleteImage(this->dstInfo(), dst, rowBytes, this->options().fZeroInitialized,
363 countLines, linesDecoded);
364 }
365 fCurrScanline += countLines;
366 return linesDecoded;
367}
368
369bool SkCodec::skipScanlines(int countLines) {
370 if (fCurrScanline < 0) {
371 return false;
372 }
373
374 SkASSERT(!fDstInfo.isEmpty());
375 if (countLines < 0 || fCurrScanline + countLines > fDstInfo.height()) {
376 // Arguably, we could just skip the scanlines which are remaining,
377 // and return true. We choose to return false so the client
378 // can catch their bug.
379 return false;
380 }
381
382 bool result = this->onSkipScanlines(countLines);
scroggo46c57472015-09-30 08:57:13 -0700383 fCurrScanline += countLines;
384 return result;
385}
386
msarette6dd0042015-10-09 11:07:34 -0700387int SkCodec::outputScanline(int inputScanline) const {
388 SkASSERT(0 <= inputScanline && inputScanline < this->getInfo().height());
389 return this->onOutputScanline(inputScanline);
390}
scroggo46c57472015-09-30 08:57:13 -0700391
msarette6dd0042015-10-09 11:07:34 -0700392int SkCodec::onOutputScanline(int inputScanline) const {
393 switch (this->getScanlineOrder()) {
394 case kTopDown_SkScanlineOrder:
msarette6dd0042015-10-09 11:07:34 -0700395 return inputScanline;
396 case kBottomUp_SkScanlineOrder:
397 return this->getInfo().height() - inputScanline - 1;
398 default:
399 // This case indicates an interlaced gif and is implemented by SkGifCodec.
400 SkASSERT(false);
401 return 0;
scroggo46c57472015-09-30 08:57:13 -0700402 }
msarette6dd0042015-10-09 11:07:34 -0700403}
scroggo46c57472015-09-30 08:57:13 -0700404
msarette6dd0042015-10-09 11:07:34 -0700405static void fill_proc(const SkImageInfo& info, void* dst, size_t rowBytes,
406 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit, SkSampler* sampler) {
407 if (sampler) {
408 sampler->fill(info, dst, rowBytes, colorOrIndex, zeroInit);
409 } else {
410 SkSampler::Fill(info, dst, rowBytes, colorOrIndex, zeroInit);
411 }
412}
413
414void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t rowBytes,
415 ZeroInitialized zeroInit, int linesRequested, int linesDecoded) {
416
417 void* fillDst;
scroggoc5560be2016-02-03 09:42:42 -0800418 const uint32_t fillValue = this->getFillValue(info.colorType());
msarette6dd0042015-10-09 11:07:34 -0700419 const int linesRemaining = linesRequested - linesDecoded;
420 SkSampler* sampler = this->getSampler(false);
421
msarett91c22b22016-02-22 12:27:46 -0800422 int fillWidth = info.width();
423 if (fOptions.fSubset) {
424 fillWidth = fOptions.fSubset->width();
425 }
426
msarette6dd0042015-10-09 11:07:34 -0700427 switch (this->getScanlineOrder()) {
scroggo6fb23912016-06-02 14:16:43 -0700428 case kTopDown_SkScanlineOrder: {
msarett91c22b22016-02-22 12:27:46 -0800429 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining);
msarette6dd0042015-10-09 11:07:34 -0700430 fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes);
431 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
432 break;
433 }
434 case kBottomUp_SkScanlineOrder: {
435 fillDst = dst;
msarett91c22b22016-02-22 12:27:46 -0800436 const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining);
msarette6dd0042015-10-09 11:07:34 -0700437 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
438 break;
439 }
440 case kOutOfOrder_SkScanlineOrder: {
441 SkASSERT(1 == linesRequested || this->getInfo().height() == linesRequested);
msarett91c22b22016-02-22 12:27:46 -0800442 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1);
msarette6dd0042015-10-09 11:07:34 -0700443 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
444 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * rowBytes);
445 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
446 }
447 break;
448 }
449 }
scroggo46c57472015-09-30 08:57:13 -0700450}