Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SkAndroidCodec Class Referenceabstract

#include <SkAndroidCodec.h>

Inheritance diagram for SkAndroidCodec:
SkNoncopyable SkAndroidCodecAdapter SkSampledCodec

Classes

struct  AndroidOptions
 

Public Types

enum class  ExifOrientationBehavior { kIgnore , kRespect }
 

Public Member Functions

virtual ~SkAndroidCodec ()
 
const SkImageInfogetInfo () const
 
const skcms_ICCProfilegetICCProfile () const
 
SkEncodedImageFormat getEncodedFormat () const
 
SkColorType computeOutputColorType (SkColorType requestedColorType)
 
SkAlphaType computeOutputAlphaType (bool requestedUnpremul)
 
sk_sp< SkColorSpacecomputeOutputColorSpace (SkColorType outputColorType, sk_sp< SkColorSpace > prefColorSpace=nullptr)
 
int computeSampleSize (SkISize *size) const
 
SkISize getSampledDimensions (int sampleSize) const
 
bool getSupportedSubset (SkIRect *desiredSubset) const
 
SkISize getSampledSubsetDimensions (int sampleSize, const SkIRect &subset) const
 
SkCodec::Result getAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions *options)
 
SkCodec::Result getAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
SkCodec::Result getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
SkCodeccodec () const
 
bool getAndroidGainmap (SkGainmapInfo *outInfo, std::unique_ptr< SkStream > *outGainmapImageStream)
 

Static Public Member Functions

static std::unique_ptr< SkAndroidCodecMakeFromCodec (std::unique_ptr< SkCodec >)
 
static std::unique_ptr< SkAndroidCodecMakeFromStream (std::unique_ptr< SkStream >, SkPngChunkReader *=nullptr)
 
static std::unique_ptr< SkAndroidCodecMakeFromData (sk_sp< SkData >, SkPngChunkReader *=nullptr)
 

Protected Member Functions

 SkAndroidCodec (SkCodec *)
 
virtual SkISize onGetSampledDimensions (int sampleSize) const =0
 
virtual bool onGetSupportedSubset (SkIRect *desiredSubset) const =0
 
virtual SkCodec::Result onGetAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions &options)=0
 

Detailed Description

Abstract interface defining image codec functionality that is necessary for Android.

Definition at line 39 of file SkAndroidCodec.h.

Member Enumeration Documentation

◆ ExifOrientationBehavior

Deprecated.

Now that SkAndroidCodec supports multiframe images, there are multiple ways to handle compositing an oriented frame on top of an oriented frame with different tradeoffs. SkAndroidCodec now ignores the orientation and forces the client to handle it.

Enumerator
kIgnore 
kRespect 

Definition at line 49 of file SkAndroidCodec.h.

49 {
50 kIgnore,
51 kRespect,
52 };

Constructor & Destructor Documentation

◆ ~SkAndroidCodec()

SkAndroidCodec::~SkAndroidCodec ( )
virtual

Definition at line 204 of file SkAndroidCodec.cpp.

204{}

◆ SkAndroidCodec()

SkAndroidCodec::SkAndroidCodec ( SkCodec codec)
protected

Definition at line 199 of file SkAndroidCodec.cpp.

200 : fInfo(codec->getInfo())
201 , fCodec(codec)
202{}
SkCodec * codec() const
SkImageInfo getInfo() const
Definition: SkCodec.h:228

Member Function Documentation

◆ codec()

SkCodec * SkAndroidCodec::codec ( ) const
inline

Definition at line 264 of file SkAndroidCodec.h.

264{ return fCodec.get(); }

◆ computeOutputAlphaType()

SkAlphaType SkAndroidCodec::computeOutputAlphaType ( bool  requestedUnpremul)
Parameters
requestedUnpremulIndicates if the client requested unpremultiplied output

Returns the appropriate alpha type to decode to. If the image has alpha, the value of requestedUnpremul will be honored.

Definition at line 297 of file SkAndroidCodec.cpp.

297 {
298 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) {
299 return kOpaque_SkAlphaType;
300 }
301 return requestedUnpremul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
302}
kUnpremul_SkAlphaType
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
const SkImageInfo & getInfo() const

