blob: e6add3b46988260b0031206344603c90fe3a4d43 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/codec/SkCodecAnimation.h"
12#include "include/codec/SkEncodedOrigin.h"
13#include "include/core/SkColor.h"
14#include "include/core/SkEncodedImageFormat.h"
15#include "include/core/SkImageInfo.h"
16#include "include/core/SkPixmap.h"
17#include "include/core/SkSize.h"
18#include "include/core/SkStream.h"
19#include "include/core/SkTypes.h"
20#include "include/core/SkYUVASizeInfo.h"
21#include "include/private/SkEncodedInfo.h"
22#include "include/private/SkNoncopyable.h"
23#include "include/private/SkTemplates.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 Taob8ec7f12019-03-26 10:44:58 +1100612 * kNoFrame if this frame is independent (so it can be
613 * drawn over an uninitialized buffer).
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400614 *
615 * Note that this is the *earliest* frame that can be used
616 * for blending. Any frame from [fRequiredFrame, i) can be
617 * used, unless its fDisposalMethod is kRestorePrevious.
scroggo19b91532016-10-24 09:03:26 -0700618 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400619 int fRequiredFrame;
scroggo19b91532016-10-24 09:03:26 -0700620
621 /**
622 * Number of milliseconds to show this frame.
623 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400624 int fDuration;
Leon Scroggins III3639faa2016-12-08 11:38:58 -0500625
626 /**
627 * Whether the end marker for this frame is contained in the stream.
628 *
629 * Note: this does not guarantee that an attempt to decode will be complete.
630 * There could be an error in the stream.
631 */
632 bool fFullyReceived;
Leon Scroggins IIIa4db9be2017-04-11 10:32:02 -0400633
634 /**
635 * This is conservative; it will still return non-opaque if e.g. a
636 * color index-based frame has a color with alpha but does not use it.
637 */
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500638 SkAlphaType fAlphaType;
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400639
640 /**
641 * How this frame should be modified before decoding the next one.
642 */
643 SkCodecAnimation::DisposalMethod fDisposalMethod;
scroggo19b91532016-10-24 09:03:26 -0700644 };
645
646 /**
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400647 * Return info about a single frame.
648 *
649 * Only supported by multi-frame images. Does not read through the stream,
650 * so it should be called after getFrameCount() to parse any frames that
651 * have not already been parsed.
652 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400653 bool getFrameInfo(int index, FrameInfo* info) const {
Leon Scroggins III557fbbe2017-05-23 09:37:21 -0400654 if (index < 0) {
655 return false;
656 }
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400657 return this->onGetFrameInfo(index, info);
658 }
659
660 /**
661 * Return info about all the frames in the image.
scroggo19b91532016-10-24 09:03:26 -0700662 *
scroggoe71b1a12016-11-01 08:28:28 -0700663 * May require reading through the stream to determine info about the
664 * frames (including the count).
scroggo19b91532016-10-24 09:03:26 -0700665 *
666 * As such, future decoding calls may require a rewind.
667 *
Nigel Tao96597c22018-08-22 10:36:12 +1000668 * For still (non-animated) image codecs, this will return an empty vector.
scroggo19b91532016-10-24 09:03:26 -0700669 */
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400670 std::vector<FrameInfo> getFrameInfo();
scroggo19b91532016-10-24 09:03:26 -0700671
scroggoe71b1a12016-11-01 08:28:28 -0700672 static constexpr int kRepetitionCountInfinite = -1;
673
674 /**
Nigel Tao96597c22018-08-22 10:36:12 +1000675 * Return the number of times to repeat, if this image is animated. This number does not
676 * include the first play through of each frame. For example, a repetition count of 4 means
677 * that each frame is played 5 times and then the animation stops.
678 *
679 * It can return kRepetitionCountInfinite, a negative number, meaning that the animation
680 * should loop forever.
scroggoe71b1a12016-11-01 08:28:28 -0700681 *
682 * May require reading the stream to find the repetition count.
683 *
684 * As such, future decoding calls may require a rewind.
685 *
Nigel Tao96597c22018-08-22 10:36:12 +1000686 * For still (non-animated) image codecs, this will return 0.
scroggoe71b1a12016-11-01 08:28:28 -0700687 */
688 int getRepetitionCount() {
689 return this->onGetRepetitionCount();
690 }
691
Mike Klein159a9592019-04-26 15:47:56 +0000692 // Register a decoder at runtime by passing two function pointers:
693 // - peek() to return true if the span of bytes appears to be your encoded format;
694 // - make() to attempt to create an SkCodec from the given stream.
695 // Not thread safe.
696 static void Register(
697 bool (*peek)(const void*, size_t),
698 std::unique_ptr<SkCodec> (*make)(std::unique_ptr<SkStream>, SkCodec::Result*));
699
scroggof24f2242015-03-03 08:59:20 -0800700protected:
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500701 const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
702
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400703 using XformFormat = skcms_PixelFormat;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400704
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400705 SkCodec(SkEncodedInfo&&,
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400706 XformFormat srcFormat,
Mike Reedede7bac2017-07-23 15:30:02 -0400707 std::unique_ptr<SkStream>,
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400708 SkEncodedOrigin = kTopLeft_SkEncodedOrigin);
msarett549ca322016-08-17 08:54:08 -0700709
msarettb714fb02016-01-22 14:46:42 -0800710 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
scroggof24f2242015-03-03 08:59:20 -0800711 // By default, scaling is not supported.
Leon Scroggins III712476e2018-10-03 15:47:00 -0400712 return this->dimensions();
scroggof24f2242015-03-03 08:59:20 -0800713 }
714
scroggoe7fc14b2015-10-02 13:14:46 -0700715 // FIXME: What to do about subsets??
716 /**
717 * Subclasses should override if they support dimensions other than the
718 * srcInfo's.
719 */
720 virtual bool onDimensionsSupported(const SkISize&) {
721 return false;
722 }
723
Hal Canarydb683012016-11-23 08:55:18 -0700724 virtual SkEncodedImageFormat onGetEncodedFormat() const = 0;
scroggo1dd3ea92015-03-20 11:55:55 -0700725
msarette6dd0042015-10-09 11:07:34 -0700726 /**
727 * @param rowsDecoded When the encoded image stream is incomplete, this function
728 * will return kIncompleteInput and rowsDecoded will be set to
729 * the number of scanlines that were successfully decoded.
730 * This will allow getPixels() to fill the uninitialized memory.
731 */
scroggoeb602a52015-07-09 08:16:03 -0700732 virtual Result onGetPixels(const SkImageInfo& info,
733 void* pixels, size_t rowBytes, const Options&,
msarette6dd0042015-10-09 11:07:34 -0700734 int* rowsDecoded) = 0;
scroggoeb602a52015-07-09 08:16:03 -0700735
Jim Van Verthe24b5872018-10-29 16:26:02 -0400736 virtual bool onQueryYUV8(SkYUVASizeInfo*, SkYUVColorSpace*) const {
msarettb714fb02016-01-22 14:46:42 -0800737 return false;
738 }
739
Jim Van Verthe24b5872018-10-29 16:26:02 -0400740 virtual Result onGetYUV8Planes(const SkYUVASizeInfo&,
741 void*[SkYUVASizeInfo::kMaxCount] /*planes*/) {
msarettb714fb02016-01-22 14:46:42 -0800742 return kUnimplemented;
743 }
744
745 virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
scroggob636b452015-07-22 07:16:20 -0700746 // By default, subsets are not supported.
747 return false;
748 }
749
msarett90c4d5f2015-12-10 13:09:24 -0800750 /**
scroggof24f2242015-03-03 08:59:20 -0800751 * If the stream was previously read, attempt to rewind.
scroggob427db12015-08-12 07:24:13 -0700752 *
753 * If the stream needed to be rewound, call onRewind.
754 * @returns true if the codec is at the right position and can be used.
755 * false if there was a failure to rewind.
halcanarya096d7a2015-03-27 12:16:53 -0700756 *
Nigel Tao13df9812018-08-08 14:33:58 +1000757 * This is called by getPixels(), getYUV8Planes(), startIncrementalDecode() and
758 * startScanlineDecode(). Subclasses may call if they need to rewind at another time.
scroggof24f2242015-03-03 08:59:20 -0800759 */
scroggob427db12015-08-12 07:24:13 -0700760 bool SK_WARN_UNUSED_RESULT rewindIfNeeded();
761
762 /**
763 * Called by rewindIfNeeded, if the stream needed to be rewound.
764 *
765 * Subclasses should do any set up needed after a rewind.
766 */
767 virtual bool onRewind() {
768 return true;
769 }
scroggof24f2242015-03-03 08:59:20 -0800770
msarettc0e80c12015-07-01 06:50:35 -0700771 /**
msarett74114382015-03-16 11:55:18 -0700772 * Get method for the input stream
msarett74114382015-03-16 11:55:18 -0700773 */
774 SkStream* stream() {
775 return fStream.get();
776 }
777
scroggo46c57472015-09-30 08:57:13 -0700778 /**
779 * The remaining functions revolve around decoding scanlines.
780 */
781
782 /**
783 * Most images types will be kTopDown and will not need to override this function.
784 */
785 virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; }
786
scroggo46c57472015-09-30 08:57:13 -0700787 const SkImageInfo& dstInfo() const { return fDstInfo; }
788
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400789 const Options& options() const { return fOptions; }
scroggo46c57472015-09-30 08:57:13 -0700790
msarettcb0d5c92015-12-03 12:23:43 -0800791 /**
792 * Returns the number of scanlines that have been decoded so far.
793 * This is unaffected by the SkScanlineOrder.
794 *
795 * Returns -1 if we have not started a scanline decode.
796 */
797 int currScanline() const { return fCurrScanline; }
798
msarette6dd0042015-10-09 11:07:34 -0700799 virtual int onOutputScanline(int inputScanline) const;
800
Leon Scroggins III9b0ba2c2018-11-19 14:52:37 -0500801 /**
802 * Return whether we can convert to dst.
803 *
804 * Will be called for the appropriate frame, prior to initializing the colorXform.
805 */
806 virtual bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
807 bool needsColorXform);
808
Leon Scroggins IIIae79f322017-08-18 10:53:24 -0400809 // Some classes never need a colorXform e.g.
810 // - ICO uses its embedded codec's colorXform
811 // - WBMP is just Black/White
812 virtual bool usesColorXform() const { return true; }
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400813 void applyColorXform(void* dst, const void* src, int count) const;
814
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400815 bool colorXform() const { return fXformTime != kNo_XformTime; }
816 bool xformOnDecode() const { return fXformTime == kDecodeRow_XformTime; }
Matt Sarett313c4632016-10-20 12:35:23 -0400817
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400818 virtual int onGetFrameCount() {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400819 return 1;
820 }
821
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400822 virtual bool onGetFrameInfo(int, FrameInfo*) const {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400823 return false;
scroggo19b91532016-10-24 09:03:26 -0700824 }
825
scroggoe71b1a12016-11-01 08:28:28 -0700826 virtual int onGetRepetitionCount() {
827 return 0;
828 }
829
Matt Sarett313c4632016-10-20 12:35:23 -0400830private:
831 const SkEncodedInfo fEncodedInfo;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400832 const XformFormat fSrcXformFormat;
bungeman6bd52842016-10-27 09:30:08 -0700833 std::unique_ptr<SkStream> fStream;
Matt Sarett313c4632016-10-20 12:35:23 -0400834 bool fNeedsRewind;
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400835 const SkEncodedOrigin fOrigin;
Matt Sarett313c4632016-10-20 12:35:23 -0400836
837 SkImageInfo fDstInfo;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400838 Options fOptions;
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400839
840 enum XformTime {
841 kNo_XformTime,
842 kPalette_XformTime,
843 kDecodeRow_XformTime,
844 };
845 XformTime fXformTime;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400846 XformFormat fDstXformFormat; // Based on fDstInfo.
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400847 skcms_ICCProfile fDstProfile;
848 skcms_AlphaFormat fDstXformAlphaFormat;
scroggo8e6c7ad2016-09-16 08:20:38 -0700849
850 // Only meaningful during scanline decodes.
Matt Sarett313c4632016-10-20 12:35:23 -0400851 int fCurrScanline;
scroggo46c57472015-09-30 08:57:13 -0700852
Matt Sarett313c4632016-10-20 12:35:23 -0400853 bool fStartedIncrementalDecode;
scroggo8e6c7ad2016-09-16 08:20:38 -0700854
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400855 bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
856
Leon Scroggins III07418182017-08-15 12:24:02 -0400857 /**
scroggoe7fc14b2015-10-02 13:14:46 -0700858 * Return whether these dimensions are supported as a scale.
859 *
860 * The codec may choose to cache the information about scale and subset.
861 * Either way, the same information will be passed to onGetPixels/onStart
862 * on success.
863 *
864 * This must return true for a size returned from getScaledDimensions.
865 */
866 bool dimensionsSupported(const SkISize& dim) {
Leon Scroggins III712476e2018-10-03 15:47:00 -0400867 return dim == this->dimensions() || this->onDimensionsSupported(dim);
scroggoe7fc14b2015-10-02 13:14:46 -0700868 }
869
Leon Scroggins III1f6af6b2017-06-12 16:41:09 -0400870 /**
871 * For multi-framed images, return the object with information about the frames.
872 */
873 virtual const SkFrameHolder* getFrameHolder() const {
874 return nullptr;
875 }
876
877 /**
878 * Check for a valid Options.fFrameIndex, and decode prior frames if necessary.
879 */
880 Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&);
881
scroggo46c57472015-09-30 08:57:13 -0700882 // Methods for scanline decoding.
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400883 virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000884 const Options& /*options*/) {
scroggo46c57472015-09-30 08:57:13 -0700885 return kUnimplemented;
886 }
887
scroggo8e6c7ad2016-09-16 08:20:38 -0700888 virtual Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000889 const Options&) {
scroggo8e6c7ad2016-09-16 08:20:38 -0700890 return kUnimplemented;
891 }
892
893 virtual Result onIncrementalDecode(int*) {
894 return kUnimplemented;
895 }
896
897
msarett9b9497e2016-02-11 13:29:36 -0800898 virtual bool onSkipScanlines(int /*countLines*/) { return false; }
scroggo46c57472015-09-30 08:57:13 -0700899
msarett33bee092015-11-11 12:43:07 -0800900 virtual int onGetScanlines(void* /*dst*/, int /*countLines*/, size_t /*rowBytes*/) { return 0; }
msarette6dd0042015-10-09 11:07:34 -0700901
902 /**
903 * On an incomplete decode, getPixels() and getScanlines() will call this function
904 * to fill any uinitialized memory.
905 *
906 * @param dstInfo Contains the destination color type
907 * Contains the destination alpha type
908 * Contains the destination width
909 * The height stored in this info is unused
910 * @param dst Pointer to the start of destination pixel memory
911 * @param rowBytes Stride length in destination pixel memory
912 * @param zeroInit Indicates if memory is zero initialized
913 * @param linesRequested Number of lines that the client requested
914 * @param linesDecoded Number of lines that were successfully decoded
915 */
916 void fillIncompleteImage(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
917 ZeroInitialized zeroInit, int linesRequested, int linesDecoded);
scroggo46c57472015-09-30 08:57:13 -0700918
scroggoe7fc14b2015-10-02 13:14:46 -0700919 /**
920 * Return an object which will allow forcing scanline decodes to sample in X.
921 *
922 * May create a sampler, if one is not currently being used. Otherwise, does
923 * not affect ownership.
924 *
scroggo19b91532016-10-24 09:03:26 -0700925 * Only valid during scanline decoding or incremental decoding.
scroggoe7fc14b2015-10-02 13:14:46 -0700926 */
msarett33bee092015-11-11 12:43:07 -0800927 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
scroggoe7fc14b2015-10-02 13:14:46 -0700928
scroggo8e6c7ad2016-09-16 08:20:38 -0700929 friend class DM::CodecSrc; // for fillIncompleteImage
msarett3d9d7a72015-10-21 10:27:10 -0700930 friend class SkSampledCodec;
msarettbe8216a2015-12-04 08:00:50 -0800931 friend class SkIcoCodec;
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500932 friend class SkAndroidCodec; // for fEncodedInfo
scroggof24f2242015-03-03 08:59:20 -0800933};
934#endif // SkCodec_DEFINED