Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
sksl
ir
SkSLChildCall.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2021 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
#include "
src/sksl/ir/SkSLChildCall.h
"
9
10
#include "
include/core/SkTypes.h
"
11
#include "
include/private/base/SkTArray.h
"
12
#include "
src/sksl/SkSLBuiltinTypes.h
"
13
#include "
src/sksl/SkSLContext.h
"
14
#include "
src/sksl/SkSLOperator.h
"
15
#include "
src/sksl/SkSLString.h
"
16
#include "
src/sksl/ir/SkSLType.h
"
17
#include "
src/sksl/ir/SkSLVariable.h
"
18
19
using namespace
skia_private
;
20
21
namespace
SkSL
{
22
23
std::unique_ptr<Expression>
ChildCall::clone
(
Position
pos
)
const
{
24
return
std::make_unique<ChildCall>(
pos
, &this->
type
(), &this->
child
(),
25
this->
arguments
().
clone
());
26
}
27
28
std::string
ChildCall::description
(
OperatorPrecedence
)
const
{
29
std::string
result
= std::string(this->
child
().
name
()) +
".eval("
;
30
auto
separator =
SkSL::String::Separator
();
31
for
(
const
std::unique_ptr<Expression>& arg : this->
arguments
()) {
32
result += separator();
33
result
+= arg->description(
OperatorPrecedence::kSequence
);
34
}
35
result
+=
")"
;
36
return
result
;
37
}
38
39
[[maybe_unused]]
static
bool
call_signature_is_valid
(
const
Context
& context,
40
const
Variable
& child,
41
const
ExpressionArray
& arguments) {
42
const
Type
* half4 = context.
fTypes
.
fHalf4
.get();
43
const
Type
*
float2
= context.
fTypes
.
fFloat2
.get();
44
45
auto
params
= [&]() ->
STArray<2, const Type*>
{
46
switch
(child.
type
().
typeKind
()) {
47
case
Type::TypeKind::kBlender
:
return
{ half4, half4 };
48
case
Type::TypeKind::kColorFilter
:
return
{ half4 };
49
case
Type::TypeKind::kShader
:
return
{
float2
};
50
default
:
51
SkUNREACHABLE
;
52
}
53
}();
54
55
if
(
params
.size() != arguments.
size
()) {
56
return
false
;
57
}
58
for
(
int
i = 0; i < arguments.
size
(); i++) {
59
if
(!arguments[i]->
type
().matches(*
params
[i])) {
60
return
false
;
61
}
62
}
63
return
true
;
64
}
65
66
std::unique_ptr<Expression>
ChildCall::Make
(
const
Context
& context,
67
Position
pos
,
68
const
Type
* returnType,
69
const
Variable
& child,
70
ExpressionArray
arguments) {
71
SkASSERT
(
call_signature_is_valid
(context,
child
,
arguments
));
72
return
std::make_unique<ChildCall>(
pos
, returnType, &
child
, std::move(
arguments
));
73
}
74
75
}
// namespace SkSL
pos
SkPoint pos
Definition
ImageShaderTest.cpp:27
SkUNREACHABLE
#define SkUNREACHABLE
Definition
SkAssert.h:135
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkSLBuiltinTypes.h
SkSLChildCall.h
SkSLContext.h
SkSLOperator.h
SkSLString.h
SkSLType.h
SkSLVariable.h
SkTArray.h
SkTypes.h
SkSL::BuiltinTypes::fFloat2
const std::unique_ptr< Type > fFloat2
Definition
SkSLBuiltinTypes.h:25
SkSL::BuiltinTypes::fHalf4
const std::unique_ptr< Type > fHalf4
Definition
SkSLBuiltinTypes.h:32
SkSL::ChildCall::Make
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type *returnType, const Variable &child, ExpressionArray arguments)
Definition
SkSLChildCall.cpp:66
SkSL::ChildCall::arguments
ExpressionArray & arguments()
Definition
SkSLChildCall.h:51
SkSL::ChildCall::child
const Variable & child() const
Definition
SkSLChildCall.h:47
SkSL::Context
Definition
SkSLContext.h:24
SkSL::Context::fTypes
const BuiltinTypes & fTypes
Definition
SkSLContext.h:30
SkSL::ExpressionArray
Definition
SkSLDefines.h:26
SkSL::Expression::type
virtual const Type & type() const
Definition
SkSLExpression.h:44
SkSL::Expression::clone
std::unique_ptr< Expression > clone() const
Definition
SkSLExpression.h:126
SkSL::Expression::description
std::string description() const final
Definition
SkSLExpression.cpp:17
SkSL::Position
Definition
SkSLPosition.h:18
SkSL::Symbol::type
const Type & type() const
Definition
SkSLSymbol.h:42
SkSL::Type::typeKind
TypeKind typeKind() const
Definition
SkSLType.h:283
SkSL::Type::TypeKind::kBlender
@ kBlender
SkSL::Type::TypeKind::kColorFilter
@ kColorFilter
SkSL::Type::TypeKind::kShader
@ kShader
SkSL::Variable
Definition
SkSLVariable.h:48
skia_private::STArray
Definition
SkTArray.h:744
skia_private::TArray::size
int size() const
Definition
SkTArray.h:416
params
const EmbeddedViewParams * params
Definition
embedder_external_view_embedder.cc:138
type
uint8_t type
Definition
fl_standard_message_codec_test.cc:1115
result
GAsyncResult * result
Definition
fl_text_input_plugin.cc:106
name
const char * name
Definition
fuchsia.cc:50
SkSL::String::Separator
std::string void void auto Separator()
Definition
SkSLString.h:30
SkSL
Definition
SkCapabilities.h:15
SkSL::call_signature_is_valid
static bool call_signature_is_valid(const Context &context, const Variable &child, const ExpressionArray &arguments)
Definition
SkSLChildCall.cpp:39
SkSL::OperatorPrecedence
OperatorPrecedence
Definition
SkSLOperator.h:57
SkSL::OperatorPrecedence::kSequence
@ kSequence
Type
Definition
asyncrescaleandread.cpp:530
skia_private
Definition
SkTArray.h:32
skvx::Vec
Definition
SkVx.h:83
Generated on Fri Apr 26 2024 06:17:30 for Flutter Engine by
1.9.8