◆ computeOutputColorSpace()

sk_sp< SkColorSpace > SkAndroidCodec::computeOutputColorSpace ( SkColorType  outputColorType,
sk_sp< SkColorSpace prefColorSpace = nullptr 
)
Parameters
outputColorTypeColor type that the client will decode to.
prefColorSpacePreferred color space to decode to. This may not return |prefColorSpace| for specific color types.

Returns the appropriate color space to decode to.

Definition at line 304 of file SkAndroidCodec.cpp.

305 {
306 switch (outputColorType) {
312 // If |prefColorSpace| is supplied, choose it.
313 if (prefColorSpace) {
314 return prefColorSpace;
315 }
316
317 const skcms_ICCProfile* encodedProfile = fCodec->getEncodedInfo().profile();
318 if (encodedProfile) {
319 // Prefer CICP information if it exists.
320 if (encodedProfile->has_CICP) {
321 const auto cicpColorSpace =
323 encodedProfile->CICP.transfer_characteristics,
324 encodedProfile->CICP.matrix_coefficients,
325 encodedProfile->CICP.video_full_range_flag);
326 if (cicpColorSpace) {
327 return cicpColorSpace;
328 }
329 }
330 if (auto encodedSpace = SkColorSpace::Make(*encodedProfile)) {
331 // Leave the pixels in the encoded color space. Color space conversion
332 // will be handled after decode time.
333 return encodedSpace;
334 }
335
336 if (encodedProfile->has_toXYZD50) {
338 encodedProfile->toXYZD50);
339 }
340 }
341
342 return SkColorSpace::MakeSRGB();
343 }
344 default:
345 // Color correction not supported for kGray.
346 return nullptr;
347 }
348}
static sk_sp< SkColorSpace > cicp_get_sk_color_space(uint8_t color_primaries, uint8_t transfer_characteristics, uint8_t matrix_coefficients, uint8_t full_range_flag)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:27
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkColorSpace > Make(const skcms_ICCProfile &)
static constexpr skcms_TransferFunction kSRGB
Definition: SkColorSpace.h:45
uint8_t color_primaries
Definition: skcms_public.h:167
uint8_t matrix_coefficients
Definition: skcms_public.h:169
uint8_t video_full_range_flag
Definition: skcms_public.h:170
uint8_t transfer_characteristics
Definition: skcms_public.h:168
skcms_Matrix3x3 toXYZD50
Definition: skcms_public.h:191
skcms_CICP CICP
Definition: skcms_public.h:208

◆ computeOutputColorType()

SkColorType SkAndroidCodec::computeOutputColorType ( SkColorType  requestedColorType)
Parameters
requestedColorTypeColor type requested by the client

|requestedColorType| may be overriden. We will default to kF16 for high precision images.

In the general case, if it is possible to decode to |requestedColorType|, this returns |requestedColorType|. Otherwise, this returns a color type that is an appropriate match for the the encoded data.

Definition at line 259 of file SkAndroidCodec.cpp.

259 {
260 bool highPrecision = fCodec->getEncodedInfo().bitsPerComponent() > 8;
261 uint8_t colorDepth = fCodec->getEncodedInfo().getColorDepth();
262 switch (requestedColorType) {
264 return kN32_SkColorType;
265 case kN32_SkColorType:
266 break;
268 // Fall through to kGray_8. Before kGray_8_SkColorType existed,
269 // we allowed clients to request kAlpha_8 when they wanted a
270 // grayscale decode.
272 if (kGray_8_SkColorType == this->getInfo().colorType()) {
273 return kGray_8_SkColorType;
274 }
275 break;
277 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) {
279 }
280 break;
282 if (colorDepth == 10) {
284 }
285 break;
288 default:
289 break;
290 }
291
292 // F16 is the Android default for high precision images.
293 return highPrecision ? kRGBA_F16_SkColorType :
294 (colorDepth == 10 ? kRGBA_1010102_SkColorType : kN32_SkColorType);
295}
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ computeSampleSize()

int SkAndroidCodec::computeSampleSize ( SkISize size) const

