blob: 6ce7b99a7095de1bd5f59bf013787b6d3800f721 [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
8#ifndef SkCodec_DEFINED
9#define SkCodec_DEFINED
10
Ben Wagnerd5148e32018-07-16 17:44:06 -040011#include "../private/SkNoncopyable.h"
bungemanf3c15b72015-08-19 11:56:48 -070012#include "../private/SkTemplates.h"
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -050013#include "../private/SkEncodedInfo.h"
Leon Scroggins III33deb7e2017-06-07 12:31:51 -040014#include "SkCodecAnimation.h"
scroggoeb602a52015-07-09 08:16:03 -070015#include "SkColor.h"
Hal Canarydb683012016-11-23 08:55:18 -070016#include "SkEncodedImageFormat.h"
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -040017#include "SkEncodedOrigin.h"
scroggof24f2242015-03-03 08:59:20 -080018#include "SkImageInfo.h"
Mike Reed43798692017-10-17 18:04:32 +000019#include "SkPixmap.h"
scroggof24f2242015-03-03 08:59:20 -080020#include "SkSize.h"
scroggofffeede2015-03-18 10:50:37 -070021#include "SkStream.h"
scroggof24f2242015-03-03 08:59:20 -080022#include "SkTypes.h"
Jim Van Verthe24b5872018-10-29 16:26:02 -040023#include "SkYUVASizeInfo.h"
scroggof24f2242015-03-03 08:59:20 -080024
scroggo19b91532016-10-24 09:03:26 -070025#include <vector>
26
msarettad8bcfe2016-03-07 07:09:03 -080027class SkColorSpace;
scroggof24f2242015-03-03 08:59:20 -080028class SkData;
Leon Scroggins III1f6af6b2017-06-12 16:41:09 -040029class SkFrameHolder;
scroggocf98fa92015-11-23 08:14:40 -080030class SkPngChunkReader;
scroggoe7fc14b2015-10-02 13:14:46 -070031class SkSampler;
scroggof24f2242015-03-03 08:59:20 -080032
msarett9876ac52016-06-01 14:47:18 -070033namespace DM {
scroggo8e6c7ad2016-09-16 08:20:38 -070034class CodecSrc;
msarett9876ac52016-06-01 14:47:18 -070035class ColorCodecSrc;
36}
37
scroggof24f2242015-03-03 08:59:20 -080038/**
39 * Abstraction layer directly on top of an image codec.
40 */
Florin Malita78c212a2016-12-14 13:17:01 -050041class SK_API SkCodec : SkNoncopyable {
scroggof24f2242015-03-03 08:59:20 -080042public:
43 /**
scroggodb30be22015-12-08 18:54:13 -080044 * Minimum number of bytes that must be buffered in SkStream input.
45 *
46 * An SkStream passed to NewFromStream must be able to use this many
47 * bytes to determine the image type. Then the same SkStream must be
48 * passed to the correct decoder to read from the beginning.
49 *
50 * This can be accomplished by implementing peek() to support peeking
51 * this many bytes, or by implementing rewind() to be able to rewind()
52 * after reading this many bytes.
53 */
Leon Scroggins III04be2b52017-08-17 15:13:20 -040054 static constexpr size_t MinBufferedBytesNeeded() { return 32; }
scroggodb30be22015-12-08 18:54:13 -080055
56 /**
Leon Scroggins III588fb042017-07-14 16:32:31 -040057 * Error codes for various SkCodec methods.
58 */
59 enum Result {
60 /**
61 * General return value for success.
62 */
63 kSuccess,
64 /**
65 * The input is incomplete. A partial image was generated.
66 */
67 kIncompleteInput,
68 /**
69 * Like kIncompleteInput, except the input had an error.
70 *
71 * If returned from an incremental decode, decoding cannot continue,
72 * even with more data.
73 */
74 kErrorInInput,
75 /**
76 * The generator cannot convert to match the request, ignoring
77 * dimensions.
78 */
79 kInvalidConversion,
80 /**
81 * The generator cannot scale to requested size.
82 */
83 kInvalidScale,
84 /**
85 * Parameters (besides info) are invalid. e.g. NULL pixels, rowBytes
86 * too small, etc.
87 */
88 kInvalidParameters,
89 /**
90 * The input did not contain a valid image.
91 */
92 kInvalidInput,
93 /**
94 * Fulfilling this request requires rewinding the input, which is not
95 * supported for this input.
96 */
97 kCouldNotRewind,
98 /**
99 * An internal error, such as OOM.
100 */
101 kInternalError,
102 /**
103 * This method is not implemented by this codec.
104 * FIXME: Perhaps this should be kUnsupported?
105 */
106 kUnimplemented,
107 };
108
109 /**
Leon Scroggins IIIfe3da022018-01-16 11:56:54 -0500110 * Readable string representing the error code.
111 */
112 static const char* ResultToString(Result);
113
114 /**
scroggof24f2242015-03-03 08:59:20 -0800115 * If this stream represents an encoded image that we know how to decode,
116 * return an SkCodec that can decode it. Otherwise return NULL.
117 *
scroggodb30be22015-12-08 18:54:13 -0800118 * As stated above, this call must be able to peek or read
119 * MinBufferedBytesNeeded to determine the correct format, and then start
120 * reading from the beginning. First it will attempt to peek, and it
121 * assumes that if less than MinBufferedBytesNeeded bytes (but more than
122 * zero) are returned, this is because the stream is shorter than this,
123 * so falling back to reading would not provide more data. If peek()
124 * returns zero bytes, this call will instead attempt to read(). This
125 * will require that the stream can be rewind()ed.
126 *
Leon Scroggins III588fb042017-07-14 16:32:31 -0400127 * If Result is not NULL, it will be set to either kSuccess if an SkCodec
128 * is returned or a reason for the failure if NULL is returned.
129 *
scroggodb30be22015-12-08 18:54:13 -0800130 * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if
131 * the image is a png.
132 *
msarett7d5105c2015-12-02 07:02:41 -0800133 * If the SkPngChunkReader is not NULL then:
134 * If the image is not a PNG, the SkPngChunkReader will be ignored.
135 * If the image is a PNG, the SkPngChunkReader will be reffed.
136 * If the PNG has unknown chunks, the SkPngChunkReader will be used
137 * to handle these chunks. SkPngChunkReader will be called to read
138 * any unknown chunk at any point during the creation of the codec
139 * or the decode. Note that if SkPngChunkReader fails to read a
140 * chunk, this could result in a failure to create the codec or a
141 * failure to decode the image.
142 * If the PNG does not contain unknown chunks, the SkPngChunkReader
143 * will not be used or modified.
scroggocf98fa92015-11-23 08:14:40 -0800144 *
scroggof24f2242015-03-03 08:59:20 -0800145 * If NULL is returned, the stream is deleted immediately. Otherwise, the
146 * SkCodec takes ownership of it, and will delete it when done with it.
147 */
Mike Reedede7bac2017-07-23 15:30:02 -0400148 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result* = nullptr,
149 SkPngChunkReader* = nullptr);
scroggof24f2242015-03-03 08:59:20 -0800150
151 /**
152 * If this data represents an encoded image that we know how to decode,
153 * return an SkCodec that can decode it. Otherwise return NULL.
154 *
msarett7d5105c2015-12-02 07:02:41 -0800155 * If the SkPngChunkReader is not NULL then:
156 * If the image is not a PNG, the SkPngChunkReader will be ignored.
157 * If the image is a PNG, the SkPngChunkReader will be reffed.
158 * If the PNG has unknown chunks, the SkPngChunkReader will be used
159 * to handle these chunks. SkPngChunkReader will be called to read
160 * any unknown chunk at any point during the creation of the codec
161 * or the decode. Note that if SkPngChunkReader fails to read a
162 * chunk, this could result in a failure to create the codec or a
163 * failure to decode the image.
164 * If the PNG does not contain unknown chunks, the SkPngChunkReader
165 * will not be used or modified.
scroggof24f2242015-03-03 08:59:20 -0800166 */
Mike Reedede7bac2017-07-23 15:30:02 -0400167 static std::unique_ptr<SkCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
168
scroggoeb602a52015-07-09 08:16:03 -0700169 virtual ~SkCodec();
170
171 /**
Leon Scroggins III712476e2018-10-03 15:47:00 -0400172 * Return a reasonable SkImageInfo to decode into.
scroggoeb602a52015-07-09 08:16:03 -0700173 */
Leon Scroggins III712476e2018-10-03 15:47:00 -0400174 SkImageInfo getInfo() const { return fEncodedInfo.makeImageInfo(); }
175
176 SkISize dimensions() const { return {fEncodedInfo.width(), fEncodedInfo.height()}; }
177 SkIRect bounds() const {
178 return SkIRect::MakeWH(fEncodedInfo.width(), fEncodedInfo.height());
179 }
scroggoeb602a52015-07-09 08:16:03 -0700180
msarett0e6274f2016-03-21 08:04:40 -0700181 /**
182 * Returns the image orientation stored in the EXIF data.
183 * If there is no EXIF data, or if we cannot read the EXIF data, returns kTopLeft.
184 */
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400185 SkEncodedOrigin getOrigin() const { return fOrigin; }
msarett0e6274f2016-03-21 08:04:40 -0700186
msarett6a738212016-03-04 13:27:35 -0800187 /**
scroggof24f2242015-03-03 08:59:20 -0800188 * Return a size that approximately supports the desired scale factor.
189 * The codec may not be able to scale efficiently to the exact scale
190 * factor requested, so return a size that approximates that scale.
emmaleer8f4ba762015-08-14 07:44:46 -0700191 * The returned value is the codec's suggestion for the closest valid
192 * scale that it can natively support
scroggof24f2242015-03-03 08:59:20 -0800193 */
scroggofffeede2015-03-18 10:50:37 -0700194 SkISize getScaledDimensions(float desiredScale) const {
msarettb32758a2015-08-18 13:22:46 -0700195 // Negative and zero scales are errors.
196 SkASSERT(desiredScale > 0.0f);
197 if (desiredScale <= 0.0f) {
198 return SkISize::Make(0, 0);
199 }
200
201 // Upscaling is not supported. Return the original size if the client
202 // requests an upscale.
203 if (desiredScale >= 1.0f) {
Leon Scroggins III712476e2018-10-03 15:47:00 -0400204 return this->dimensions();
msarettb32758a2015-08-18 13:22:46 -0700205 }
scroggofffeede2015-03-18 10:50:37 -0700206 return this->onGetScaledDimensions(desiredScale);
207 }
scroggof24f2242015-03-03 08:59:20 -0800208
scroggo1dd3ea92015-03-20 11:55:55 -0700209 /**
scroggob636b452015-07-22 07:16:20 -0700210 * Return (via desiredSubset) a subset which can decoded from this codec,
211 * or false if this codec cannot decode subsets or anything similar to
212 * desiredSubset.
213 *
214 * @param desiredSubset In/out parameter. As input, a desired subset of
215 * the original bounds (as specified by getInfo). If true is returned,
216 * desiredSubset may have been modified to a subset which is
217 * supported. Although a particular change may have been made to
218 * desiredSubset to create something supported, it is possible other
219 * changes could result in a valid subset.
220 * If false is returned, desiredSubset's value is undefined.
221 * @return true if this codec supports decoding desiredSubset (as
222 * returned, potentially modified)
223 */
224 bool getValidSubset(SkIRect* desiredSubset) const {
225 return this->onGetValidSubset(desiredSubset);
226 }
227
228 /**
scroggo1dd3ea92015-03-20 11:55:55 -0700229 * Format of the encoded data.
230 */
Hal Canarydb683012016-11-23 08:55:18 -0700231 SkEncodedImageFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
scroggo1dd3ea92015-03-20 11:55:55 -0700232
scroggo05245902015-03-25 11:11:52 -0700233 /**
scroggoeb602a52015-07-09 08:16:03 -0700234 * Whether or not the memory passed to getPixels is zero initialized.
235 */
236 enum ZeroInitialized {
237 /**
238 * The memory passed to getPixels is zero initialized. The SkCodec
239 * may take advantage of this by skipping writing zeroes.
240 */
241 kYes_ZeroInitialized,
242 /**
243 * The memory passed to getPixels has not been initialized to zero,
244 * so the SkCodec must write all zeroes to memory.
245 *
246 * This is the default. It will be used if no Options struct is used.
247 */
248 kNo_ZeroInitialized,
249 };
250
251 /**
252 * Additional options to pass to getPixels.
253 */
254 struct Options {
255 Options()
scroggob636b452015-07-22 07:16:20 -0700256 : fZeroInitialized(kNo_ZeroInitialized)
scroggo19b91532016-10-24 09:03:26 -0700257 , fSubset(nullptr)
258 , fFrameIndex(0)
Nigel Tao66bc5242018-08-22 10:56:03 +1000259 , fPriorFrame(kNoFrame)
scroggob636b452015-07-22 07:16:20 -0700260 {}
scroggoeb602a52015-07-09 08:16:03 -0700261
Matt Sarettcf3f2342017-03-23 15:32:25 -0400262 ZeroInitialized fZeroInitialized;
scroggob636b452015-07-22 07:16:20 -0700263 /**
264 * If not NULL, represents a subset of the original image to decode.
scroggob636b452015-07-22 07:16:20 -0700265 * Must be within the bounds returned by getInfo().
Hal Canarydb683012016-11-23 08:55:18 -0700266 * If the EncodedFormat is SkEncodedImageFormat::kWEBP (the only one which
scroggob636b452015-07-22 07:16:20 -0700267 * currently supports subsets), the top and left values must be even.
msarettfdb47572015-10-13 12:50:14 -0700268 *
scroggo8e6c7ad2016-09-16 08:20:38 -0700269 * In getPixels and incremental decode, we will attempt to decode the
270 * exact rectangular subset specified by fSubset.
msarettfdb47572015-10-13 12:50:14 -0700271 *
272 * In a scanline decode, it does not make sense to specify a subset
273 * top or subset height, since the client already controls which rows
274 * to get and which rows to skip. During scanline decodes, we will
275 * require that the subset top be zero and the subset height be equal
276 * to the full height. We will, however, use the values of
277 * subset left and subset width to decode partial scanlines on calls
278 * to getScanlines().
scroggob636b452015-07-22 07:16:20 -0700279 */
Matt Sarettcf3f2342017-03-23 15:32:25 -0400280 const SkIRect* fSubset;
scroggo19b91532016-10-24 09:03:26 -0700281
282 /**
283 * The frame to decode.
284 *
285 * Only meaningful for multi-frame images.
286 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400287 int fFrameIndex;
scroggo19b91532016-10-24 09:03:26 -0700288
289 /**
Nigel Tao66bc5242018-08-22 10:56:03 +1000290 * If not kNoFrame, the dst already contains the prior frame at this index.
scroggo19b91532016-10-24 09:03:26 -0700291 *
292 * Only meaningful for multi-frame images.
293 *
294 * If fFrameIndex needs to be blended with a prior frame (as reported by
295 * getFrameInfo[fFrameIndex].fRequiredFrame), the client can set this to
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400296 * any non-kRestorePrevious frame in [fRequiredFrame, fFrameIndex) to
297 * indicate that that frame is already in the dst. Options.fZeroInitialized
298 * is ignored in this case.
scroggo19b91532016-10-24 09:03:26 -0700299 *
Nigel Tao66bc5242018-08-22 10:56:03 +1000300 * If set to kNoFrame, the codec will decode any necessary required frame(s) first.
scroggo19b91532016-10-24 09:03:26 -0700301 */
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400302 int fPriorFrame;
scroggoeb602a52015-07-09 08:16:03 -0700303 };
304
305 /**
306 * Decode into the given pixels, a block of memory of size at
307 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
308 * bytesPerPixel)
309 *
310 * Repeated calls to this function should give the same results,
311 * allowing the PixelRef to be immutable.
312 *
313 * @param info A description of the format (config, size)
314 * expected by the caller. This can simply be identical
315 * to the info returned by getInfo().
316 *
317 * This contract also allows the caller to specify
318 * different output-configs, which the implementation can
319 * decide to support or not.
320 *
321 * A size that does not match getInfo() implies a request
322 * to scale. If the generator cannot perform this scale,
323 * it will return kInvalidScale.
324 *
msarett50ce1f22016-07-29 06:23:33 -0700325 * If the info contains a non-null SkColorSpace, the codec
326 * will perform the appropriate color space transformation.
327 * If the caller passes in the same color space that was
328 * reported by the codec, the color space transformation is
329 * a no-op.
330 *
scroggo46c57472015-09-30 08:57:13 -0700331 * If a scanline decode is in progress, scanline mode will end, requiring the client to call
332 * startScanlineDecode() in order to return to decoding scanlines.
333 *
scroggoeb602a52015-07-09 08:16:03 -0700334 * @return Result kSuccess, or another value explaining the type of failure.
335 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000336 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*);
scroggoeb602a52015-07-09 08:16:03 -0700337
338 /**
Leon Scroggins571b30f2017-07-11 17:35:31 +0000339 * Simplified version of getPixels() that uses the default Options.
scroggoeb602a52015-07-09 08:16:03 -0700340 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000341 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
342 return this->getPixels(info, pixels, rowBytes, nullptr);
343 }
scroggoeb602a52015-07-09 08:16:03 -0700344
Mike Reed43798692017-10-17 18:04:32 +0000345 Result getPixels(const SkPixmap& pm, const Options* opts = nullptr) {
346 return this->getPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), opts);
347 }
348
msarettb714fb02016-01-22 14:46:42 -0800349 /**
350 * If decoding to YUV is supported, this returns true. Otherwise, this
351 * returns false and does not modify any of the parameters.
352 *
353 * @param sizeInfo Output parameter indicating the sizes and required
Jim Van Verth8f11e432018-10-18 14:36:59 -0400354 * allocation widths of the Y, U, V, and A planes. Given current codec
355 * limitations the size of the A plane will always be 0 and the Y, U, V
356 * channels will always be planar.
msarettb714fb02016-01-22 14:46:42 -0800357 * @param colorSpace Output parameter. If non-NULL this is set to kJPEG,
358 * otherwise this is ignored.
359 */
Jim Van Verthe24b5872018-10-29 16:26:02 -0400360 bool queryYUV8(SkYUVASizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
msarettb714fb02016-01-22 14:46:42 -0800361 if (nullptr == sizeInfo) {
362 return false;
363 }
364
Jim Van Verth8f11e432018-10-18 14:36:59 -0400365 bool result = this->onQueryYUV8(sizeInfo, colorSpace);
366 if (result) {
367 for (int i = 0; i <= 2; ++i) {
Jim Van Verth8f11e432018-10-18 14:36:59 -0400368 SkASSERT(sizeInfo->fSizes[i].fWidth > 0 && sizeInfo->fSizes[i].fHeight > 0 &&
369 sizeInfo->fWidthBytes[i] > 0);
370 }
Jim Van Verth8f11e432018-10-18 14:36:59 -0400371 SkASSERT(!sizeInfo->fSizes[3].fWidth &&
372 !sizeInfo->fSizes[3].fHeight &&
373 !sizeInfo->fWidthBytes[3]);
374 }
375 return result;
msarettb714fb02016-01-22 14:46:42 -0800376 }
377
378 /**
379 * Returns kSuccess, or another value explaining the type of failure.
380 * This always attempts to perform a full decode. If the client only
381 * wants size, it should call queryYUV8().
382 *
383 * @param sizeInfo Needs to exactly match the values returned by the
384 * query, except the WidthBytes may be larger than the
385 * recommendation (but not smaller).
386 * @param planes Memory for each of the Y, U, and V planes.
387 */
Jim Van Verthe24b5872018-10-29 16:26:02 -0400388 Result getYUV8Planes(const SkYUVASizeInfo& sizeInfo, void* planes[SkYUVASizeInfo::kMaxCount]) {
Jim Van Verth8f11e432018-10-18 14:36:59 -0400389 if (!planes || !planes[0] || !planes[1] || !planes[2]) {
msarettb714fb02016-01-22 14:46:42 -0800390 return kInvalidInput;
391 }
Jim Van Verth8f11e432018-10-18 14:36:59 -0400392 SkASSERT(!planes[3]); // TODO: is this a fair assumption?
msarettb714fb02016-01-22 14:46:42 -0800393
394 if (!this->rewindIfNeeded()) {
395 return kCouldNotRewind;
396 }
397
398 return this->onGetYUV8Planes(sizeInfo, planes);
399 }
400
scroggoeb602a52015-07-09 08:16:03 -0700401 /**
scroggo8e6c7ad2016-09-16 08:20:38 -0700402 * Prepare for an incremental decode with the specified options.
403 *
404 * This may require a rewind.
405 *
Leon Scroggins IIIcb6b8842018-12-04 13:55:13 -0500406 * If kIncompleteInput is returned, may be called again after more data has
407 * been provided to the source SkStream.
408 *
scroggo8e6c7ad2016-09-16 08:20:38 -0700409 * @param dstInfo Info of the destination. If the dimensions do not match
410 * those of getInfo, this implies a scale.
411 * @param dst Memory to write to. Needs to be large enough to hold the subset,
412 * if present, or the full image as described in dstInfo.
413 * @param options Contains decoding options, including if memory is zero
414 * initialized and whether to decode a subset.
scroggo8e6c7ad2016-09-16 08:20:38 -0700415 * @return Enum representing success or reason for failure.
416 */
417 Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000418 const Options*);
scroggo8e6c7ad2016-09-16 08:20:38 -0700419
420 Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes) {
Leon Scroggins571b30f2017-07-11 17:35:31 +0000421 return this->startIncrementalDecode(dstInfo, dst, rowBytes, nullptr);
scroggo8e6c7ad2016-09-16 08:20:38 -0700422 }
423
424 /**
425 * Start/continue the incremental decode.
426 *
Leon Scroggins IIIcb6b8842018-12-04 13:55:13 -0500427 * Not valid to call before a call to startIncrementalDecode() returns
428 * kSuccess.
scroggo8e6c7ad2016-09-16 08:20:38 -0700429 *
Leon Scroggins IIIcb6b8842018-12-04 13:55:13 -0500430 * If kIncompleteInput is returned, may be called again after more data has
431 * been provided to the source SkStream.
scroggo8e6c7ad2016-09-16 08:20:38 -0700432 *
433 * Unlike getPixels and getScanlines, this does not do any filling. This is
434 * left up to the caller, since they may be skipping lines or continuing the
435 * decode later. In the latter case, they may choose to initialize all lines
436 * first, or only initialize the remaining lines after the first call.
437 *
438 * @param rowsDecoded Optional output variable returning the total number of
439 * lines initialized. Only meaningful if this method returns kIncompleteInput.
440 * Otherwise the implementation may not set it.
441 * Note that some implementations may have initialized this many rows, but
442 * not necessarily finished those rows (e.g. interlaced PNG). This may be
443 * useful for determining what rows the client needs to initialize.
444 * @return kSuccess if all lines requested in startIncrementalDecode have
445 * been completely decoded. kIncompleteInput otherwise.
446 */
447 Result incrementalDecode(int* rowsDecoded = nullptr) {
448 if (!fStartedIncrementalDecode) {
449 return kInvalidParameters;
450 }
451 return this->onIncrementalDecode(rowsDecoded);
452 }
453
454 /**
scroggo46c57472015-09-30 08:57:13 -0700455 * The remaining functions revolve around decoding scanlines.
456 */
457
458 /**
459 * Prepare for a scanline decode with the specified options.
460 *
461 * After this call, this class will be ready to decode the first scanline.
462 *
463 * This must be called in order to call getScanlines or skipScanlines.
464 *
465 * This may require rewinding the stream.
466 *
467 * Not all SkCodecs support this.
468 *
469 * @param dstInfo Info of the destination. If the dimensions do not match
470 * those of getInfo, this implies a scale.
471 * @param options Contains decoding options, including if memory is zero
472 * initialized.
scroggo46c57472015-09-30 08:57:13 -0700473 * @return Enum representing success or reason for failure.
474 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000475 Result startScanlineDecode(const SkImageInfo& dstInfo, const Options* options);
scroggo46c57472015-09-30 08:57:13 -0700476
477 /**
Leon Scroggins571b30f2017-07-11 17:35:31 +0000478 * Simplified version of startScanlineDecode() that uses the default Options.
scroggo46c57472015-09-30 08:57:13 -0700479 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000480 Result startScanlineDecode(const SkImageInfo& dstInfo) {
481 return this->startScanlineDecode(dstInfo, nullptr);
482 }
scroggo46c57472015-09-30 08:57:13 -0700483
484 /**
485 * Write the next countLines scanlines into dst.
486 *
487 * Not valid to call before calling startScanlineDecode().
488 *
489 * @param dst Must be non-null, and large enough to hold countLines
490 * scanlines of size rowBytes.
491 * @param countLines Number of lines to write.
492 * @param rowBytes Number of bytes per row. Must be large enough to hold
493 * a scanline based on the SkImageInfo used to create this object.
msarette6dd0042015-10-09 11:07:34 -0700494 * @return the number of lines successfully decoded. If this value is
495 * less than countLines, this will fill the remaining lines with a
496 * default value.
scroggo46c57472015-09-30 08:57:13 -0700497 */
msarette6dd0042015-10-09 11:07:34 -0700498 int getScanlines(void* dst, int countLines, size_t rowBytes);
scroggo46c57472015-09-30 08:57:13 -0700499
500 /**
501 * Skip count scanlines.
502 *
503 * Not valid to call before calling startScanlineDecode().
504 *
505 * The default version just calls onGetScanlines and discards the dst.
506 * NOTE: If skipped lines are the only lines with alpha, this default
507 * will make reallyHasAlpha return true, when it could have returned
508 * false.
msarette6dd0042015-10-09 11:07:34 -0700509 *
510 * @return true if the scanlines were successfully skipped
511 * false on failure, possible reasons for failure include:
512 * An incomplete input image stream.
513 * Calling this function before calling startScanlineDecode().
514 * If countLines is less than zero or so large that it moves
515 * the current scanline past the end of the image.
scroggo46c57472015-09-30 08:57:13 -0700516 */
msarette6dd0042015-10-09 11:07:34 -0700517 bool skipScanlines(int countLines);
scroggo46c57472015-09-30 08:57:13 -0700518
519 /**
520 * The order in which rows are output from the scanline decoder is not the
521 * same for all variations of all image types. This explains the possible
522 * output row orderings.
523 */
524 enum SkScanlineOrder {
525 /*
526 * By far the most common, this indicates that the image can be decoded
527 * reliably using the scanline decoder, and that rows will be output in
528 * the logical order.
529 */
530 kTopDown_SkScanlineOrder,
531
532 /*
533 * This indicates that the scanline decoder reliably outputs rows, but
534 * they will be returned in reverse order. If the scanline format is
535 * kBottomUp, the nextScanline() API can be used to determine the actual
536 * y-coordinate of the next output row, but the client is not forced
537 * to take advantage of this, given that it's not too tough to keep
538 * track independently.
539 *
540 * For full image decodes, it is safe to get all of the scanlines at
541 * once, since the decoder will handle inverting the rows as it
542 * decodes.
543 *
544 * For subset decodes and sampling, it is simplest to get and skip
545 * scanlines one at a time, using the nextScanline() API. It is
546 * possible to ask for larger chunks at a time, but this should be used
547 * with caution. As with full image decodes, the decoder will handle
548 * inverting the requested rows, but rows will still be delivered
549 * starting from the bottom of the image.
550 *
551 * Upside down bmps are an example.
552 */
553 kBottomUp_SkScanlineOrder,
scroggo46c57472015-09-30 08:57:13 -0700554 };
555
556 /**
557 * An enum representing the order in which scanlines will be returned by
558 * the scanline decoder.
msarettbe8216a2015-12-04 08:00:50 -0800559 *
560 * This is undefined before startScanlineDecode() is called.
scroggo46c57472015-09-30 08:57:13 -0700561 */
562 SkScanlineOrder getScanlineOrder() const { return this->onGetScanlineOrder(); }
563
564 /**
565 * Returns the y-coordinate of the next row to be returned by the scanline
msarette6dd0042015-10-09 11:07:34 -0700566 * decoder.
567 *
568 * This will equal fCurrScanline, except in the case of strangely
scroggo19b91532016-10-24 09:03:26 -0700569 * encoded image types (bottom-up bmps).
scroggo46c57472015-09-30 08:57:13 -0700570 *
571 * Results are undefined when not in scanline decoding mode.
572 */
msarette6dd0042015-10-09 11:07:34 -0700573 int nextScanline() const { return this->outputScanline(fCurrScanline); }
574
575 /**
msarettcb0d5c92015-12-03 12:23:43 -0800576 * Returns the output y-coordinate of the row that corresponds to an input
577 * y-coordinate. The input y-coordinate represents where the scanline
578 * is located in the encoded data.
msarette6dd0042015-10-09 11:07:34 -0700579 *
580 * This will equal inputScanline, except in the case of strangely
581 * encoded image types (bottom-up bmps, interlaced gifs).
582 */
583 int outputScanline(int inputScanline) const;
scroggo46c57472015-09-30 08:57:13 -0700584
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400585 /**
586 * Return the number of frames in the image.
587 *
588 * May require reading through the stream.
589 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400590 int getFrameCount() {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400591 return this->onGetFrameCount();
592 }
593
Nigel Tao66bc5242018-08-22 10:56:03 +1000594 // Sentinel value used when a frame index implies "no frame":
595 // - FrameInfo::fRequiredFrame set to this value means the frame
596 // is independent.
597 // - Options::fPriorFrame set to this value means no (relevant) prior frame
598 // is residing in dst's memory.
599 static constexpr int kNoFrame = -1;
600
Mike Kleineb4d6412018-11-12 16:08:30 +0000601 // This transitional definition was added in August 2018, and will eventually be removed.
602#ifdef SK_LEGACY_SKCODEC_NONE_ENUM
603 static constexpr int kNone = kNoFrame;
604#endif
605
scroggo19b91532016-10-24 09:03:26 -0700606 /**
607 * Information about individual frames in a multi-framed image.
608 */
609 struct FrameInfo {
610 /**
611 * The frame that this frame needs to be blended with, or
Nigel Tao66bc5242018-08-22 10:56:03 +1000612 * kNoFrame if this frame is independent.
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400613 *
614 * Note that this is the *earliest* frame that can be used
615 * for blending. Any frame from [fRequiredFrame, i) can be
616 * used, unless its fDisposalMethod is kRestorePrevious.
scroggo19b91532016-10-24 09:03:26 -0700617 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400618 int fRequiredFrame;
scroggo19b91532016-10-24 09:03:26 -0700619
620 /**
621 * Number of milliseconds to show this frame.
622 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400623 int fDuration;
Leon Scroggins III3639faa2016-12-08 11:38:58 -0500624
625 /**
626 * Whether the end marker for this frame is contained in the stream.
627 *
628 * Note: this does not guarantee that an attempt to decode will be complete.
629 * There could be an error in the stream.
630 */
631 bool fFullyReceived;
Leon Scroggins IIIa4db9be2017-04-11 10:32:02 -0400632
633 /**
634 * This is conservative; it will still return non-opaque if e.g. a
635 * color index-based frame has a color with alpha but does not use it.
636 */
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500637 SkAlphaType fAlphaType;
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400638
639 /**
640 * How this frame should be modified before decoding the next one.
641 */
642 SkCodecAnimation::DisposalMethod fDisposalMethod;
scroggo19b91532016-10-24 09:03:26 -0700643 };
644
645 /**
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400646 * Return info about a single frame.
647 *
648 * Only supported by multi-frame images. Does not read through the stream,
649 * so it should be called after getFrameCount() to parse any frames that
650 * have not already been parsed.
651 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400652 bool getFrameInfo(int index, FrameInfo* info) const {
Leon Scroggins III557fbbe2017-05-23 09:37:21 -0400653 if (index < 0) {
654 return false;
655 }
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400656 return this->onGetFrameInfo(index, info);
657 }
658
659 /**
660 * Return info about all the frames in the image.
scroggo19b91532016-10-24 09:03:26 -0700661 *
scroggoe71b1a12016-11-01 08:28:28 -0700662 * May require reading through the stream to determine info about the
663 * frames (including the count).
scroggo19b91532016-10-24 09:03:26 -0700664 *
665 * As such, future decoding calls may require a rewind.
666 *
Nigel Tao96597c22018-08-22 10:36:12 +1000667 * For still (non-animated) image codecs, this will return an empty vector.
scroggo19b91532016-10-24 09:03:26 -0700668 */
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400669 std::vector<FrameInfo> getFrameInfo();
scroggo19b91532016-10-24 09:03:26 -0700670
scroggoe71b1a12016-11-01 08:28:28 -0700671 static constexpr int kRepetitionCountInfinite = -1;
672
673 /**
Nigel Tao96597c22018-08-22 10:36:12 +1000674 * Return the number of times to repeat, if this image is animated. This number does not
675 * include the first play through of each frame. For example, a repetition count of 4 means
676 * that each frame is played 5 times and then the animation stops.
677 *
678 * It can return kRepetitionCountInfinite, a negative number, meaning that the animation
679 * should loop forever.
scroggoe71b1a12016-11-01 08:28:28 -0700680 *
681 * May require reading the stream to find the repetition count.
682 *
683 * As such, future decoding calls may require a rewind.
684 *
Nigel Tao96597c22018-08-22 10:36:12 +1000685 * For still (non-animated) image codecs, this will return 0.
scroggoe71b1a12016-11-01 08:28:28 -0700686 */
687 int getRepetitionCount() {
688 return this->onGetRepetitionCount();
689 }
690
scroggof24f2242015-03-03 08:59:20 -0800691protected:
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500692 const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
693
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400694 using XformFormat = skcms_PixelFormat;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400695
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400696 SkCodec(SkEncodedInfo&&,
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400697 XformFormat srcFormat,
Mike Reedede7bac2017-07-23 15:30:02 -0400698 std::unique_ptr<SkStream>,
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400699 SkEncodedOrigin = kTopLeft_SkEncodedOrigin);
msarett549ca322016-08-17 08:54:08 -0700700
msarettb714fb02016-01-22 14:46:42 -0800701 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
scroggof24f2242015-03-03 08:59:20 -0800702 // By default, scaling is not supported.
Leon Scroggins III712476e2018-10-03 15:47:00 -0400703 return this->dimensions();
scroggof24f2242015-03-03 08:59:20 -0800704 }
705
scroggoe7fc14b2015-10-02 13:14:46 -0700706 // FIXME: What to do about subsets??
707 /**
708 * Subclasses should override if they support dimensions other than the
709 * srcInfo's.
710 */
711 virtual bool onDimensionsSupported(const SkISize&) {
712 return false;
713 }
714
Hal Canarydb683012016-11-23 08:55:18 -0700715 virtual SkEncodedImageFormat onGetEncodedFormat() const = 0;
scroggo1dd3ea92015-03-20 11:55:55 -0700716
msarette6dd0042015-10-09 11:07:34 -0700717 /**
718 * @param rowsDecoded When the encoded image stream is incomplete, this function
719 * will return kIncompleteInput and rowsDecoded will be set to
720 * the number of scanlines that were successfully decoded.
721 * This will allow getPixels() to fill the uninitialized memory.
722 */
scroggoeb602a52015-07-09 08:16:03 -0700723 virtual Result onGetPixels(const SkImageInfo& info,
724 void* pixels, size_t rowBytes, const Options&,
msarette6dd0042015-10-09 11:07:34 -0700725 int* rowsDecoded) = 0;
scroggoeb602a52015-07-09 08:16:03 -0700726
Jim Van Verthe24b5872018-10-29 16:26:02 -0400727 virtual bool onQueryYUV8(SkYUVASizeInfo*, SkYUVColorSpace*) const {
msarettb714fb02016-01-22 14:46:42 -0800728 return false;
729 }
730
Jim Van Verthe24b5872018-10-29 16:26:02 -0400731 virtual Result onGetYUV8Planes(const SkYUVASizeInfo&,
732 void*[SkYUVASizeInfo::kMaxCount] /*planes*/) {
msarettb714fb02016-01-22 14:46:42 -0800733 return kUnimplemented;
734 }
735
736 virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
scroggob636b452015-07-22 07:16:20 -0700737 // By default, subsets are not supported.
738 return false;
739 }
740
msarett90c4d5f2015-12-10 13:09:24 -0800741 /**
scroggof24f2242015-03-03 08:59:20 -0800742 * If the stream was previously read, attempt to rewind.
scroggob427db12015-08-12 07:24:13 -0700743 *
744 * If the stream needed to be rewound, call onRewind.
745 * @returns true if the codec is at the right position and can be used.
746 * false if there was a failure to rewind.
halcanarya096d7a2015-03-27 12:16:53 -0700747 *
Nigel Tao13df9812018-08-08 14:33:58 +1000748 * This is called by getPixels(), getYUV8Planes(), startIncrementalDecode() and
749 * startScanlineDecode(). Subclasses may call if they need to rewind at another time.
scroggof24f2242015-03-03 08:59:20 -0800750 */
scroggob427db12015-08-12 07:24:13 -0700751 bool SK_WARN_UNUSED_RESULT rewindIfNeeded();
752
753 /**
754 * Called by rewindIfNeeded, if the stream needed to be rewound.
755 *
756 * Subclasses should do any set up needed after a rewind.
757 */
758 virtual bool onRewind() {
759 return true;
760 }
scroggof24f2242015-03-03 08:59:20 -0800761
msarettc0e80c12015-07-01 06:50:35 -0700762 /**
msarett74114382015-03-16 11:55:18 -0700763 * Get method for the input stream
msarett74114382015-03-16 11:55:18 -0700764 */
765 SkStream* stream() {
766 return fStream.get();
767 }
768
scroggo46c57472015-09-30 08:57:13 -0700769 /**
770 * The remaining functions revolve around decoding scanlines.
771 */
772
773 /**
774 * Most images types will be kTopDown and will not need to override this function.
775 */
776 virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; }
777
scroggo46c57472015-09-30 08:57:13 -0700778 const SkImageInfo& dstInfo() const { return fDstInfo; }
779
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400780 const Options& options() const { return fOptions; }
scroggo46c57472015-09-30 08:57:13 -0700781
msarettcb0d5c92015-12-03 12:23:43 -0800782 /**
783 * Returns the number of scanlines that have been decoded so far.
784 * This is unaffected by the SkScanlineOrder.
785 *
786 * Returns -1 if we have not started a scanline decode.
787 */
788 int currScanline() const { return fCurrScanline; }
789
msarette6dd0042015-10-09 11:07:34 -0700790 virtual int onOutputScanline(int inputScanline) const;
791
Leon Scroggins III9b0ba2c2018-11-19 14:52:37 -0500792 /**
793 * Return whether we can convert to dst.
794 *
795 * Will be called for the appropriate frame, prior to initializing the colorXform.
796 */
797 virtual bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
798 bool needsColorXform);
799
Leon Scroggins IIIae79f322017-08-18 10:53:24 -0400800 // Some classes never need a colorXform e.g.
801 // - ICO uses its embedded codec's colorXform
802 // - WBMP is just Black/White
803 virtual bool usesColorXform() const { return true; }
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400804 void applyColorXform(void* dst, const void* src, int count) const;
805
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400806 bool colorXform() const { return fXformTime != kNo_XformTime; }
807 bool xformOnDecode() const { return fXformTime == kDecodeRow_XformTime; }
Matt Sarett313c4632016-10-20 12:35:23 -0400808
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400809 virtual int onGetFrameCount() {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400810 return 1;
811 }
812
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400813 virtual bool onGetFrameInfo(int, FrameInfo*) const {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400814 return false;
scroggo19b91532016-10-24 09:03:26 -0700815 }
816
scroggoe71b1a12016-11-01 08:28:28 -0700817 virtual int onGetRepetitionCount() {
818 return 0;
819 }
820
Matt Sarett313c4632016-10-20 12:35:23 -0400821private:
822 const SkEncodedInfo fEncodedInfo;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400823 const XformFormat fSrcXformFormat;
bungeman6bd52842016-10-27 09:30:08 -0700824 std::unique_ptr<SkStream> fStream;
Matt Sarett313c4632016-10-20 12:35:23 -0400825 bool fNeedsRewind;
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400826 const SkEncodedOrigin fOrigin;
Matt Sarett313c4632016-10-20 12:35:23 -0400827
828 SkImageInfo fDstInfo;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400829 Options fOptions;
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400830
831 enum XformTime {
832 kNo_XformTime,
833 kPalette_XformTime,
834 kDecodeRow_XformTime,
835 };
836 XformTime fXformTime;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400837 XformFormat fDstXformFormat; // Based on fDstInfo.
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400838 skcms_ICCProfile fDstProfile;
839 skcms_AlphaFormat fDstXformAlphaFormat;
scroggo8e6c7ad2016-09-16 08:20:38 -0700840
841 // Only meaningful during scanline decodes.
Matt Sarett313c4632016-10-20 12:35:23 -0400842 int fCurrScanline;
scroggo46c57472015-09-30 08:57:13 -0700843
Matt Sarett313c4632016-10-20 12:35:23 -0400844 bool fStartedIncrementalDecode;
scroggo8e6c7ad2016-09-16 08:20:38 -0700845
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400846 bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
847
Leon Scroggins III07418182017-08-15 12:24:02 -0400848 /**
scroggoe7fc14b2015-10-02 13:14:46 -0700849 * Return whether these dimensions are supported as a scale.
850 *
851 * The codec may choose to cache the information about scale and subset.
852 * Either way, the same information will be passed to onGetPixels/onStart
853 * on success.
854 *
855 * This must return true for a size returned from getScaledDimensions.
856 */
857 bool dimensionsSupported(const SkISize& dim) {
Leon Scroggins III712476e2018-10-03 15:47:00 -0400858 return dim == this->dimensions() || this->onDimensionsSupported(dim);
scroggoe7fc14b2015-10-02 13:14:46 -0700859 }
860
Leon Scroggins III1f6af6b2017-06-12 16:41:09 -0400861 /**
862 * For multi-framed images, return the object with information about the frames.
863 */
864 virtual const SkFrameHolder* getFrameHolder() const {
865 return nullptr;
866 }
867
868 /**
869 * Check for a valid Options.fFrameIndex, and decode prior frames if necessary.
870 */
871 Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&);
872
scroggo46c57472015-09-30 08:57:13 -0700873 // Methods for scanline decoding.
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400874 virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000875 const Options& /*options*/) {
scroggo46c57472015-09-30 08:57:13 -0700876 return kUnimplemented;
877 }
878
scroggo8e6c7ad2016-09-16 08:20:38 -0700879 virtual Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000880 const Options&) {
scroggo8e6c7ad2016-09-16 08:20:38 -0700881 return kUnimplemented;
882 }
883
884 virtual Result onIncrementalDecode(int*) {
885 return kUnimplemented;
886 }
887
888
msarett9b9497e2016-02-11 13:29:36 -0800889 virtual bool onSkipScanlines(int /*countLines*/) { return false; }
scroggo46c57472015-09-30 08:57:13 -0700890
msarett33bee092015-11-11 12:43:07 -0800891 virtual int onGetScanlines(void* /*dst*/, int /*countLines*/, size_t /*rowBytes*/) { return 0; }
msarette6dd0042015-10-09 11:07:34 -0700892
893 /**
894 * On an incomplete decode, getPixels() and getScanlines() will call this function
895 * to fill any uinitialized memory.
896 *
897 * @param dstInfo Contains the destination color type
898 * Contains the destination alpha type
899 * Contains the destination width
900 * The height stored in this info is unused
901 * @param dst Pointer to the start of destination pixel memory
902 * @param rowBytes Stride length in destination pixel memory
903 * @param zeroInit Indicates if memory is zero initialized
904 * @param linesRequested Number of lines that the client requested
905 * @param linesDecoded Number of lines that were successfully decoded
906 */
907 void fillIncompleteImage(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
908 ZeroInitialized zeroInit, int linesRequested, int linesDecoded);
scroggo46c57472015-09-30 08:57:13 -0700909
scroggoe7fc14b2015-10-02 13:14:46 -0700910 /**
911 * Return an object which will allow forcing scanline decodes to sample in X.
912 *
913 * May create a sampler, if one is not currently being used. Otherwise, does
914 * not affect ownership.
915 *
scroggo19b91532016-10-24 09:03:26 -0700916 * Only valid during scanline decoding or incremental decoding.
scroggoe7fc14b2015-10-02 13:14:46 -0700917 */
msarett33bee092015-11-11 12:43:07 -0800918 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
scroggoe7fc14b2015-10-02 13:14:46 -0700919
scroggo8e6c7ad2016-09-16 08:20:38 -0700920 friend class DM::CodecSrc; // for fillIncompleteImage
msarett3d9d7a72015-10-21 10:27:10 -0700921 friend class SkSampledCodec;
msarettbe8216a2015-12-04 08:00:50 -0800922 friend class SkIcoCodec;
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500923 friend class SkAndroidCodec; // for fEncodedInfo
scroggof24f2242015-03-03 08:59:20 -0800924};
925#endif // SkCodec_DEFINED