Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkJpegEncoderMgr Class Referencefinal
Inheritance diagram for SkJpegEncoderMgr:
SkNoncopyable

Public Member Functions

bool initializeRGB (const SkImageInfo &, const SkJpegEncoder::Options &, const SkJpegMetadataEncoder::SegmentList &)
 
bool initializeYUV (const SkYUVAPixmapInfo &, const SkJpegEncoder::Options &, const SkJpegMetadataEncoder::SegmentList &)
 
jpeg_compress_struct * cinfo ()
 
skjpeg_error_mgrerrorMgr ()
 
transform_scanline_proc proc () const
 
 ~SkJpegEncoderMgr ()
 

Static Public Member Functions

static std::unique_ptr< SkJpegEncoderMgrMake (SkWStream *stream)
 

Detailed Description

Definition at line 47 of file SkJpegEncoderImpl.cpp.

Constructor & Destructor Documentation

◆ ~SkJpegEncoderMgr()

SkJpegEncoderMgr::~SkJpegEncoderMgr ( )
inline

Definition at line 70 of file SkJpegEncoderImpl.cpp.

70{ jpeg_destroy_compress(&fCInfo); }

Member Function Documentation

◆ cinfo()

jpeg_compress_struct * SkJpegEncoderMgr::cinfo ( )
inline

Definition at line 64 of file SkJpegEncoderImpl.cpp.

64{ return &fCInfo; }

◆ errorMgr()

skjpeg_error_mgr * SkJpegEncoderMgr::errorMgr ( )
inline

Definition at line 66 of file SkJpegEncoderImpl.cpp.

66{ return &fErrMgr; }

◆ initializeRGB()

bool SkJpegEncoderMgr::initializeRGB ( const SkImageInfo srcInfo,
const SkJpegEncoder::Options options,
const SkJpegMetadataEncoder::SegmentList metadataSegments 
)

Definition at line 87 of file SkJpegEncoderImpl.cpp.

89 {
90 auto chooseProc8888 = [&]() {
91 if (kUnpremul_SkAlphaType == srcInfo.alphaType() &&
94 }
95 return (transform_scanline_proc) nullptr;
96 };
97
98 J_COLOR_SPACE jpegColorType = JCS_EXT_RGBA;
99 int numComponents = 0;
100 switch (srcInfo.colorType()) {
102 fProc = chooseProc8888();
103 jpegColorType = JCS_EXT_RGBA;
104 numComponents = 4;
105 break;
107 fProc = chooseProc8888();
108 jpegColorType = JCS_EXT_BGRA;
109 numComponents = 4;
110 break;
113 jpegColorType = JCS_RGB;
114 numComponents = 3;
115 break;
118 return false;
119 }
120
122 jpegColorType = JCS_RGB;
123 numComponents = 3;
124 break;
128 jpegColorType = JCS_GRAYSCALE;
129 numComponents = 1;
130 break;
132 if (kUnpremul_SkAlphaType == srcInfo.alphaType() &&
135 } else {
137 }
138 jpegColorType = JCS_EXT_RGBA;
139 numComponents = 4;
140 break;
141 default:
142 return false;
143 }
144
145 fCInfo.image_width = srcInfo.width();
146 fCInfo.image_height = srcInfo.height();
147 fCInfo.in_color_space = jpegColorType;
148 fCInfo.input_components = numComponents;
149 jpeg_set_defaults(&fCInfo);
150
151 if (numComponents != 1) {
152 switch (options.fDownsample) {
154 SkASSERT(2 == fCInfo.comp_info[0].h_samp_factor);
155 SkASSERT(2 == fCInfo.comp_info[0].v_samp_factor);
156 SkASSERT(1 == fCInfo.comp_info[1].h_samp_factor);
157 SkASSERT(1 == fCInfo.comp_info[1].v_samp_factor);
158 SkASSERT(1 == fCInfo.comp_info[2].h_samp_factor);
159 SkASSERT(1 == fCInfo.comp_info[2].v_samp_factor);
160 break;
162 fCInfo.comp_info[0].h_samp_factor = 2;
163 fCInfo.comp_info[0].v_samp_factor = 1;
164 SkASSERT(1 == fCInfo.comp_info[1].h_samp_factor);
165 SkASSERT(1 == fCInfo.comp_info[1].v_samp_factor);
166 SkASSERT(1 == fCInfo.comp_info[2].h_samp_factor);
167 SkASSERT(1 == fCInfo.comp_info[2].v_samp_factor);
168 break;
170 fCInfo.comp_info[0].h_samp_factor = 1;
171 fCInfo.comp_info[0].v_samp_factor = 1;
172 SkASSERT(1 == fCInfo.comp_info[1].h_samp_factor);
173 SkASSERT(1 == fCInfo.comp_info[1].v_samp_factor);
174 SkASSERT(1 == fCInfo.comp_info[2].h_samp_factor);
175 SkASSERT(1 == fCInfo.comp_info[2].v_samp_factor);
176 break;
177 }
178 }
179
180 initializeCommon(options, metadataSegments);
181 return true;
182}
const char * options
kUnpremul_SkAlphaType
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kR8_unorm_SkColorType
Definition: SkColorType.h:54
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ 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
@ 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
@ 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
static void transform_scanline_to_premul_legacy(char *dst, const char *src, int width, int)
static void transform_scanline_F16_to_8888(char *dst, const char *src, int width, int)
void(* transform_scanline_proc)(char *dst, const char *src, int width, int bpp)
static void transform_scanline_565(char *dst, const char *src, int width, int)
static void transform_scanline_F16_to_premul_8888(char *dst, const char *src, int width, int)
static void transform_scanline_444(char *dst, const char *src, int width, int)
int width() const
Definition: SkImageInfo.h:365
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375
SkColorType colorType() const
Definition: SkImageInfo.h:373
int height() const
Definition: SkImageInfo.h:371

◆ initializeYUV()

bool SkJpegEncoderMgr::initializeYUV ( const SkYUVAPixmapInfo srcInfo,
const SkJpegEncoder::Options options,
const SkJpegMetadataEncoder::SegmentList metadataSegments 
)

Definition at line 221 of file SkJpegEncoderImpl.cpp.

223 {
224 fCInfo.image_width = srcInfo.yuvaInfo().width();
225 fCInfo.image_height = srcInfo.yuvaInfo().height();
226 fCInfo.in_color_space = JCS_YCbCr;
227 fCInfo.input_components = 3;
228 jpeg_set_defaults(&fCInfo);
229
230 // Support no color space conversion.
231 if (srcInfo.yuvColorSpace() != kJPEG_Full_SkYUVColorSpace) {
232 return false;
233 }
234
235 // Support only 8-bit data.
236 switch (srcInfo.dataType()) {
238 break;
239 default:
240 return false;
241 }
242
243 // Support only Y,U,V and Y,UV configurations (they are the only ones supported by
244 // yuva_copy_row).
245 switch (srcInfo.yuvaInfo().planeConfig()) {
248 break;
249 default:
250 return false;
251 }
252
253 // Specify to the encoder to use the same subsampling as the input image. The U and V planes
254 // always have a sampling factor of 1.
255 auto [ssHoriz, ssVert] = SkYUVAInfo::SubsamplingFactors(srcInfo.yuvaInfo().subsampling());
256 fCInfo.comp_info[0].h_samp_factor = ssHoriz;
257 fCInfo.comp_info[0].v_samp_factor = ssVert;
258
259 initializeCommon(options, metadataSegments);
260 return true;
261}
@ kJPEG_Full_SkYUVColorSpace
describes full range
Definition: SkImageInfo.h:69
int width() const
Definition: SkYUVAInfo.h:172
@ kY_U_V
Plane 0: Y, Plane 1: U, Plane 2: V.
@ kY_UV
Plane 0: Y, Plane 1: UV.
int height() const
Definition: SkYUVAInfo.h:173
PlaneConfig planeConfig() const
Definition: SkYUVAInfo.h:160
static std::tuple< int, int > SubsamplingFactors(Subsampling)
Definition: SkYUVAInfo.cpp:29
Subsampling subsampling() const
Definition: SkYUVAInfo.h:161
SkYUVColorSpace yuvColorSpace() const
const SkYUVAInfo & yuvaInfo() const
@ kUnorm8
8 bit unsigned normalized
DataType dataType() const

◆ Make()

static std::unique_ptr< SkJpegEncoderMgr > SkJpegEncoderMgr::Make ( SkWStream stream)
inlinestatic

Definition at line 53 of file SkJpegEncoderImpl.cpp.

53 {
54 return std::unique_ptr<SkJpegEncoderMgr>(new SkJpegEncoderMgr(stream));
55 }

◆ proc()

transform_scanline_proc SkJpegEncoderMgr::proc ( ) const
inline

Definition at line 68 of file SkJpegEncoderImpl.cpp.

68{ return fProc; }

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