Compute the appropriate sample size to get to |size|.

Parameters
sizeAs an input parameter, the desired output size of the decode. As an output parameter, the smallest sampled size larger than the input.
Returns
the sample size to set AndroidOptions::fSampleSize to decode to the output |size|.

Definition at line 367 of file SkAndroidCodec.cpp.

367 {
368 SkASSERT(desiredSize);
369
370 const auto origDims = fCodec->dimensions();
371 if (!desiredSize || *desiredSize == origDims) {
372 return 1;
373 }
374
375 if (smaller_than(origDims, *desiredSize)) {
376 *desiredSize = origDims;
377 return 1;
378 }
379
380 // Handle bad input:
381 if (desiredSize->width() < 1 || desiredSize->height() < 1) {
382 *desiredSize = SkISize::Make(std::max(1, desiredSize->width()),
383 std::max(1, desiredSize->height()));
384 }
385
386 if (supports_any_down_scale(fCodec.get())) {
387 return 1;
388 }
389
390 int sampleX = origDims.width() / desiredSize->width();
391 int sampleY = origDims.height() / desiredSize->height();
392 int sampleSize = std::min(sampleX, sampleY);
393 auto computedSize = this->getSampledDimensions(sampleSize);
394 if (computedSize == *desiredSize) {
395 return sampleSize;
396 }
397
398 if (computedSize == origDims || sampleSize == 1) {
399 // Cannot downscale
400 *desiredSize = computedSize;
401 return 1;
402 }
403
404 if (strictly_bigger_than(computedSize, *desiredSize)) {
405 // See if there is a tighter fit.
406 while (true) {
407 auto smaller = this->getSampledDimensions(sampleSize + 1);
408 if (smaller == *desiredSize) {
409 return sampleSize + 1;
410 }
411 if (smaller == computedSize || smaller_than(smaller, *desiredSize)) {
412 // Cannot get any smaller without being smaller than desired.
413 *desiredSize = computedSize;
414 return sampleSize;
415 }
416
417 sampleSize++;
418 computedSize = smaller;
419 }
420
421 SkASSERT(false);
422 }
423
424 if (!smaller_than(computedSize, *desiredSize)) {
425 // This means one of the computed dimensions is equal to desired, and
426 // the other is bigger. This is as close as we can get.
427 *desiredSize = computedSize;
428 return sampleSize;
429 }
430
431 // computedSize is too small. Make it larger.
432 while (sampleSize > 2) {
433 auto bigger = this->getSampledDimensions(sampleSize - 1);
434 if (bigger == *desiredSize || !smaller_than(bigger, *desiredSize)) {
435 *desiredSize = bigger;
436 return sampleSize - 1;
437 }
438 sampleSize--;
439 }
440
441 *desiredSize = origDims;
442 return 1;
443}
static bool smaller_than(const SkISize &a, const SkISize &b)
static bool strictly_bigger_than(const SkISize &a, const SkISize &b)
static bool supports_any_down_scale(const SkCodec *codec)
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkISize getSampledDimensions(int sampleSize) const
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getAndroidGainmap()

bool SkAndroidCodec::getAndroidGainmap ( SkGainmapInfo outInfo,
std::unique_ptr< SkStream > *  outGainmapImageStream 
)

Retrieve the gainmap for an image.

Parameters
outInfoOn success, this is populated with the parameters for rendering this gainmap. This parameter must be non-nullptr.
outGainmapImageStreamOn success, this is populated with a stream from which the gainmap image may be decoded. This parameter is optional, and may be set to nullptr.
Returns
If this has a gainmap image and that gainmap image was successfully extracted then return true. Otherwise return false.

Definition at line 544 of file SkAndroidCodec.cpp.

545 {
546 return fCodec->onGetGainmapInfo(info, outGainmapImageStream);
547}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213

◆ getAndroidPixels() [1/2]

SkCodec::Result SkAndroidCodec::getAndroidPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes 
)

Simplified version of getAndroidPixels() where we supply the default AndroidOptions as specified above for AndroidOptions. It will not perform any scaling or subsetting.

Definition at line 539 of file SkAndroidCodec.cpp.

