FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
skia-python/src/skia/MaskFilter.cpp at main · skia-python/skia-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
skia-python
/
skia-python
Public
Notifications
You must be signed in to change notification settings
Fork
52
Star
322
Code
Issues
44
Pull requests
6
Discussions
Actions
Projects
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
skia-python
/
src
/
skia
/
MaskFilter.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
152 lines (134 loc) · 5.36 KB
Breadcrumbs
skia-python
/
src
/
skia
/
MaskFilter.cpp
Copy path
File metadata and controls
152 lines (134 loc) · 5.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#
include
"
common.h
"
#
include
<
include/core/SkBlurTypes.h
>
#
include
<
include/core/SkCoverageMode.h
>
#
include
<
include/effects/SkShaderMaskFilter.h
>
#
include
<
include/effects/SkTableMaskFilter.h
>
#
include
<
include/effects/SkBlurMaskFilter.h
>
#
include
<
pybind11/stl.h
>
void
initMaskFilter
(py::
module
&m) {
py::enum_<SkBlurStyle>(m,
"
BlurStyle
"
,
py::arithmetic
())
.
value
(
"
kNormal_BlurStyle
"
, SkBlurStyle::
kNormal_SkBlurStyle
,
"
fuzzy inside and outside
"
)
.
value
(
"
kSolid_BlurStyle
"
, SkBlurStyle::
kSolid_SkBlurStyle
,
"
solid inside, fuzzy outside
"
)
.
value
(
"
kOuter_BlurStyle
"
, SkBlurStyle::
kOuter_SkBlurStyle
,
"
nothing inside, fuzzy outside
"
)
.
value
(
"
kInner_BlurStyle
"
, SkBlurStyle::
kInner_SkBlurStyle
,
"
fuzzy inside, nothing outside
"
)
.
value
(
"
kLastEnum_BlurStyle
"
, SkBlurStyle::
kLastEnum_SkBlurStyle
,
"
"
)
.
export_values
();
py::enum_<SkCoverageMode>(m,
"
ConvergeMode
"
,
R"docstring(
Describes geometric operations (ala :py:class:`Region.Op`) that can be
applied to coverage bytes.
These can be thought of as variants of porter-duff (:py:class:`BlendMode`)
modes, but only applied to the alpha channel.
See :py:class:`MaskFilter` for ways to use these when combining two
different masks.
)docstring"
)
.
value
(
"
kUnion
"
, SkCoverageMode::
kUnion
)
.
value
(
"
kIntersect
"
, SkCoverageMode::
kIntersect
)
.
value
(
"
kDifference
"
, SkCoverageMode::
kDifference
)
.
value
(
"
kReverseDifference
"
, SkCoverageMode::
kReverseDifference
)
.
value
(
"
kXor
"
, SkCoverageMode::
kXor
)
.
value
(
"
kLast
"
, SkCoverageMode::
kLast
)
.
export_values
();
py::class_<SkMaskFilter, sk_sp<SkMaskFilter>, SkFlattenable>(
m,
"
MaskFilter
"
,
R"docstring(
:py:class:`MaskFilter` is the base class for object that perform
transformations on the mask before drawing it.
An example subclass is Blur.
.. rubric:: Subclasses
.. autosummary::
:nosignatures:
~skia.ShaderMaskFilter
~skia.TableMaskFilter
)docstring"
)
.
def_static
(
"
MakeBlur
"
, &SkMaskFilter::MakeBlur,
R"docstring(
Create a blur maskfilter.
:param skia.BlurStyle style: The :py:class:`BlurStyle` to use
:param float sigma: Standard deviation of the Gaussian blur to apply.
Must be > 0.
:param bool respectCTM: if true the blur's sigma is modified by the CTM.
:return: The new blur maskfilter
)docstring"
,
py::arg
(
"
style
"
),
py::arg
(
"
sigma
"
),
py::arg
(
"
respectCTM
"
) =
true
)
.
def_static
(
"
Deserialize
"
,
[] (py::buffer b) {
auto
info = b.
request
();
return
SkMaskFilter::Deserialize
(
info.
ptr
, info.
shape
[
0
] * info.
strides
[
0
]);
},
py::arg
(
"
data
"
))
;
py::class_<SkBlurMaskFilter>(m,
"
BlurMaskFilter
"
)
//
.def_static("MakeEmboss",
//
[] (SkScalar blurSigma, const std::vector<SkScalar>& direction,
//
SkScalar ambient, SkScalar specular) {
//
if (direction.size() != 3)
//
throw std::runtime_error("direction must have 3 elements.");
//
return SkBlurMaskFilter::MakeEmboss(
//
blurSigma, &direction[0], ambient, specular);
//
},
//
py::arg("blurSigma"), py::arg("direction"), py::arg("ambient"),
//
py::arg("specular"))
;
py::class_<SkShaderMaskFilter>(m,
"
ShaderMaskFilter
"
)
.
def_static
(
"
Make
"
,
[] (
const
SkShader& shader) {
auto
data = shader.
serialize
();
auto
clone =
SkShader::Deserialize
(
shader.
getFlattenableType
(), data->
data
(), data->
size
());
return
SkShaderMaskFilter::Make
(sk_sp<SkShader>(
reinterpret_cast
<SkShader*>(clone.
release
())));
},
py::arg
(
"
shader
"
));
py::class_<SkTableMaskFilter>(m,
"
TableMaskFilter
"
,
R"docstring(
Applies a table lookup on each of the alpha values in the mask.
Helper methods create some common tables (e.g. gamma, clipping)
)docstring"
)
.
def_static
(
"
MakeGammaTable
"
,
[] (SkScalar gamma) {
std::vector<
uint8_t
>
table
(
256
);
SkTableMaskFilter::MakeGammaTable
(&table[
0
], gamma);
return
py::cast
(table);
},
R"docstring(
Utility that sets the gamma table.
:return: gamma table
:rtype: List[int]
)docstring"
,
py::arg
(
"
gamma
"
))
.
def_static
(
"
MakeClipTable
"
,
[] (
uint8_t
min,
uint8_t
max) {
std::vector<
uint8_t
>
table
(
256
);
SkTableMaskFilter::MakeClipTable
(&table[
0
], min, max);
return
py::cast
(table);
},
R"docstring(
Utility that creates a clipping table: clamps values below min to 0 and
above max to 255, and rescales the remaining into 0..255.
:return: clipping table
:rtype: List[int]
)docstring"
,
py::arg
(
"
min
"
),
py::arg
(
"
max
"
))
.
def_static
(
"
Create
"
,
[] (std::vector<
uint8_t
>& table) {
return
sk_sp<SkMaskFilter>(
SkTableMaskFilter::Create
(&table[
0
]));
},
py::arg
(
"
table
"
))
.
def_static
(
"
CreateGamma
"
,
[] (SkScalar gamma) {
return
sk_sp<SkMaskFilter>(
SkTableMaskFilter::CreateGamma
(gamma));
},
py::arg
(
"
gamma
"
))
.
def_static
(
"
CreateClip
"
,
[] (
uint8_t
min,
uint8_t
max) {
return
sk_sp<SkMaskFilter>(
SkTableMaskFilter::CreateClip
(min, max));
},
py::arg
(
"
min
"
),
py::arg
(
"
max
"
));
}
Back
|
FazBrowse Home
|
New Git URL