Flutter Engine
The Flutter Engine
Functions
SkAndroidCodec.cpp File Reference
#include "include/codec/SkAndroidCodec.h"
#include "include/codec/SkCodec.h"
#include "include/codec/SkEncodedImageFormat.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkRect.h"
#include "include/core/SkStream.h"
#include "modules/skcms/skcms.h"
#include "src/codec/SkAndroidCodecAdapter.h"
#include "src/codec/SkCodecPriv.h"
#include "src/codec/SkSampledCodec.h"
#include <algorithm>
#include <cstdint>
#include <functional>
#include <utility>

Go to the source code of this file.

Functions

static bool is_valid_sample_size (int sampleSize)
 
static bool cicp_get_primaries (uint8_t primaries, skcms_Matrix3x3 *sk_primaries)
 
static bool cicp_get_transfer_fn (uint8_t transfer_characteristics, skcms_TransferFunction *trfn)
 
static sk_sp< SkColorSpacecicp_get_sk_color_space (uint8_t color_primaries, uint8_t transfer_characteristics, uint8_t matrix_coefficients, uint8_t full_range_flag)
 
static bool supports_any_down_scale (const SkCodec *codec)
 
static bool smaller_than (const SkISize &a, const SkISize &b)
 
static bool strictly_bigger_than (const SkISize &a, const SkISize &b)
 

Function Documentation

◆ cicp_get_primaries()

static bool cicp_get_primaries ( uint8_t  primaries,
skcms_Matrix3x3 sk_primaries 
)
static

Definition at line 34 of file SkAndroidCodec.cpp.

34 {
35 // Rec. ITU-T H.273, Table 2.
36 switch (primaries) {
37 case 0:
38 // Reserved.
39 break;
40 case 1:
41 *sk_primaries = SkNamedGamut::kSRGB;
42 return true;
43 case 2:
44 // Unspecified.
45 break;
46 case 3:
47 // Reserved.
48 break;
49 case 4:
51 0.67f, 0.33f, 0.21f, 0.71f, 0.14f, 0.08f, 0.31f, 0.316f, sk_primaries);
52 case 5:
54 0.64f, 0.33f, 0.29f, 0.60f, 0.15f, 0.06f, 0.3127f, 0.3290f, sk_primaries);
55 case 6:
57 0.630f, 0.340f, 0.310f, 0.595f, 0.155f, 0.070f, 0.3127f, 0.3290f, sk_primaries);
58 case 7:
60 0.630f, 0.340f, 0.310f, 0.595f, 0.155f, 0.070f, 0.3127f, 0.3290f, sk_primaries);
61 case 8:
63 0.681f, 0.319f, 0.243f, 0.692f, 0.145f, 0.049f, 0.310f, 0.316f, sk_primaries);
64 case 9:
65 *sk_primaries = SkNamedGamut::kRec2020;
66 return true;
67 case 10:
69 1.f, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f / 3.f, 1.f / 3.f, sk_primaries);
70 case 11:
72 0.680f, 0.320f, 0.265f, 0.690f, 0.150f, 0.060f, 0.314f, 0.351f, sk_primaries);
73 case 12:
75 0.680f, 0.320f, 0.265f, 0.690f, 0.150f, 0.060f, 0.3127f, 0.3290f, sk_primaries);
76 case 22:
78 0.630f, 0.340f, 0.295f, 0.605f, 0.155f, 0.077f, 0.3127f, 0.3290f, sk_primaries);
79 default:
80 // Reserved.
81 break;
82 }
83 *sk_primaries = SkNamedGamut::kSRGB;
84 return false;
85}
static constexpr skcms_Matrix3x3 kSRGB
Definition: SkColorSpace.h:67
static constexpr skcms_Matrix3x3 kRec2020
Definition: SkColorSpace.h:93
bool skcms_PrimariesToXYZD50(float rx, float ry, float gx, float gy, float bx, float by, float wx, float wy, skcms_Matrix3x3 *toXYZD50)
Definition: skcms.cc:1747

◆ cicp_get_sk_color_space()

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 
)
static

Definition at line 182 of file SkAndroidCodec.cpp.

