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

Classes

struct  Options
 

Enumerations

enum class  AlphaOption { kIgnore , kBlendOnBlack }
 
enum class  Downsample { k420 , k422 , k444 }
 

Functions

SK_API bool Encode (SkWStream *dst, const SkPixmap &src, const Options &options)
 
SK_API bool Encode (SkWStream *dst, const SkYUVAPixmaps &src, const SkColorSpace *srcColorSpace, 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)
 
SK_API std::unique_ptr< SkEncoderMake (SkWStream *dst, const SkYUVAPixmaps &src, const SkColorSpace *srcColorSpace, const Options &options)
 

Enumeration Type Documentation

◆ AlphaOption

enum class SkJpegEncoder::AlphaOption
strong
Enumerator
kIgnore 
kBlendOnBlack 

Definition at line 28 of file SkJpegEncoder.h.

◆ Downsample

enum class SkJpegEncoder::Downsample
strong
Enumerator
k420 

Reduction by a factor of two in both the horizontal and vertical directions.

k422 

Reduction by a factor of two in the horizontal direction.

k444 

No downsampling.

Definition at line 33 of file SkJpegEncoder.h.

33 {
34 /**
35 * Reduction by a factor of two in both the horizontal and vertical directions.
36 */
37 k420,
38
39 /**
40 * Reduction by a factor of two in the horizontal direction.
41 */
42 k422,
43
44 /**
45 * No downsampling.
46 */
47 k444,
48};

Function Documentation

◆ Encode() [1/3]

sk_sp< SkData > SkJpegEncoder::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 SkJpegEncoder_none.cpp.

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

◆ Encode() [2/3]

bool SkJpegEncoder::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 SkJpegEncoder_none.cpp.

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

◆ Encode() [3/3]

bool SkJpegEncoder::Encode ( SkWStream dst,
const SkYUVAPixmaps src,
const SkColorSpace srcColorSpace,
const Options options 
)

Definition at line 393 of file SkJpegEncoderImpl.cpp.

396 {
397 auto encoder = Make(dst, src, srcColorSpace, options);
398 return encoder.get() && encoder->encodeRows(src.yuvaInfo().height());
399}
const char * options
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
dst
Definition: cp.py:12

◆ Make() [1/2]

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

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

|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 416 of file SkJpegEncoderImpl.cpp.

416 {
417 SkJpegMetadataEncoder::SegmentList metadataSegments;
418 SkJpegMetadataEncoder::AppendXMPStandard(metadataSegments, options.xmpMetadata);
419 SkJpegMetadataEncoder::AppendICC(metadataSegments, options, src.colorSpace());
420 return SkJpegEncoderImpl::MakeRGB(dst, src, options, metadataSegments);
421}
static std::unique_ptr< SkEncoder > MakeRGB(SkWStream *dst, const SkPixmap &src, const SkJpegEncoder::Options &options, const SkJpegMetadataEncoder::SegmentList &metadata)
void AppendICC(SegmentList &segmentList, const SkJpegEncoder::Options &options, const SkColorSpace *colorSpace)
void AppendXMPStandard(SegmentList &segmentList, const SkData *xmpMetadata)
std::vector< Segment > SegmentList

◆ Make() [2/2]

std::unique_ptr< SkEncoder > SkJpegEncoder::Make ( SkWStream dst,
const SkYUVAPixmaps src,
const SkColorSpace srcColorSpace,
const Options options 
)

Definition at line 423 of file SkJpegEncoderImpl.cpp.

426 {
427 SkJpegMetadataEncoder::SegmentList metadataSegments;
428 SkJpegMetadataEncoder::AppendXMPStandard(metadataSegments, options.xmpMetadata);
429 SkJpegMetadataEncoder::AppendICC(metadataSegments, options, srcColorSpace);
430 return SkJpegEncoderImpl::MakeYUV(dst, src, srcColorSpace, options, metadataSegments);
431}
static std::unique_ptr< SkEncoder > MakeYUV(SkWStream *dst, const SkYUVAPixmaps &srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options, const SkJpegMetadataEncoder::SegmentList &metadata)