Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
graphite
geom
AnalyticBlurMask.h
Go to the documentation of this file.
1
/*
2
* Copyright 2024 Google LLC
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 skgpu_graphite_geom_AnalyticBlurMask_DEFINED
9
#define skgpu_graphite_geom_AnalyticBlurMask_DEFINED
10
11
#include "
include/core/SkM44.h
"
12
#include "
src/gpu/graphite/TextureProxy.h
"
13
#include "
src/gpu/graphite/geom/Rect.h
"
14
15
#include <optional>
16
17
class
SkMatrix
;
18
class
SkRRect
;
19
20
namespace
skgpu::graphite
{
21
22
class
Recorder
;
23
class
Transform
;
24
25
/**
26
* AnalyticBlurMask holds the shader inputs used to do an analytic blur over rects, rrects, or
27
* circles.
28
*/
29
class
AnalyticBlurMask
{
30
public
:
31
enum class
ShapeType
{
32
kRect,
33
kRRect
,
34
kCircle,
35
};
36
37
static_assert
(0 ==
static_cast<
int
>
(
ShapeType::kRect
),
38
"Blur shader code depends on AnalyticBlurMask::ShapeType"
);
39
static_assert
(1 ==
static_cast<
int
>
(
ShapeType::kRRect
),
40
"Blur shader code depends on AnalyticBlurMask::ShapeType"
);
41
static_assert
(2 ==
static_cast<
int
>
(
ShapeType::kCircle
),
42
"Blur shader code depends on AnalyticBlurMask::ShapeType"
);
43
44
AnalyticBlurMask
() =
delete
;
45
46
static
std::optional<AnalyticBlurMask>
Make
(
Recorder
*,
47
const
Transform
& localToDevice,
48
float
deviceSigma,
49
const
SkRRect
& srcRRect);
50
51
const
Rect
&
drawBounds
()
const
{
return
fDrawBounds; }
52
const
SkM44
&
deviceToScaledShape
()
const
{
return
fDevToScaledShape; }
53
const
Rect
&
shapeData
()
const
{
return
fShapeData; }
54
ShapeType
shapeType
()
const
{
return
fShapeType; }
55
const
SkV2
&
blurData
()
const
{
return
fBlurData; }
56
sk_sp<TextureProxy>
refProxy
()
const
{
return
fProxy; }
57
58
private
:
59
AnalyticBlurMask
(
const
Rect
&
drawBounds
,
60
const
SkM44
& devToScaledShape,
61
ShapeType
shapeType
,
62
const
Rect
&
shapeData
,
63
const
SkV2
&
blurData
,
64
sk_sp<TextureProxy>
proxy)
65
: fDrawBounds(
drawBounds
)
66
, fDevToScaledShape(devToScaledShape)
67
, fShapeData(
shapeData
)
68
, fBlurData(
blurData
)
69
, fShapeType(
shapeType
)
70
, fProxy(
std
::move(proxy)) {}
71
72
static
std::optional<AnalyticBlurMask> MakeRect(
Recorder
*,
73
const
SkMatrix
& localToDevice,
74
float
devSigma,
75
const
SkRect
& srcRect);
76
77
static
std::optional<AnalyticBlurMask> MakeCircle(
Recorder
*,
78
const
SkMatrix
& localToDevice,
79
float
devSigma,
80
const
SkRect
& srcRect,
81
const
SkRect
& devRect);
82
83
static
std::optional<AnalyticBlurMask> MakeRRect(
Recorder
* recorder,
84
const
SkMatrix
& localToDevice,
85
float
devSigma,
86
const
SkRRect
& srcRRect,
87
const
SkRRect
& devRRect);
88
89
// Draw bounds in local space.
90
Rect
fDrawBounds;
91
92
// Transforms device-space coordinates to the shape data's space.
93
SkM44
fDevToScaledShape;
94
95
// Shape data, which can define a rectangle, circle, or rounded rectangle.
96
// This data is in a local space defined by the concatenation of the local-to-device matrix and
97
// fDevToScaledShape.
98
Rect
fShapeData;
99
100
// "fBlurData" holds different data depending on the shape type, for the unique needs of the
101
// shape types' respective shaders.
102
// In the rectangle case, it holds:
103
// x = a boolean indicating whether we can use a fast path for sampling the blur integral
104
// because the rectangle is larger than 6*sigma in both dimensions, and
105
// y = the value "1 / (6*sigma)".
106
// In the rounded rectangle case, it holds:
107
// x = the size of the blurred edge, defined as "2*blurRadius + cornerRadius", and
108
// y is unused.
109
// In the circle case, this data is unused.
110
SkV2
fBlurData;
111
112
ShapeType
fShapeType;
113
sk_sp<TextureProxy>
fProxy;
114
};
115
116
}
// namespace skgpu::graphite
117
118
#endif
// skgpu_graphite_geom_AnalyticBlurMask_DEFINED
Rect.h
SkM44.h
kRRect
@ kRRect
Definition:
SkPath_serial.cpp:52
TextureProxy.h
SkM44
Definition:
SkM44.h:150
SkMatrix
Definition:
SkMatrix.h:54
SkRRect
Definition:
SkRRect.h:35
sk_sp
Definition:
SkRefCnt.h:220
skgpu::graphite::AnalyticBlurMask
Definition:
AnalyticBlurMask.h:29
skgpu::graphite::AnalyticBlurMask::ShapeType
ShapeType
Definition:
AnalyticBlurMask.h:31
skgpu::graphite::AnalyticBlurMask::ShapeType::kRect
@ kRect
skgpu::graphite::AnalyticBlurMask::ShapeType::kCircle
@ kCircle
skgpu::graphite::AnalyticBlurMask::ShapeType::kRRect
@ kRRect
skgpu::graphite::AnalyticBlurMask::deviceToScaledShape
const SkM44 & deviceToScaledShape() const
Definition:
AnalyticBlurMask.h:52
skgpu::graphite::AnalyticBlurMask::shapeData
const Rect & shapeData() const
Definition:
AnalyticBlurMask.h:53
skgpu::graphite::AnalyticBlurMask::refProxy
sk_sp< TextureProxy > refProxy() const
Definition:
AnalyticBlurMask.h:56
skgpu::graphite::AnalyticBlurMask::AnalyticBlurMask
AnalyticBlurMask()=delete
skgpu::graphite::AnalyticBlurMask::Make
static std::optional< AnalyticBlurMask > Make(Recorder *, const Transform &localToDevice, float deviceSigma, const SkRRect &srcRRect)
Definition:
AnalyticBlurMask.cpp:48
skgpu::graphite::AnalyticBlurMask::blurData
const SkV2 & blurData() const
Definition:
AnalyticBlurMask.h:55
skgpu::graphite::AnalyticBlurMask::drawBounds
const Rect & drawBounds() const
Definition:
AnalyticBlurMask.h:51
skgpu::graphite::AnalyticBlurMask::shapeType
ShapeType shapeType() const
Definition:
AnalyticBlurMask.h:54
skgpu::graphite::Recorder
Definition:
Recorder.h:75
skgpu::graphite::Rect
Definition:
Rect.h:27
skgpu::graphite::Transform
Definition:
Transform_graphite.h:19
impeller::Rect
TRect< Scalar > Rect
Definition:
rect.h:769
skgpu::graphite
Definition:
BoundsManagerBench.cpp:27
sktext::gpu::Transform
skgpu::graphite::Transform Transform
Definition:
GraphiteVertexFiller.cpp:52
std
Definition:
ref_ptr.h:256
SkRect
Definition:
extension.cpp:13
SkV2
Definition:
SkM44.h:19
Generated on Sun Jun 23 2024 21:56:26 for Flutter Engine by
1.9.4