Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
shaders
SkLocalMatrixShader.h
Go to the documentation of this file.
1
/*
2
* Copyright 2014 Google Inc.
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 SkLocalMatrixShader_DEFINED
9
#define SkLocalMatrixShader_DEFINED
10
11
#include "
include/core/SkFlattenable.h
"
12
#include "
include/core/SkMatrix.h
"
13
#include "
include/core/SkRefCnt.h
"
14
#include "
include/core/SkShader.h
"
15
#include "
include/core/SkTypes.h
"
16
#include "
src/shaders/SkShaderBase.h
"
17
18
#include <type_traits>
19
#include <utility>
20
21
class
SkArenaAlloc
;
22
class
SkImage
;
23
class
SkReadBuffer
;
24
class
SkWriteBuffer
;
25
enum class
SkTileMode
;
26
struct
SkStageRec
;
27
28
class
SkLocalMatrixShader
final :
public
SkShaderBase
{
29
public
:
30
template
<
typename
T
,
typename
... Args>
31
static
std::enable_if_t<std::is_base_of_v<SkShader, T>,
sk_sp<SkShader>
>
32
MakeWrapped
(
const
SkMatrix
*
localMatrix
, Args&&...
args
) {
33
auto
t = sk_make_sp<T>(std::forward<Args>(
args
)...);
34
if
(
localMatrix
) {
35
return
t->makeWithLocalMatrix(*
localMatrix
);
36
}
37
return
t;
38
}
39
40
SkLocalMatrixShader
(
sk_sp<SkShader>
wrapped
,
const
SkMatrix
&
localMatrix
)
41
: fLocalMatrix(
localMatrix
), fWrappedShader(
std
::move(
wrapped
)) {}
42
43
bool
isOpaque
()
const override
{
return
as_SB
(fWrappedShader)->
isOpaque
(); }
44
45
bool
isConstant
()
const override
;
46
GradientType
asGradient
(GradientInfo*
info
,
SkMatrix
*
localMatrix
)
const override
;
47
ShaderType
type
()
const override
{
return
ShaderType::kLocalMatrix; }
48
49
sk_sp<SkShader>
makeAsALocalMatrixShader
(
SkMatrix
*
localMatrix
)
const override
{
50
if
(
localMatrix
) {
51
*
localMatrix
= fLocalMatrix;
52
}
53
return
fWrappedShader;
54
}
55
56
const
SkMatrix
&
localMatrix
()
const
{
return
fLocalMatrix; }
57
sk_sp<SkShader>
wrappedShader
()
const
{
return
fWrappedShader; }
58
59
protected
:
60
void
flatten
(
SkWriteBuffer
&)
const override
;
61
62
#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
63
Context
* onMakeContext(
const
ContextRec&,
SkArenaAlloc
*)
const override
;
64
#endif
65
66
SkImage
*
onIsAImage
(
SkMatrix
* matrix,
SkTileMode
* mode)
const override
;
67
68
bool
appendStages
(
const
SkStageRec
&,
const
SkShaders::MatrixRec
&)
const override
;
69
70
private
:
71
SK_FLATTENABLE_HOOKS
(
SkLocalMatrixShader
)
72
73
SkMatrix
fLocalMatrix;
74
sk_sp<SkShader>
fWrappedShader;
75
};
76
77
/**
78
* Replaces the CTM when used. Created to support clipShaders, which have to be evaluated
79
* using the CTM that was present at the time they were specified (which may be different
80
* from the CTM at the time something is drawn through the clip.
81
*/
82
class
SkCTMShader
final :
public
SkShaderBase
{
83
public
:
84
SkCTMShader
(
sk_sp<SkShader>
proxy,
const
SkMatrix
&
ctm
);
85
86
bool
isOpaque
()
const override
{
return
fProxyShader->
isOpaque
(); }
87
88
bool
isConstant
()
const override
;
89
GradientType
asGradient
(GradientInfo*
info
,
SkMatrix
* localMatrix)
const override
;
90
91
ShaderType
type
()
const override
{
return
ShaderType::kCTM; }
92
93
const
SkMatrix
&
ctm
()
const
{
return
fCTM; }
94
sk_sp<SkShader>
proxyShader
()
const
{
return
fProxyShader; }
95
96
protected
:
97
void
flatten
(
SkWriteBuffer
&)
const override
{
SkASSERT
(
false
); }
98
99
bool
appendStages
(
const
SkStageRec
& rec,
const
SkShaders::MatrixRec
&)
const override
;
100
101
private
:
102
SK_FLATTENABLE_HOOKS
(
SkCTMShader
)
103
104
sk_sp<SkShader>
fProxyShader;
105
SkMatrix
fCTM;
106
};
107
108
#endif
info
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition
DM.cpp:213
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkFlattenable.h
SK_FLATTENABLE_HOOKS
#define SK_FLATTENABLE_HOOKS(type)
Definition
SkFlattenable.h:108
SkMatrix.h
SkRefCnt.h
SkShaderBase.h
as_SB
SkShaderBase * as_SB(SkShader *shader)
Definition
SkShaderBase.h:412
SkShader.h
SkTileMode
SkTileMode
Definition
SkTileMode.h:13
SkTypes.h
wrapped
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
Definition
TextureProxyTest.cpp:112
SkArenaAlloc
Definition
SkArenaAlloc.h:105
SkCTMShader
Definition
SkLocalMatrixShader.h:82
SkCTMShader::flatten
void flatten(SkWriteBuffer &) const override
Definition
SkLocalMatrixShader.h:97
SkCTMShader::isOpaque
bool isOpaque() const override
Definition
SkLocalMatrixShader.h:86
SkCTMShader::ctm
const SkMatrix & ctm() const
Definition
SkLocalMatrixShader.h:93
SkCTMShader::appendStages
bool appendStages(const SkStageRec &rec, const SkShaders::MatrixRec &) const override
Definition
SkLocalMatrixShader.cpp:80
SkCTMShader::isConstant
bool isConstant() const override
Definition
SkLocalMatrixShader.cpp:71
SkCTMShader::asGradient
GradientType asGradient(GradientInfo *info, SkMatrix *localMatrix) const override
Definition
SkLocalMatrixShader.cpp:75
SkCTMShader::proxyShader
sk_sp< SkShader > proxyShader() const
Definition
SkLocalMatrixShader.h:94
SkCTMShader::type
ShaderType type() const override
Definition
SkLocalMatrixShader.h:91
SkImage
Definition
SkImage.h:272
SkLocalMatrixShader
Definition
SkLocalMatrixShader.h:28
SkLocalMatrixShader::isConstant
bool isConstant() const override
Definition
SkLocalMatrixShader.cpp:16
SkLocalMatrixShader::localMatrix
const SkMatrix & localMatrix() const
Definition
SkLocalMatrixShader.h:56
SkLocalMatrixShader::appendStages
bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const override
Definition
SkLocalMatrixShader.cpp:61
SkLocalMatrixShader::isOpaque
bool isOpaque() const override
Definition
SkLocalMatrixShader.h:43
SkLocalMatrixShader::makeAsALocalMatrixShader
sk_sp< SkShader > makeAsALocalMatrixShader(SkMatrix *localMatrix) const override
Definition
SkLocalMatrixShader.h:49
SkLocalMatrixShader::onIsAImage
SkImage * onIsAImage(SkMatrix *matrix, SkTileMode *mode) const override
Definition
SkLocalMatrixShader.cpp:51
SkLocalMatrixShader::SkLocalMatrixShader
SkLocalMatrixShader(sk_sp< SkShader > wrapped, const SkMatrix &localMatrix)
Definition
SkLocalMatrixShader.h:40
SkLocalMatrixShader::MakeWrapped
static std::enable_if_t< std::is_base_of_v< SkShader, T >, sk_sp< SkShader > > MakeWrapped(const SkMatrix *localMatrix, Args &&... args)
Definition
SkLocalMatrixShader.h:32
SkLocalMatrixShader::flatten
void flatten(SkWriteBuffer &) const override
Definition
SkLocalMatrixShader.cpp:39
SkLocalMatrixShader::asGradient
GradientType asGradient(GradientInfo *info, SkMatrix *localMatrix) const override
Definition
SkLocalMatrixShader.cpp:20
SkLocalMatrixShader::type
ShaderType type() const override
Definition
SkLocalMatrixShader.h:47
SkLocalMatrixShader::wrappedShader
sk_sp< SkShader > wrappedShader() const
Definition
SkLocalMatrixShader.h:57
SkMatrix
Definition
SkMatrix.h:54
SkReadBuffer
Definition
SkReadBuffer.h:52
SkShaderBase
Definition
SkShaderBase.h:186
SkShaderBase::ShaderType
ShaderType
Definition
SkShaderBase.h:199
SkShaderBase::GradientType
GradientType
Definition
SkShaderBase.h:207
SkShader::isOpaque
virtual bool isOpaque() const
Definition
SkShader.h:44
SkShaders::MatrixRec
Definition
SkShaderBase.h:57
SkWriteBuffer
Definition
SkWriteBuffer.h:41
sk_sp
Definition
SkRefCnt.h:220
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition
fl_event_channel.h:89
std
Definition
ref_ptr.h:256
T
#define T
Definition
precompiler.cc:65
Context
Definition
SerialProcsTest.cpp:126
SkStageRec
Definition
SkEffectPriv.h:20
Generated on Fri Apr 26 2024 06:17:28 for Flutter Engine by
1.9.8