Flutter Engine
The Flutter Engine
Static Public Member Functions | List of all members
SkColorFilters Class Reference

#include <SkColorFilter.h>

Static Public Member Functions

static sk_sp< SkColorFilterCompose (const sk_sp< SkColorFilter > &outer, sk_sp< SkColorFilter > inner)
 
static sk_sp< SkColorFilterBlend (const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
 
static sk_sp< SkColorFilterBlend (SkColor c, SkBlendMode mode)
 
static sk_sp< SkColorFilterMatrix (const SkColorMatrix &)
 
static sk_sp< SkColorFilterMatrix (const float rowMajor[20])
 
static sk_sp< SkColorFilterHSLAMatrix (const SkColorMatrix &)
 
static sk_sp< SkColorFilterHSLAMatrix (const float rowMajor[20])
 
static sk_sp< SkColorFilterLinearToSRGBGamma ()
 
static sk_sp< SkColorFilterSRGBToLinearGamma ()
 
static sk_sp< SkColorFilterLerp (float t, sk_sp< SkColorFilter > dst, sk_sp< SkColorFilter > src)
 
static sk_sp< SkColorFilterTable (const uint8_t table[256])
 
static sk_sp< SkColorFilterTableARGB (const uint8_t tableA[256], const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256])
 
static sk_sp< SkColorFilterTable (sk_sp< SkColorTable > table)
 
static sk_sp< SkColorFilterLighting (SkColor mul, SkColor add)
 

Detailed Description

Definition at line 90 of file SkColorFilter.h.

Member Function Documentation

◆ Blend() [1/2]

sk_sp< SkColorFilter > SkColorFilters::Blend ( const SkColor4f c,
sk_sp< SkColorSpace colorSpace,
SkBlendMode  mode 
)
static

Definition at line 89 of file SkBlendModeColorFilter.cpp.

91 {
92 if (!SkIsValidMode(mode)) {
93 return nullptr;
94 }
95
96 // First map to sRGB to simplify storage in the actual SkColorFilter instance, staying unpremul
97 // until the final dst color space is known when actually filtering.
98 SkColor4f srgb = map_color<kUnpremul_SkAlphaType>(color, colorSpace.get(), sk_srgb_singleton());
99
100 // Next collapse some modes if possible
101 float alpha = srgb.fA;
102 if (SkBlendMode::kClear == mode) {
105 } else if (SkBlendMode::kSrcOver == mode) {
106 if (0.f == alpha) {
108 } else if (1.f == alpha) {
110 }
111 // else just stay srcover
112 }
113
114 // Finally weed out combinations that are noops, and just return null
115 if (SkBlendMode::kDst == mode ||
116 (0.f == alpha && (SkBlendMode::kSrcOver == mode ||
122 (1.f == alpha && SkBlendMode::kDstIn == mode)) {
123 return nullptr;
124 }
125
127}
@ kDstIn
r = d * sa
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstOver
r = d + (1-da)*s
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kClear
r = 0
SkColorSpace * sk_srgb_singleton()
static bool SkIsValidMode(SkBlendMode mode)
T * get() const
Definition: SkRefCnt.h:303
DlColor color
constexpr SkColor4f kTransparent
Definition: SkColor.h:434
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ Blend() [2/2]

sk_sp< SkColorFilter > SkColorFilters::Blend ( SkColor  c,
SkBlendMode  mode 
)
static

Definition at line 129 of file SkBlendModeColorFilter.cpp.

129 {
130 return Blend(SkColor4f::FromColor(color), /*sRGB*/ nullptr, mode);
131}
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)

◆ Compose()

static sk_sp< SkColorFilter > SkColorFilters::Compose ( const sk_sp< SkColorFilter > &  outer,
sk_sp< SkColorFilter inner 
)
inlinestatic

Definition at line 92 of file SkColorFilter.h.

93 {
94 return outer ? outer->makeComposed(std::move(inner))
95 : std::move(inner);
96 }
sk_sp< SkColorFilter > makeComposed(sk_sp< SkColorFilter > inner) const

◆ HSLAMatrix() [1/2]

sk_sp< SkColorFilter > SkColorFilters::HSLAMatrix ( const float  rowMajor[20])
static

Definition at line 107 of file SkMatrixColorFilter.cpp.

107 {
109}
static sk_sp< SkColorFilter > MakeMatrix(const float array[20], SkMatrixColorFilter::Domain domain)

◆ HSLAMatrix() [2/2]

sk_sp< SkColorFilter > SkColorFilters::HSLAMatrix ( const SkColorMatrix cm)
static

Definition at line 111 of file SkMatrixColorFilter.cpp.

111 {
112 return MakeMatrix(cm.fMat.data(), SkMatrixColorFilter::Domain::kHSLA);
113}

◆ Lerp()

sk_sp< SkColorFilter > SkColorFilters::Lerp ( float  t,
sk_sp< SkColorFilter dst,
sk_sp< SkColorFilter src 
)
static

Definition at line 116 of file SkRuntimeColorFilter.cpp.

117 {
118 using namespace SkKnownRuntimeEffects;
119
120 if (!cf0 && !cf1) {
121 return nullptr;
122 }
123 if (SkIsNaN(weight)) {
124 return nullptr;
125 }
126
127 if (cf0 == cf1) {
128 return cf0; // or cf1
129 }
130
131 if (weight <= 0) {
132 return cf0;
133 }
134 if (weight >= 1) {
135 return cf1;
136 }
137
138 const SkRuntimeEffect* lerpEffect = GetKnownRuntimeEffect(StableKey::kLerp);
139
140 sk_sp<SkColorFilter> inputs[] = {cf0,cf1};
141 return lerpEffect->makeColorFilter(SkData::MakeWithCopy(&weight, sizeof(weight)),
143}
static constexpr bool SkIsNaN(T x)
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
sk_sp< SkColorFilter > makeColorFilter(sk_sp< const SkData > uniforms) const
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ Lighting()

sk_sp< SkColorFilter > SkColorFilters::Lighting ( SkColor  mul,
SkColor  add 
)
static

Create a colorfilter that multiplies the RGB channels by one color, and then adds a second color, pinning the result for each component to [0..255]. The alpha components of the mul and add arguments are ignored.

Definition at line 26 of file SkColorMatrixFilter.cpp.

26 {
27 const SkColor opaqueAlphaMask = SK_ColorBLACK;
28 // omit the alpha and compare only the RGB values
29 if (0 == (add & ~opaqueAlphaMask)) {
30 return SkColorFilters::Blend(mul | opaqueAlphaMask, SkBlendMode::kModulate);
31 }
32
37 1);
38 matrix.postTranslate(byte_to_unit_float(SkColorGetR(add)),
41 0);
43}
@ kModulate
r = s*d
static SkScalar byte_to_unit_float(U8CPU byte)
#define SkColorGetR(color)
Definition: SkColor.h:65
#define SkColorGetG(color)
Definition: SkColor.h:69
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
#define SkColorGetB(color)
Definition: SkColor.h:73
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ LinearToSRGBGamma()

sk_sp< SkColorFilter > SkColorFilters::LinearToSRGBGamma ( )
static

Definition at line 82 of file SkColorSpaceXformColorFilter.cpp.

82 {
85 return sk_ref_sp(gSingleton.get());
86}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeSRGBLinear()

◆ Matrix() [1/2]

sk_sp< SkColorFilter > SkColorFilters::Matrix ( const float  rowMajor[20])
static

Definition at line 99 of file SkMatrixColorFilter.cpp.

◆ Matrix() [2/2]

sk_sp< SkColorFilter > SkColorFilters::Matrix ( const SkColorMatrix cm)
static

Definition at line 103 of file SkMatrixColorFilter.cpp.

103 {
104 return MakeMatrix(cm.fMat.data(), SkMatrixColorFilter::Domain::kRGBA);
105}

◆ SRGBToLinearGamma()

sk_sp< SkColorFilter > SkColorFilters::SRGBToLinearGamma ( )
static

Definition at line 88 of file SkColorSpaceXformColorFilter.cpp.

88 {
91 return sk_ref_sp(gSingleton.get());
92}

◆ Table() [1/2]

sk_sp< SkColorFilter > SkColorFilters::Table ( const uint8_t  table[256])
static

Create a table colorfilter, copying the table into the filter, and applying it to all 4 components. a' = table[a]; r' = table[r]; g' = table[g]; b' = table[b]; Components are operated on in unpremultiplied space. If the incomming colors are premultiplied, they are temporarily unpremultiplied, then the table is applied, and then the result is remultiplied.

Definition at line 55 of file SkTableColorFilter.cpp.

55 {
57}
SI F table(const skcms_Curve *curve, F v)
static sk_sp< SkColorFilter > Table(const uint8_t table[256])
static sk_sp< SkColorTable > Make(const uint8_t table[256])
Definition: SkColorTable.h:29

◆ Table() [2/2]

sk_sp< SkColorFilter > SkColorFilters::Table ( sk_sp< SkColorTable table)
static

Create a table colorfilter that holds a ref to the shared color table.

Definition at line 66 of file SkTableColorFilter.cpp.

66 {
67 if (!table) {
68 return nullptr;
69 }
70 return sk_make_sp<SkTableColorFilter>(std::move(table));
71}

◆ TableARGB()

sk_sp< SkColorFilter > SkColorFilters::TableARGB ( const uint8_t  tableA[256],
const uint8_t  tableR[256],
const uint8_t  tableG[256],
const uint8_t  tableB[256] 
)
static

Create a table colorfilter, with a different table for each component [A, R, G, B]. If a given table is NULL, then it is treated as identity, with the component left unchanged. If a table is not null, then its contents are copied into the filter.

Definition at line 59 of file SkTableColorFilter.cpp.

62 {
63 return SkColorFilters::Table(SkColorTable::Make(tableA, tableR, tableG, tableB));
64}

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