540 {
541 return this->getAndroidPixels(info, pixels, rowBytes, nullptr);
542}
SkCodec::Result getAndroidPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions *options)

◆ getAndroidPixels() [2/2]

SkCodec::Result SkAndroidCodec::getAndroidPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
const AndroidOptions options 
)

Decode into the given pixels, a block of memory of size at least (info.fHeight - 1) * rowBytes + (info.fWidth * bytesPerPixel)

Repeated calls to this function should give the same results, allowing the PixelRef to be immutable.

Parameters
infoA description of the format (config, size) expected by the caller. This can simply be identical to the info returned by getInfo().

This contract also allows the caller to specify different output-configs, which the implementation can decide to support or not.

A size that does not match getInfo() implies a request to scale or subset. If the codec cannot perform this scaling or subsetting, it will return an error code.

The AndroidOptions object is also used to specify any requested scaling or subsetting using options->fSampleSize and options->fSubset. If NULL, the defaults (as specified above for AndroidOptions) are used.

Returns
Result kSuccess, or another value explaining the type of failure.

Definition at line 490 of file SkAndroidCodec.cpp.

491 {
492 if (!requestPixels) {
494 }
495 if (requestRowBytes < requestInfo.minRowBytes()) {
497 }
498
499 AndroidOptions defaultOptions;
500 if (!options) {
501 options = &defaultOptions;
502 } else {
503 if (options->fSubset) {
504 if (!is_valid_subset(*options->fSubset, fCodec->dimensions())) {
506 }
507
508 if (SkIRect::MakeSize(fCodec->dimensions()) == *options->fSubset) {
509 // The caller wants the whole thing, rather than a subset. Modify
510 // the AndroidOptions passed to onGetAndroidPixels to not specify
511 // a subset.
512 defaultOptions = *options;
513 defaultOptions.fSubset = nullptr;
514 options = &defaultOptions;
515 }
516 }
517 }
518
519 // We may need to have handleFrameIndex recursively call this method
520 // to resolve one frame depending on another. The recursion stops
521 // when we find a frame which does not require an earlier frame
522 // e.g. frame->getRequiredFrame() returns kNoFrame
523 auto getPixelsFn = [&](const SkImageInfo& info, void* pixels, size_t rowBytes,
524 const SkCodec::Options& opts, int requiredFrame
525 ) -> SkCodec::Result {
526 SkAndroidCodec::AndroidOptions prevFrameOptions(
527 reinterpret_cast<const SkAndroidCodec::AndroidOptions&>(opts));
528 prevFrameOptions.fFrameIndex = requiredFrame;
529 return this->getAndroidPixels(info, pixels, rowBytes, &prevFrameOptions);
530 };
531 if (auto result = fCodec->handleFrameIndex(requestInfo, requestPixels, requestRowBytes,
532 *options, getPixelsFn); result != SkCodec::kSuccess) {
533 return result;
534 }
535
536 return this->onGetAndroidPixels(requestInfo, requestPixels, requestRowBytes, *options);
537}
const char * options
static bool is_valid_subset(const SkIRect &subset, const SkISize &imageDims)
Definition: SkCodecPriv.h:35
virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions &options)=0
Result
Definition: SkCodec.h:76
@ kInvalidParameters
Definition: SkCodec.h:105
@ kSuccess
Definition: SkCodec.h:80
GAsyncResult * result
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

◆ getEncodedFormat()

SkEncodedImageFormat SkAndroidCodec::getEncodedFormat ( ) const
inline

Format of the encoded data.

Definition at line 97 of file SkAndroidCodec.h.

97{ return fCodec->getEncodedFormat(); }

◆ getICCProfile()

const skcms_ICCProfile * SkAndroidCodec::getICCProfile ( ) const
inline

Return the ICC profile of the encoded data.

Definition at line 90 of file SkAndroidCodec.h.

90 {
91 return fCodec->getEncodedInfo().profile();
92 }

◆ getInfo()

const SkImageInfo & SkAndroidCodec::getInfo ( ) const
inline

Definition at line 85 of file SkAndroidCodec.h.

85{ return fInfo; }

