Flutter Engine
The Flutter Engine
SkSLConstructorMatrixResize.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_MATRIX_RESIZE
9#define SKSL_CONSTRUCTOR_MATRIX_RESIZE
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 matrix resize operation, such as `mat4x4(myMat2x2)`.
27 *
28 * These always contain exactly 1 matrix of non-matching size. Cells that aren't present in the
29 * input matrix are populated with the identity matrix.
30 */
32public:
33 inline static constexpr Kind kIRNodeKind = Kind::kConstructorMatrixResize;
34
35 ConstructorMatrixResize(Position pos, const Type& type, std::unique_ptr<Expression> arg)
36 : INHERITED(pos, kIRNodeKind, &type, std::move(arg)) {}
37
38 static std::unique_ptr<Expression> Make(const Context& context,
40 const Type& type,
41 std::unique_ptr<Expression> arg);
42
43 std::unique_ptr<Expression> clone(Position pos) const override {
44 return std::make_unique<ConstructorMatrixResize>(pos, this->type(), argument()->clone());
45 }
46
47 bool supportsConstantValues() const override { return true; }
48 std::optional<double> getConstantValue(int n) const override;
49
50private:
51 using INHERITED = SingleArgumentConstructor;
52};
53
54} // namespace SkSL
55
56#endif
SkPoint pos
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
ConstructorMatrixResize(Position pos, const Type &type, std::unique_ptr< Expression > arg)
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