Flutter Engine
The Flutter Engine
SkSLConstructorCompound.h
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#ifndef SKSL_CONSTRUCTOR_COMPOUND
9#define SKSL_CONSTRUCTOR_COMPOUND
10
16
17#include <memory>
18#include <utility>
19
20namespace SkSL {
21
22class Context;
23class Type;
24
25/**
26 * Represents a vector or matrix that is composed from other expressions, such as
27 * `half3(pos.xy, 1)` or `mat3(a.xyz, b.xyz, 0, 0, 1)`
28 *
29 * These can contain a mix of scalars and aggregates. The total number of scalar values inside the
30 * constructor must always match the type's slot count. (e.g. `pos.xy` consumes two slots.)
31 * The inner values must have the same component type as the vector/matrix.
32 */
34public:
35 inline static constexpr Kind kIRNodeKind = Kind::kConstructorCompound;
36
38 : INHERITED(pos, kIRNodeKind, &type, std::move(args)) {}
39
40 static std::unique_ptr<Expression> Make(const Context& context,
42 const Type& type,
44
45 static std::unique_ptr<Expression> MakeFromConstants(const Context& context,
47 const Type& type,
48 const double values[]);
49
50 std::unique_ptr<Expression> clone(Position pos) const override {
51 return std::make_unique<ConstructorCompound>(pos, this->type(), this->arguments().clone());
52 }
53
54private:
55 using INHERITED = MultiArgumentConstructor;
56};
57
58} // namespace SkSL
59
60#endif
SkPoint pos
static std::unique_ptr< Expression > MakeFromConstants(const Context &context, Position pos, const Type &type, const double values[])
static constexpr Kind kIRNodeKind
std::unique_ptr< Expression > clone(Position pos) const override
ConstructorCompound(Position pos, const Type &type, ExpressionArray args)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, ExpressionArray args)
std::unique_ptr< Expression > clone() const
const Type & type() const
ExpressionArray & arguments()
MultiArgumentConstructor(Position pos, Kind kind, const Type *type, ExpressionArray arguments)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
ExpressionKind
Definition: SkSLIRNode.h:62
Definition: ref_ptr.h:256