2 * Copyright 2021 Google LLC
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SKSL_CONSTRUCTOR_MATRIX_RESIZE
9 #define SKSL_CONSTRUCTOR_MATRIX_RESIZE
11 #include "src/sksl/SkSLContext.h"
12 #include "src/sksl/ir/SkSLConstructor.h"
13 #include "src/sksl/ir/SkSLExpression.h"
14 #include "src/sksl/ir/SkSLLiteral.h"
21 * Represents the construction of a matrix resize operation, such as `mat4x4(myMat2x2)`.
23 * These always contain exactly 1 matrix of non-matching size. Cells that aren't present in the
24 * input matrix are populated with the identity matrix.
26 class ConstructorMatrixResize final : public SingleArgumentConstructor {
28 inline static constexpr Kind kExpressionKind = Kind::kConstructorMatrixResize;
30 ConstructorMatrixResize(Position pos, const Type& type, std::unique_ptr<Expression> arg)
31 : INHERITED(pos, kExpressionKind, &type, std::move(arg)) {}
33 static std::unique_ptr<Expression> Make(const Context& context,
36 std::unique_ptr<Expression> arg);
38 std::unique_ptr<Expression> clone(Position pos) const override {
39 return std::make_unique<ConstructorMatrixResize>(pos, this->type(), argument()->clone());
42 bool supportsConstantValues() const override { return true; }
43 std::optional<double> getConstantValue(int n) const override;
46 using INHERITED = SingleArgumentConstructor;