Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
include
core
SkColorFilter.h
Go to the documentation of this file.
1
/*
2
* Copyright 2006 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 SkColorFilter_DEFINED
9
#define SkColorFilter_DEFINED
10
11
#include "
include/core/SkColor.h
"
12
#include "
include/core/SkFlattenable.h
"
13
#include "
include/core/SkRefCnt.h
"
14
#include "
include/private/base/SkAPI.h
"
15
16
#include <cstddef>
17
#include <cstdint>
18
#include <utility>
19
20
class
SkColorMatrix
;
21
class
SkColorSpace
;
22
class
SkColorTable
;
23
24
enum class
SkBlendMode
;
25
struct
SkDeserialProcs
;
26
27
/**
28
* ColorFilters are optional objects in the drawing pipeline. When present in
29
* a paint, they are called with the "src" colors, and return new colors, which
30
* are then passed onto the next stage (either ImageFilter or Xfermode).
31
*
32
* All subclasses are required to be reentrant-safe : it must be legal to share
33
* the same instance between several threads.
34
*/
35
class
SK_API
SkColorFilter
:
public
SkFlattenable
{
36
public
:
37
/** If the filter can be represented by a source color plus Mode, this
38
* returns true, and sets (if not NULL) the color and mode appropriately.
39
* If not, this returns false and ignores the parameters.
40
*/
41
bool
asAColorMode(
SkColor
*
color
,
SkBlendMode
* mode)
const
;
42
43
/** If the filter can be represented by a 5x4 matrix, this
44
* returns true, and sets the matrix appropriately.
45
* If not, this returns false and ignores the parameter.
46
*/
47
bool
asAColorMatrix(
float
matrix[20])
const
;
48
49
// Returns true if the filter is guaranteed to never change the alpha of a color it filters.
50
bool
isAlphaUnchanged()
const
;
51
52
/**
53
* Applies this filter to the input color. This function does no color management.
54
*
55
* DEPRECATED: Please use filterColor4f instead. That function supports higher precision,
56
* wide-gamut color, and is explicit about the color space of the input and output.
57
*/
58
SkColor
filterColor(
SkColor
)
const
;
59
60
/**
61
* Converts the src color (in src colorspace), into the dst colorspace,
62
* then applies this filter to it, returning the filtered color in the dst colorspace.
63
*/
64
SkColor4f
filterColor4f(
const
SkColor4f
& srcColor,
SkColorSpace
* srcCS,
65
SkColorSpace
* dstCS)
const
;
66
67
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
68
* this filter, applied to the output of the inner filter.
69
*
70
* result = this(inner(...))
71
*/
72
sk_sp<SkColorFilter>
makeComposed(
sk_sp<SkColorFilter>
inner)
const
;
73
74
/** Return a colorfilter that will compute this filter in a specific color space. By default all
75
* filters operate in the destination (surface) color space. This allows filters like Blend and
76
* Matrix, or runtime color filters to perform their math in a known space.
77
*/
78
sk_sp<SkColorFilter>
makeWithWorkingColorSpace(
sk_sp<SkColorSpace>
)
const
;
79
80
static
sk_sp<SkColorFilter>
Deserialize
(
const
void
* data,
size_t
size,
81
const
SkDeserialProcs
* procs =
nullptr
);
82
83
private
:
84
SkColorFilter
() =
default
;
85
friend
class
SkColorFilterBase
;
86
87
using
INHERITED
=
SkFlattenable
;
88
};
89
90
class
SK_API
SkColorFilters
{
91
public
:
92
static
sk_sp<SkColorFilter>
Compose
(
const
sk_sp<SkColorFilter>
& outer,
93
sk_sp<SkColorFilter>
inner) {
94
return
outer ? outer->makeComposed(std::move(inner))
95
: std::move(inner);
96
}
97
98
// Blends between the constant color (src) and input color (dst) based on the SkBlendMode.
99
// If the color space is null, the constant color is assumed to be defined in sRGB.
100
static
sk_sp<SkColorFilter>
Blend(
const
SkColor4f
& c,
sk_sp<SkColorSpace>
,
SkBlendMode
mode);
101
static
sk_sp<SkColorFilter>
Blend(
SkColor
c,
SkBlendMode
mode);
102
103
static
sk_sp<SkColorFilter>
Matrix(
const
SkColorMatrix
&);
104
static
sk_sp<SkColorFilter>
Matrix(
const
float
rowMajor[20]);
105
106
// A version of Matrix which operates in HSLA space instead of RGBA.
107
// I.e. HSLA-to-RGBA(Matrix(RGBA-to-HSLA(input))).
108
static
sk_sp<SkColorFilter>
HSLAMatrix(
const
SkColorMatrix
&);
109
static
sk_sp<SkColorFilter>
HSLAMatrix(
const
float
rowMajor[20]);
110
111
static
sk_sp<SkColorFilter>
LinearToSRGBGamma();
112
static
sk_sp<SkColorFilter>
SRGBToLinearGamma();
113
static
sk_sp<SkColorFilter>
Lerp(
float
t,
sk_sp<SkColorFilter>
dst,
sk_sp<SkColorFilter>
src);
114
115
/**
116
* Create a table colorfilter, copying the table into the filter, and
117
* applying it to all 4 components.
118
* a' = table[a];
119
* r' = table[r];
120
* g' = table[g];
121
* b' = table[b];
122
* Components are operated on in unpremultiplied space. If the incomming
123
* colors are premultiplied, they are temporarily unpremultiplied, then
124
* the table is applied, and then the result is remultiplied.
125
*/
126
static
sk_sp<SkColorFilter>
Table(
const
uint8_t
table
[256]);
127
128
/**
129
* Create a table colorfilter, with a different table for each
130
* component [A, R, G, B]. If a given table is NULL, then it is
131
* treated as identity, with the component left unchanged. If a table
132
* is not null, then its contents are copied into the filter.
133
*/
134
static
sk_sp<SkColorFilter>
TableARGB(
const
uint8_t tableA[256],
135
const
uint8_t tableR[256],
136
const
uint8_t tableG[256],
137
const
uint8_t tableB[256]);
138
139
/**
140
* Create a table colorfilter that holds a ref to the shared color table.
141
*/
142
static
sk_sp<SkColorFilter>
Table(
sk_sp<SkColorTable>
table
);
143
144
/**
145
* Create a colorfilter that multiplies the RGB channels by one color, and
146
* then adds a second color, pinning the result for each component to
147
* [0..255]. The alpha components of the mul and add arguments
148
* are ignored.
149
*/
150
static
sk_sp<SkColorFilter>
Lighting(
SkColor
mul,
SkColor
add);
151
152
private
:
153
SkColorFilters
() =
delete
;
154
};
155
156
#endif
color
SkColor4f color
Definition
ImageShaderTest.cpp:28
SkAPI.h
SK_API
#define SK_API
Definition
SkAPI.h:35
SkBlendMode
SkBlendMode
Definition
SkBlendMode.h:38
SkColor.h
SkColor
uint32_t SkColor
Definition
SkColor.h:37
SkFlattenable.h
SkRefCnt.h
table
SI F table(const skcms_Curve *curve, F v)
Definition
Transform_inl.h:604
SkColorFilterBase
Definition
SkColorFilterBase.h:35
SkColorFilter
Definition
SkColorFilter.h:35
SkColorFilters
Definition
SkColorFilter.h:90
SkColorFilters::Compose
static sk_sp< SkColorFilter > Compose(const sk_sp< SkColorFilter > &outer, sk_sp< SkColorFilter > inner)
Definition
SkColorFilter.h:92
SkColorMatrix
Definition
SkColorMatrix.h:18
SkColorSpace
Definition
SkColorSpace.h:107
SkColorTable
Definition
SkColorTable.h:25
SkFlattenable
Definition
SkFlattenable.h:28
SkFlattenable::SkFlattenable
SkFlattenable()
Definition
SkFlattenable.h:43
SkFlattenable::Deserialize
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
Definition
SkFlattenable.cpp:151
sk_sp
Definition
SkRefCnt.h:220
SkColor4f
SkDeserialProcs
Definition
SkSerialProcs.h:97
Generated on Fri Apr 26 2024 06:16:10 for Flutter Engine by
1.9.8