◆ getPixels()

SkCodec::Result SkAndroidCodec::getPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes 
)
inline

Definition at line 260 of file SkAndroidCodec.h.

260 {
261 return this->getAndroidPixels(info, pixels, rowBytes);
262 }

◆ getSampledDimensions()

SkISize SkAndroidCodec::getSampledDimensions ( int  sampleSize) const

Returns the dimensions of the scaled output image, for an input sampleSize.

When the sample size divides evenly into the original dimensions, the scaled output dimensions will simply be equal to the original dimensions divided by the sample size.

When the sample size does not divide even into the original dimensions, the codec may round up or down, depending on what is most efficient to decode.

Finally, the codec will always recommend a non-zero output, so the output dimension will always be one if the sampleSize is greater than the original dimension.

Definition at line 445 of file SkAndroidCodec.cpp.

445 {
446 if (!is_valid_sample_size(sampleSize)) {
447 return {0, 0};
448 }
449
450 // Fast path for when we are not scaling.
451 if (1 == sampleSize) {
452 return fCodec->dimensions();
453 }
454
455 return this->onGetSampledDimensions(sampleSize);
456}
static bool is_valid_sample_size(int sampleSize)
virtual SkISize onGetSampledDimensions(int sampleSize) const =0

◆ getSampledSubsetDimensions()

SkISize SkAndroidCodec::getSampledSubsetDimensions ( int  sampleSize,
const SkIRect subset 
) const

Returns the dimensions of the scaled, partial output image, for an input sampleSize and subset.

Parameters
sampleSizeFactor to scale down by.
subsetMust be a valid subset of the original image dimensions and a subset supported by SkAndroidCodec. getSubset() can be used to obtain a subset supported by SkAndroidCodec.
Returns
Size of the scaled partial image. Or zero size if either of the inputs is invalid.

Definition at line 466 of file SkAndroidCodec.cpp.

466 {
467 if (!is_valid_sample_size(sampleSize)) {
468 return {0, 0};
469 }
470
471 // We require that the input subset is a subset that is supported by SkAndroidCodec.
472 // We test this by calling getSupportedSubset() and verifying that no modifications
473 // are made to the subset.
474 SkIRect copySubset = subset;
475 if (!this->getSupportedSubset(&copySubset) || copySubset != subset) {
476 return {0, 0};
477 }
478
479 // If the subset is the entire image, for consistency, use getSampledDimensions().
480 if (fCodec->dimensions() == subset.size()) {
481 return this->getSampledDimensions(sampleSize);
482 }
483
484 // This should perhaps call a virtual function, but currently both of our subclasses
485 // want the same implementation.
486 return {get_scaled_dimension(subset.width(), sampleSize),
487 get_scaled_dimension(subset.height(), sampleSize)};
488}
static int get_scaled_dimension(int srcDimension, int sampleSize)
Definition: SkCodecPriv.h:44
bool getSupportedSubset(SkIRect *desiredSubset) const
Definition: SkRect.h:32
constexpr SkISize size() const
Definition: SkRect.h:172
constexpr int32_t height() const
Definition: SkRect.h:165
constexpr int32_t width() const
Definition: SkRect.h:158

◆ getSupportedSubset()

bool SkAndroidCodec::getSupportedSubset ( SkIRect desiredSubset) const

Return (via desiredSubset) a subset which can decoded from this codec, or false if the input subset is invalid.

Parameters
desiredSubsetin/out parameter As input, a desired subset of the original bounds (as specified by getInfo). As output, if true is returned, desiredSubset may have been modified to a subset which is supported. Although a particular change may have been made to desiredSubset to create something supported, it is possible other changes could result in a valid subset. If false is returned, desiredSubset's value is undefined.
Returns
true If the input desiredSubset is valid. desiredSubset may be modified to a subset supported by the codec. false If desiredSubset is invalid (NULL or not fully contained within the image).

Definition at line 458 of file SkAndroidCodec.cpp.

458 {
459 if (!desiredSubset || !is_valid_subset(*desiredSubset, fCodec->dimensions())) {
460 return false;
461 }
462
463 return this->onGetSupportedSubset(desiredSubset);
464}
virtual bool onGetSupportedSubset(SkIRect *desiredSubset) const =0