185 {
186 if (matrix_coefficients != 0) return nullptr;
187
188 if (full_range_flag != 1) return nullptr;
189
191 if (!cicp_get_transfer_fn(transfer_characteristics, &trfn)) return nullptr;
192
193 skcms_Matrix3x3 primaries;
194 if (!cicp_get_primaries(color_primaries, &primaries)) return nullptr;
195
196 return SkColorSpace::MakeRGB(trfn, primaries);
197}
static bool cicp_get_primaries(uint8_t primaries, skcms_Matrix3x3 *sk_primaries)
static bool cicp_get_transfer_fn(uint8_t transfer_characteristics, skcms_TransferFunction *trfn)
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)

◆ cicp_get_transfer_fn()

static bool cicp_get_transfer_fn ( uint8_t  transfer_characteristics,
skcms_TransferFunction trfn 
)
static

Definition at line 87 of file SkAndroidCodec.cpp.

87 {
88 // Rec. ITU-T H.273, Table 3.
89 switch (transfer_characteristics) {
90 case 0:
91 // Reserved.
92 break;
93 case 1:
95 return true;
96 case 2:
97 // Unspecified.
98 break;
99 case 3:
100 // Reserved.
101 break;
102 case 4:
103 *trfn = {2.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
104 return true;
105 case 5:
106 *trfn = {2.8f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
107 return true;
108 case 6:
110 return true;
111 case 7:
112 *trfn = {2.222222222222f,
113 0.899626676224f,
114 0.100373323776f,
115 0.25f,
116 0.091286342118f,
117 0.f,
118 0.f};
119 return true;
120 case 8:
122 return true;
123 case 9:
124 // Logarithmic transfer characteristic (100:1 range).
125 // Not supported by skcms
126 break;
127 case 10:
128 // Logarithmic transfer characteristic (100 * Sqrt( 10 ) : 1 range).
129 // Not supported by skcms
130 break;
131 case 11:
133 break;
134 case 12:
135 // Rec. ITU-R BT.1361-0 extended colour gamut system (historical).
136 // Same as kRec709 on positive values, differs on negative values.
137 // Not supported by skcms
138 break;
139 case 13:
141 return true;
142 case 14:
144 return true;
145 case 15:
147 return true;
148 case 16:
149 // Android expects PQ to match 203 nits to SDR white
150 *trfn = {-2.f,
151 -1.55522297832f,
152 1.86045365631f,
153 32 / 2523.0f,
154 2413 / 128.0f,
155 -2392 / 128.0f,
156 8192 / 1305.0f};
157 return true;
158 case 17:
159 *trfn = {2.6f, 1.034080527699f, 0.f, 0.f, 0.f, 0.f, 0.f};
160 return true;
161 case 18:
162 // Android expects HLG to match 203 nits to SDR white
164 0.314509843f,
165 2.f,
166 2.f,
167 1.f / 0.17883277f,
168 0.28466892f,
169 0.55991073f)) {
170 return true;
171 }
172 break;
173 default:
174 // 19-255 Reserved.
175 break;
176 }
177
179 return false;
180}
static constexpr skcms_TransferFunction kRec2020
Definition: SkColorSpace.h:54
static constexpr skcms_TransferFunction kSRGB
Definition: SkColorSpace.h:45
static constexpr skcms_TransferFunction kLinear
Definition: SkColorSpace.h:51
bool skcms_TransferFunction_makeScaledHLGish(skcms_TransferFunction *tf, float K, float R, float G, float a, float b, float c)
Definition: skcms.cc:204

◆ is_valid_sample_size()

static bool is_valid_sample_size ( int  sampleSize)
static

Definition at line 29 of file SkAndroidCodec.cpp.

29 {
30 // FIXME: As Leon has mentioned elsewhere, surely there is also a maximum sampleSize?
31 return sampleSize > 0;
32}

◆ smaller_than()

static bool smaller_than ( const SkISize a,
const SkISize b 
)
inlinestatic

Definition at line 358 of file SkAndroidCodec.cpp.

358 {
359 return a.width() < b.width() || a.height() < b.height();
360}
static bool b
struct MyStruct a[10]

◆ strictly_bigger_than()

static bool strictly_bigger_than ( const SkISize a,
const SkISize b 
)
inlinestatic

Definition at line 363 of file SkAndroidCodec.cpp.

363 {
364 return a.width() > b.width() && a.height() > b.height();
365}

◆ supports_any_down_scale()

static bool supports_any_down_scale ( const SkCodec codec)
static

Definition at line 350 of file SkAndroidCodec.cpp.

350 {
352}
SkEncodedImageFormat getEncodedFormat() const
Definition: SkCodec.h:292