Create a diagonal-matrix Constructor class.
This constructor takes a single argument and splats it diagonally across
an otherwise-zero matrix. These are also sometimes referred to as a
uniform-scale matrix.
Change-Id: I1ed8140f55f5cad4029015807b220d6475401daa
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/390716
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 41c7972..7915776 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -17,6 +17,7 @@
#include "src/sksl/ir/SkSLBoolLiteral.h"
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLConstructor.h"
+#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
#include "src/sksl/ir/SkSLDiscardStatement.h"
#include "src/sksl/ir/SkSLDoStatement.h"
@@ -312,6 +313,12 @@
SkASSERT(inlinedCtor);
return inlinedCtor;
}
+ case Expression::Kind::kConstructorDiagonalMatrix: {
+ const ConstructorDiagonalMatrix& ctor = expression.as<ConstructorDiagonalMatrix>();
+ return ConstructorDiagonalMatrix::Make(*fContext, offset,
+ *ctor.type().clone(symbolTableForExpression),
+ expr(ctor.argument()));
+ }
case Expression::Kind::kExternalFunctionCall: {
const ExternalFunctionCall& externalCall = expression.as<ExternalFunctionCall>();
return std::make_unique<ExternalFunctionCall>(offset, &externalCall.function(),
@@ -913,6 +920,11 @@
}
break;
}
+ case Expression::Kind::kConstructorDiagonalMatrix: {
+ ConstructorDiagonalMatrix& ctorExpr = (*expr)->as<ConstructorDiagonalMatrix>();
+ this->visitExpression(&ctorExpr.argument());
+ break;
+ }
case Expression::Kind::kExternalFunctionCall: {
ExternalFunctionCall& funcCallExpr = (*expr)->as<ExternalFunctionCall>();
for (std::unique_ptr<Expression>& arg : funcCallExpr.arguments()) {