◆ MakeFromCodec()

std::unique_ptr< SkAndroidCodec > SkAndroidCodec::MakeFromCodec ( std::unique_ptr< SkCodec codec)
static

Pass ownership of an SkCodec to a newly-created SkAndroidCodec.

Definition at line 212 of file SkAndroidCodec.cpp.

212 {
213 if (nullptr == codec) {
214 return nullptr;
215 }
216
219 if (SkCodecs::HasDecoder("avif")) {
220 // If a dedicated AVIF decoder has been registered, SkAvifCodec can
221 // handle scaling internally.
222 return std::make_unique<SkAndroidCodecAdapter>(codec.release());
223 }
224 // This will fallback to SkHeifCodec, which needs sampling.
225 return std::make_unique<SkSampledCodec>(codec.release());
226 }
227
228 switch (format) {
235 return std::make_unique<SkSampledCodec>(codec.release());
239 return std::make_unique<SkAndroidCodecAdapter>(codec.release());
240 case SkEncodedImageFormat::kAVIF: // Handled above
245 return nullptr;
246 }
248}
#define SkUNREACHABLE
Definition: SkAssert.h:135
SkEncodedImageFormat
SkEncodedImageFormat getEncodedFormat() const
Definition: SkCodec.h:292
uint32_t uint32_t * format
bool HasDecoder(std::string_view id)
Definition: SkCodec.cpp:146

◆ MakeFromData()

std::unique_ptr< SkAndroidCodec > SkAndroidCodec::MakeFromData ( sk_sp< SkData data,
SkPngChunkReader chunkReader = nullptr 
)
static

If this data represents an encoded image that we know how to decode, return an SkAndroidCodec that can decode it. Otherwise return NULL.

The SkPngChunkReader handles unknown chunks in PNGs. See SkCodec.h for more details.

Definition at line 250 of file SkAndroidCodec.cpp.

251 {
252 if (!data) {
253 return nullptr;
254 }
255
256 return MakeFromStream(SkMemoryStream::Make(std::move(data)), chunkReader);
257}
static std::unique_ptr< SkAndroidCodec > MakeFromStream(std::unique_ptr< SkStream >, SkPngChunkReader *=nullptr)
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Definition: SkStream.cpp:314
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ MakeFromStream()

std::unique_ptr< SkAndroidCodec > SkAndroidCodec::MakeFromStream ( std::unique_ptr< SkStream stream,
SkPngChunkReader chunkReader = nullptr 
)
static

If this stream represents an encoded image that we know how to decode, return an SkAndroidCodec that can decode it. Otherwise return NULL.

The SkPngChunkReader handles unknown chunks in PNGs. See SkCodec.h for more details.

If NULL is returned, the stream is deleted immediately. Otherwise, the SkCodec takes ownership of it, and will delete it when done with it.

Definition at line 206 of file SkAndroidCodec.cpp.

207 {
208 auto codec = SkCodec::MakeFromStream(std::move(stream), nullptr, chunkReader);
209 return MakeFromCodec(std::move(codec));
210}
static std::unique_ptr< SkAndroidCodec > MakeFromCodec(std::unique_ptr< SkCodec >)
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, SkSpan< const SkCodecs::Decoder > decoders, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
Definition: SkCodec.cpp:163

◆ onGetAndroidPixels()

virtual SkCodec::Result SkAndroidCodec::onGetAndroidPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
const AndroidOptions options 
)
protectedpure virtual

Implemented in SkAndroidCodecAdapter, and SkSampledCodec.

◆ onGetSampledDimensions()

virtual SkISize SkAndroidCodec::onGetSampledDimensions ( int  sampleSize) const
protectedpure virtual

Implemented in SkAndroidCodecAdapter, and SkSampledCodec.

◆ onGetSupportedSubset()

virtual bool SkAndroidCodec::onGetSupportedSubset ( SkIRect desiredSubset) const
protectedpure virtual

Implemented in SkAndroidCodecAdapter, and SkSampledCodec.


The documentation for this class was generated from the following files: