Flutter Engine
The Flutter Engine
SkImageEncoderFns.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 The Android Open Source Project
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 SkImageEncoderFns_DEFINED
9#define SkImageEncoderFns_DEFINED
10
12#include "include/core/SkData.h"
17#include "modules/skcms/skcms.h"
18
19#include <cstring>
20
21typedef void (*transform_scanline_proc)(char* dst, const char* src, int width, int bpp);
22
23static inline void transform_scanline_memcpy(char* dst, const char* src, int width, int bpp) {
24 memcpy(dst, src, width * bpp);
25}
26
27static inline void transform_scanline_A8_to_GrayAlpha(char* dst, const char* src, int width, int) {
28 for (int i = 0; i < width; i++) {
29 *dst++ = 0;
30 *dst++ = *src++;
31 }
32}
33
34
35static void skcms(char* dst, const char* src, int n,
36 skcms_PixelFormat srcFmt, skcms_AlphaFormat srcAlpha,
37 skcms_PixelFormat dstFmt, skcms_AlphaFormat dstAlpha) {
38 SkAssertResult(skcms_Transform(src, srcFmt, srcAlpha, nullptr,
39 dst, dstFmt, dstAlpha, nullptr, n));
40}
41
42static inline void transform_scanline_gray(char* dst, const char* src, int width, int) {
46}
47
48static inline void transform_scanline_565(char* dst, const char* src, int width, int) {
52}
53
54static inline void transform_scanline_RGBX(char* dst, const char* src, int width, int) {
58}
59
60static inline void transform_scanline_BGRX(char* dst, const char* src, int width, int) {
64}
65
66static inline void transform_scanline_444(char* dst, const char* src, int width, int) {
70}
71
72static inline void transform_scanline_rgbA(char* dst, const char* src, int width, int) {
76}
77
78static inline void transform_scanline_bgrA(char* dst, const char* src, int width, int) {
82}
83
84static inline void transform_scanline_to_premul_legacy(char* dst, const char* src, int width, int) {
88}
89
90static inline void transform_scanline_BGRA(char* dst, const char* src, int width, int) {
94}
95
96static inline void transform_scanline_4444(char* dst, const char* src, int width, int) {
100}
101
102static inline void transform_scanline_101010x(char* dst, const char* src, int width, int) {
103 skcms(dst, src, width,
106}
107
108static inline void transform_scanline_1010102(char* dst, const char* src, int width, int) {
109 skcms(dst, src, width,
112}
113
114static inline void transform_scanline_1010102_premul(char* dst, const char* src, int width, int) {
115 skcms(dst, src, width,
118}
119
120static inline void transform_scanline_bgr_101010x(char* dst, const char* src, int width, int) {
121 skcms(dst, src, width,
124}
125
126static inline void transform_scanline_bgra_1010102(char* dst, const char* src, int width, int) {
127 skcms(dst, src, width,
130}
131
132static inline void transform_scanline_bgr_101010x_xr(char* dst, const char* src, int width, int) {
133 skcms(dst, src, width,
136}
137
138static inline void transform_scanline_bgra_10101010_xr(char* dst, const char* src, int width, int) {
139 skcms(dst, src, width,
142}
143
144static inline void transform_scanline_bgra_1010102_premul(char* dst, const char* src, int width, int) {
145 skcms(dst, src, width,
148}
149
150static inline void transform_scanline_F16(char* dst, const char* src, int width, int) {
151 skcms(dst, src, width,
154}
155
156static inline void transform_scanline_F16_premul(char* dst, const char* src, int width, int) {
157 skcms(dst, src, width,
160}
161
162static inline void transform_scanline_F16_to_8888(char* dst, const char* src, int width, int) {
163 skcms(dst, src, width,
166}
167
169 const char* src,
170 int width,
171 int) {
172 skcms(dst, src, width,
175}
176
178 const char* src,
179 int width,
180 int) {
181 skcms(dst, src, width,
184}
185
186static inline void transform_scanline_F32(char* dst, const char* src, int width, int) {
187 skcms(dst, src, width,
190}
191
192static inline void transform_scanline_F32_premul(char* dst, const char* src, int width, int) {
193 skcms(dst, src, width,
196}
197
200 const char* profile_description) {
201 // TODO(ccameron): Remove this check.
202 if (!cs) {
203 return nullptr;
204 }
205
206 if (profile) {
207 return SkWriteICCProfile(profile, profile_description);
208 }
209
210 skcms_Matrix3x3 toXYZD50;
211 if (cs->toXYZD50(&toXYZD50)) {
213 cs->transferFn(&fn);
214 return SkWriteICCProfile(fn, toXYZD50);
215 }
216 return nullptr;
217}
218
221 const char* profile_description) {
222 return icc_from_color_space(info.colorSpace(), profile, profile_description);
223}
224
225#endif // SkImageEncoderFns_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
SK_API sk_sp< SkData > SkWriteICCProfile(const skcms_TransferFunction &, const skcms_Matrix3x3 &toXYZD50)
Definition: SkICC.cpp:682
static void transform_scanline_F16_premul_to_8888(char *dst, const char *src, int width, int)
static void transform_scanline_RGBX(char *dst, const char *src, int width, int)
static void transform_scanline_bgr_101010x(char *dst, const char *src, int width, int)
static void transform_scanline_F32(char *dst, const char *src, int width, int)
static void transform_scanline_F16_premul(char *dst, const char *src, int width, int)
static void transform_scanline_gray(char *dst, const char *src, int width, int)
static void transform_scanline_F16(char *dst, const char *src, int width, int)
static void transform_scanline_bgra_1010102_premul(char *dst, const char *src, int width, int)
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)
static void transform_scanline_bgra_10101010_xr(char *dst, const char *src, int width, int)
static void transform_scanline_1010102(char *dst, const char *src, int width, int)
static void skcms(char *dst, const char *src, int n, skcms_PixelFormat srcFmt, skcms_AlphaFormat srcAlpha, skcms_PixelFormat dstFmt, skcms_AlphaFormat dstAlpha)
static void transform_scanline_BGRX(char *dst, const char *src, int width, int)
static void transform_scanline_bgra_1010102(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_4444(char *dst, const char *src, int width, int)
static void transform_scanline_565(char *dst, const char *src, int width, int)
static void transform_scanline_memcpy(char *dst, const char *src, int width, int bpp)
static void transform_scanline_F16_to_premul_8888(char *dst, const char *src, int width, int)
static void transform_scanline_A8_to_GrayAlpha(char *dst, const char *src, int width, int)
static void transform_scanline_bgr_101010x_xr(char *dst, const char *src, int width, int)
static void transform_scanline_101010x(char *dst, const char *src, int width, int)
static void transform_scanline_444(char *dst, const char *src, int width, int)
static sk_sp< SkData > icc_from_color_space(const SkColorSpace *cs, const skcms_ICCProfile *profile, const char *profile_description)
static void transform_scanline_F32_premul(char *dst, const char *src, int width, int)
static void transform_scanline_1010102_premul(char *dst, const char *src, int width, int)
static void transform_scanline_rgbA(char *dst, const char *src, int width, int)
static void transform_scanline_BGRA(char *dst, const char *src, int width, int)
static void transform_scanline_bgrA(char *dst, const char *src, int width, int)
bool toXYZD50(skcms_Matrix3x3 *toXYZD50) const
void transferFn(float gabcdef[7]) const
dst
Definition: cp.py:12
int32_t width
bool skcms_Transform(const void *src, skcms_PixelFormat srcFmt, skcms_AlphaFormat srcAlpha, const skcms_ICCProfile *srcProfile, void *dst, skcms_PixelFormat dstFmt, skcms_AlphaFormat dstAlpha, const skcms_ICCProfile *dstProfile, size_t nz)
Definition: skcms.cc:2495
skcms_PixelFormat
Definition: skcms_public.h:273
@ skcms_PixelFormat_RGBA_16161616BE
Definition: skcms_public.h:302
@ skcms_PixelFormat_BGR_101010x_XR
Definition: skcms_public.h:321
@ skcms_PixelFormat_RGBA_ffff
Definition: skcms_public.h:317
@ skcms_PixelFormat_RGBA_1010102
Definition: skcms_public.h:292
@ skcms_PixelFormat_BGRA_8888
Definition: skcms_public.h:288
@ skcms_PixelFormat_BGRA_10101010_XR
Definition: skcms_public.h:323
@ skcms_PixelFormat_RGBA_hhhh
Definition: skcms_public.h:312
@ skcms_PixelFormat_RGBA_8888
Definition: skcms_public.h:287
@ skcms_PixelFormat_RGB_888
Definition: skcms_public.h:285
@ skcms_PixelFormat_G_8
Definition: skcms_public.h:276
@ skcms_PixelFormat_BGR_565
Definition: skcms_public.h:280
@ skcms_PixelFormat_ABGR_4444
Definition: skcms_public.h:282
@ skcms_PixelFormat_RGB_161616BE
Definition: skcms_public.h:300
@ skcms_PixelFormat_BGRA_1010102
Definition: skcms_public.h:293
skcms_AlphaFormat
Definition: skcms_public.h:336
@ skcms_AlphaFormat_Unpremul
Definition: skcms_public.h:339
@ skcms_AlphaFormat_PremulAsEncoded
Definition: skcms_public.h:341