Flutter Engine
The Flutter Engine
Classes | Enumerations | Functions
SkPngEncoder Namespace Reference

Classes

struct  Options
 

Enumerations

enum class  FilterFlag : int {
  kZero = 0x00 , kNone = 0x08 , kSub = 0x10 , kUp = 0x20 ,
  kAvg = 0x40 , kPaeth = 0x80 , kAll = kNone | kSub | kUp | kAvg | kPaeth
}
 

Functions

FilterFlag operator| (FilterFlag x, FilterFlag y)
 
SK_API bool Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API sk_sp< SkDataEncode (GrDirectContext *ctx, const SkImage *img, const Options &options)
 
SK_API std::unique_ptr< SkEncoderMake (SkWStream *dst, const SkPixmap &src, const Options &options)
 

Enumeration Type Documentation

◆ FilterFlag

enum class SkPngEncoder::FilterFlag : int
strong
Enumerator
kZero 
kNone 
kSub 
kUp 
kAvg 
kPaeth 
kAll 

Definition at line 29 of file SkPngEncoder.h.

29 : int {
30 kZero = 0x00,
31 kNone = 0x08,
32 kSub = 0x10,
33 kUp = 0x20,
34 kAvg = 0x40,
35 kPaeth = 0x80,
36 kAll = kNone | kSub | kUp | kAvg | kPaeth,
37};
@ kUp
Definition: embedder.h:973
@ kNone
Definition: layer.h:53

Function Documentation

◆ Encode() [1/2]

sk_sp< SkData > SkPngEncoder::Encode ( GrDirectContext ctx,
const SkImage img,
const Options options 
)

Encode the provided image and return the resulting bytes. If the image was created as a texture-backed image on a GPU context, that |ctx| must be provided so the pixels can be read before being encoded. For raster-backed images, |ctx| can be nullptr. |options| may be used to control the encoding behavior.

Returns nullptr if the pixels could not be read or encoding otherwise fails.

Definition at line 25 of file SkPngEncoder_none.cpp.

25 {
26 SkDEBUGFAIL("Using encoder stub");
27 return nullptr;
28}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118

◆ Encode() [2/2]

bool SkPngEncoder::Encode ( SkWStream dst,
const SkPixmap src,
const Options options 
)

Encode the |src| pixels to the |dst| stream. |options| may be used to control the encoding behavior.

Returns true on success. Returns false on an invalid or unsupported |src|.

Definition at line 20 of file SkPngEncoder_none.cpp.

20 {
21 SkDEBUGFAIL("Using encoder stub");
22 return false;
23}

◆ Make()

std::unique_ptr< SkEncoder > SkPngEncoder::Make ( SkWStream dst,
const SkPixmap src,
const Options options 
)

Create a png encoder that will encode the |src| pixels to the |dst| stream. |options| may be used to control the encoding behavior.

The primary use of this is incremental encoding of the pixels.

|dst| is unowned but must remain valid for the lifetime of the object.

This returns nullptr on an invalid or unsupported |src|.

Definition at line 481 of file SkPngEncoderImpl.cpp.

481 {
482 if (!SkPixmapIsValid(src)) {
483 return nullptr;
484 }
485
486 std::unique_ptr<SkPngEncoderMgr> encoderMgr = SkPngEncoderMgr::Make(dst);
487 if (!encoderMgr) {
488 return nullptr;
489 }
490
491 if (!encoderMgr->setHeader(src.info(), options)) {
492 return nullptr;
493 }
494
495 if (!encoderMgr->setColorSpace(src.info(), options)) {
496 return nullptr;
497 }
498
499 if (!encoderMgr->writeInfo(src.info())) {
500 return nullptr;
501 }
502
503 encoderMgr->chooseProc(src.info());
504
505 return std::make_unique<SkPngEncoderImpl>(std::move(encoderMgr), src);
506}
const char * options
static bool SkPixmapIsValid(const SkPixmap &src)
static std::unique_ptr< SkPngEncoderMgr > Make(SkWStream *stream)
dst
Definition: cp.py:12

◆ operator|()

FilterFlag SkPngEncoder::operator| ( FilterFlag  x,
FilterFlag  y 
)
inline

Definition at line 39 of file SkPngEncoder.h.

39{ return (FilterFlag)((int)x | (int)y); }
double y
double x