Flutter Engine
The Flutter Engine
SkSLConstructorDiagonalMatrix.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_DIAGONAL_MATRIX
9#define SKSL_CONSTRUCTOR_DIAGONAL_MATRIX
10
15
16#include <memory>
17#include <optional>
18#include <utility>
19
20namespace SkSL {
21
22class Context;
23class Type;
24
25/**
26 * Represents the construction of a diagonal matrix, such as `half3x3(n)`.
27 *
28 * These always contain exactly 1 scalar.
29 */
31public:
32 inline static constexpr Kind kIRNodeKind = Kind::kConstructorDiagonalMatrix;
33
34 ConstructorDiagonalMatrix(Position pos, const Type& type, std::unique_ptr<Expression> arg)
35 : INHERITED(pos, kIRNodeKind, &type, std::move(arg)) {}
36
37 static std::unique_ptr<Expression> Make(const Context& context,
39 const Type& type,
40 std::unique_ptr<Expression> arg);
41
42 std::unique_ptr<Expression> clone(Position pos) const override {
43 return std::make_unique<ConstructorDiagonalMatrix>(pos, this->type(), argument()->clone());
44 }
45
46 bool supportsConstantValues() const override { return true; }
47 std::optional<double> getConstantValue(int n) const override;
48
49private:
50 using INHERITED = SingleArgumentConstructor;
51};
52
53} // namespace SkSL
54
55#endif
SkPoint pos
ConstructorDiagonalMatrix(Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
std::unique_ptr< Expression > clone(Position pos) const override
std::optional< double > getConstantValue(int n) const override
std::unique_ptr< Expression > clone() const
const Type & type() const
SingleArgumentConstructor(Position pos, Kind kind, const Type *type, std::unique_ptr< Expression > argument)
std::unique_ptr< Expression > & argument()
ExpressionKind
Definition: SkSLIRNode.h:62
Definition: ref_ptr.h:256