Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkSL::ConstructorDiagonalMatrix Class Referencefinal

#include <SkSLConstructorDiagonalMatrix.h>

Inheritance diagram for SkSL::ConstructorDiagonalMatrix:
SkSL::SingleArgumentConstructor SkSL::AnyConstructor SkSL::Expression SkSL::IRNode SkSL::Poolable

Public Member Functions

 ConstructorDiagonalMatrix (Position pos, const Type &type, std::unique_ptr< Expression > arg)
 
std::unique_ptr< Expressionclone (Position pos) const override
 
bool supportsConstantValues () const override
 
std::optional< double > getConstantValue (int n) const override
 
- Public Member Functions inherited from SkSL::SingleArgumentConstructor
 SingleArgumentConstructor (Position pos, Kind kind, const Type *type, std::unique_ptr< Expression > argument)
 
std::unique_ptr< Expression > & argument ()
 
const std::unique_ptr< Expression > & argument () const
 
SkSpan< std::unique_ptr< Expression > > argumentSpan () final
 
SkSpan< const std::unique_ptr< Expression > > argumentSpan () const final
 
- Public Member Functions inherited from SkSL::AnyConstructor
 AnyConstructor (Position pos, Kind kind, const Type *type)
 
std::string description (OperatorPrecedence) const override
 
const TypecomponentType () const
 
ComparisonResult compareConstant (const Expression &other) const override
 
- Public Member Functions inherited from SkSL::Expression
 Expression (Position pos, Kind kind, const Type *type)
 
Kind kind () const
 
virtual const Typetype () const
 
bool isAnyConstructor () const
 
bool isIntLiteral () const
 
bool isFloatLiteral () const
 
bool isBoolLiteral () const
 
AnyConstructorasAnyConstructor ()
 
const AnyConstructorasAnyConstructor () const
 
bool isIncomplete (const Context &context) const
 
CoercionCost coercionCost (const Type &target) const
 
std::unique_ptr< Expressionclone () const
 
std::string description () const final
 
- Public Member Functions inherited from SkSL::IRNode
virtual ~IRNode ()
 
 IRNode (const IRNode &)=delete
 
IRNodeoperator= (const IRNode &)=delete
 
Position position () const
 
void setPosition (Position p)
 
template<typename T >
bool is () const
 
template<typename T >
const Tas () const
 
template<typename T >
Tas ()
 

Static Public Member Functions

static std::unique_ptr< ExpressionMake (const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
 
- Static Public Member Functions inherited from SkSL::Poolable
static void * operator new (const size_t size)
 
static void operator delete (void *ptr)
 

Static Public Attributes

static constexpr Kind kIRNodeKind = Kind::kConstructorDiagonalMatrix
 

Additional Inherited Members

- Public Types inherited from SkSL::Expression
enum class  ComparisonResult { kUnknown = -1 , kNotEqual , kEqual }
 
using Kind = ExpressionKind
 
- Public Attributes inherited from SkSL::IRNode
Position fPosition
 
- Protected Member Functions inherited from SkSL::IRNode
 IRNode (Position position, int kind)
 
- Protected Attributes inherited from SkSL::IRNode
int fKind
 

Detailed Description

Represents the construction of a diagonal matrix, such as half3x3(n).

These always contain exactly 1 scalar.

Definition at line 30 of file SkSLConstructorDiagonalMatrix.h.

Constructor & Destructor Documentation

◆ ConstructorDiagonalMatrix()

SkSL::ConstructorDiagonalMatrix::ConstructorDiagonalMatrix ( Position  pos,
const Type type,
std::unique_ptr< Expression arg 
)
inline

Definition at line 34 of file SkSLConstructorDiagonalMatrix.h.

35 : INHERITED(pos, kIRNodeKind, &type, std::move(arg)) {}
SkPoint pos
virtual const Type & type() const

Member Function Documentation

◆ clone()

std::unique_ptr< Expression > SkSL::ConstructorDiagonalMatrix::clone ( Position  pos) const
inlineoverridevirtual

Implements SkSL::Expression.

Definition at line 42 of file SkSLConstructorDiagonalMatrix.h.

42 {
43 return std::make_unique<ConstructorDiagonalMatrix>(pos, this->type(), argument()->clone());
44 }
std::unique_ptr< Expression > clone() const
std::unique_ptr< Expression > & argument()

◆ getConstantValue()

std::optional< double > SkSL::ConstructorDiagonalMatrix::getConstantValue ( int  n) const
overridevirtual

Returns the n'th compile-time constant value within a literal or constructor. Use Type::slotCount to determine the number of slots within an expression. Slots which do not contain compile-time constant values will return nullopt. vec4(1, vec2(2), 3) contains four compile-time constants: (1, 2, 2, 3) mat2(f) contains four slots, and two are constant: (nullopt, 0, 0, nullopt) All classes which override this function must also implement supportsConstantValues.

Reimplemented from SkSL::AnyConstructor.

Definition at line 32 of file SkSLConstructorDiagonalMatrix.cpp.

32 {
33 int rows = this->type().rows();
34 int row = n % rows;
35 int col = n / rows;
36
37 SkASSERT(col >= 0);
38 SkASSERT(row >= 0);
39 SkASSERT(col < this->type().columns());
40 SkASSERT(row < this->type().rows());
41
42 return (col == row) ? this->argument()->getConstantValue(0) : 0.0;
43}
#define SkASSERT(cond)
Definition SkAssert.h:116
virtual int rows() const
Definition SkSLType.h:438

◆ Make()

std::unique_ptr< Expression > SkSL::ConstructorDiagonalMatrix::Make ( const Context context,
Position  pos,
const Type type,
std::unique_ptr< Expression arg 
)
static

Definition at line 16 of file SkSLConstructorDiagonalMatrix.cpp.

19 {
22 SkASSERT(arg->type().isScalar());
23 SkASSERT(arg->type().matches(type.componentType()));
24
25 // Look up the value of constant variables. This allows constant-expressions like `mat4(five)`
26 // to be replaced with `mat4(5.0)`.
28
29 return std::make_unique<ConstructorDiagonalMatrix>(pos, type, std::move(arg));
30}
static std::unique_ptr< Expression > MakeConstantValueForVariable(Position pos, std::unique_ptr< Expression > expr)
bool isAllowedInES2(const Context &context) const
virtual const Type & componentType() const
Definition SkSLType.h:404
virtual bool isMatrix() const
Definition SkSLType.h:528

◆ supportsConstantValues()

bool SkSL::ConstructorDiagonalMatrix::supportsConstantValues ( ) const
inlineoverridevirtual

Returns true if this expression type supports getConstantValue. (This particular expression may or may not actually contain a constant value.) It's harmless to call getConstantValue on expressions which don't support constant values or don't contain any constant values, but if supportsConstantValues returns false, you can assume that getConstantValue will return nullopt for every slot of this expression. This allows for early-out opportunities in some cases. (Some expressions have tons of slots but never hold a constant value; e.g. a variable holding a very large array.)

Reimplemented from SkSL::AnyConstructor.

Definition at line 46 of file SkSLConstructorDiagonalMatrix.h.

46{ return true; }

Member Data Documentation

◆ kIRNodeKind

constexpr Kind SkSL::ConstructorDiagonalMatrix::kIRNodeKind = Kind::kConstructorDiagonalMatrix
inlinestaticconstexpr

Definition at line 32 of file SkSLConstructorDiagonalMatrix.h.


The documentation for this class was generated from the following files: