Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
SkSL::StructType Class Referencefinal
Inheritance diagram for SkSL::StructType:
SkSL::Type SkSL::Symbol SkSL::IRNode SkSL::Poolable

Public Member Functions

 StructType (Position pos, std::string_view name, TArray< Field > fields, int nestingDepth, bool interfaceBlock, bool isBuiltin)
 
SkSpan< const Fieldfields () const override
 
bool isStruct () const override
 
bool isInterfaceBlock () const override
 
bool isBuiltin () const override
 
bool isAllowedInES2 () const override
 
bool isAllowedInUniform (Position *errorPosition) const override
 
bool isOrContainsArray () const override
 
bool isOrContainsUnsizedArray () const override
 
bool isOrContainsAtomic () const override
 
size_t slotCount () const override
 
int structNestingDepth () const override
 
const TypeslotType (size_t n) const override
 
- Public Member Functions inherited from SkSL::Type
 Type (const Type &other)=delete
 
std::string getArrayName (int arraySize) const
 
template<typename T >
bool is () const
 
template<typename T >
const Tas () const
 
template<typename T >
Tas ()
 
const Typeclone (const Context &context, SymbolTable *symbolTable) const
 
std::string displayName () const
 
std::string description () const override
 
bool isAllowedInES2 (const Context &context) const
 
virtual const Typeresolve () const
 
bool matches (const Type &other) const
 
const char * abbreviatedName () const
 
TypeKind typeKind () const
 
virtual NumberKind numberKind () const
 
bool isBoolean () const
 
bool isNumber () const
 
bool isFloat () const
 
bool isSigned () const
 
bool isUnsigned () const
 
bool isInteger () const
 
bool isOpaque () const
 
bool isStorageTexture () const
 
virtual int priority () const
 
bool canCoerceTo (const Type &other, bool allowNarrowing) const
 
CoercionCost coercionCost (const Type &other) const
 
virtual const TypecomponentType () const
 
const TypecolumnType (const Context &context) const
 
virtual const TypetextureType () const
 
virtual int columns () const
 
virtual int rows () const
 
virtual double minimumValue () const
 
virtual double maximumValue () const
 
virtual SkSpan< const Type *const > coercibleTypes () const
 
virtual SpvDim_ dimensions () const
 
virtual bool isDepth () const
 
virtual bool isArrayedTexture () const
 
bool isVoid () const
 
bool isGeneric () const
 
bool isSampler () const
 
bool isAtomic () const
 
virtual bool isScalar () const
 
virtual bool isLiteral () const
 
virtual const TypescalarTypeForLiteral () const
 
virtual bool isVector () const
 
virtual bool isMatrix () const
 
virtual bool isArray () const
 
virtual bool isUnsizedArray () const
 
bool isEffectChild () const
 
virtual bool isMultisampled () const
 
virtual TextureAccess textureAccess () const
 
bool hasPrecision () const
 
bool highPrecision () const
 
virtual int bitWidth () const
 
const TypetoCompound (const Context &context, int columns, int rows) const
 
const TypeapplyQualifiers (const Context &context, ModifierFlags *modifierFlags, Position pos) const
 
std::unique_ptr< ExpressioncoerceExpression (std::unique_ptr< Expression > expr, const Context &context) const
 
bool checkForOutOfRangeLiteral (const Context &context, const Expression &expr) const
 
bool checkForOutOfRangeLiteral (const Context &context, double value, Position pos) const
 
bool checkIfUsableInArray (const Context &context, Position arrayPos) const
 
SKSL_INT convertArraySize (const Context &context, Position arrayPos, std::unique_ptr< Expression > size) const
 
SKSL_INT convertArraySize (const Context &context, Position arrayPos, Position sizePos, SKSL_INT size) const
 
- Public Member Functions inherited from SkSL::Symbol
 Symbol (Position pos, Kind kind, std::string_view name, const Type *type=nullptr)
 
 ~Symbol () override
 
std::unique_ptr< Expressioninstantiate (const Context &context, Position pos) const
 
const Typetype () const
 
Kind kind () const
 
std::string_view name () const
 
void setName (std::string_view newName)
 
- 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 Attributes

static constexpr TypeKind kTypeKind = TypeKind::kStruct
 
- Static Public Attributes inherited from SkSL::Type
static constexpr Kind kIRNodeKind = Kind::kType
 
static constexpr int kMaxAbbrevLength = 3
 
static constexpr int kUnsizedArray = -1
 

Additional Inherited Members

- Public Types inherited from SkSL::Type
enum class  TypeKind : int8_t {
  kArray , kAtomic , kGeneric , kLiteral ,
  kMatrix , kOther , kSampler , kSeparateSampler ,
  kScalar , kStruct , kTexture , kVector ,
  kVoid , kColorFilter , kShader , kBlender
}
 
enum class  NumberKind : int8_t {
  kFloat , kSigned , kUnsigned , kBoolean ,
  kNonnumeric
}
 
enum class  TextureAccess : int8_t { kSample , kRead , kWrite , kReadWrite }
 
- Public Types inherited from SkSL::Symbol
using Kind = SymbolKind
 
- Static Public Member Functions inherited from SkSL::Type
static std::unique_ptr< TypeMakeArrayType (const Context &context, std::string_view name, const Type &componentType, int columns)
 
static std::unique_ptr< TypeMakeAliasType (std::string_view name, const Type &targetType)
 
static std::unique_ptr< TypeMakeGenericType (const char *name, SkSpan< const Type *const > types, const Type *slotType)
 
static std::unique_ptr< TypeMakeLiteralType (const char *name, const Type &scalarType, int8_t priority)
 
static std::unique_ptr< TypeMakeMatrixType (std::string_view name, const char *abbrev, const Type &componentType, int columns, int8_t rows)
 
static std::unique_ptr< TypeMakeSamplerType (const char *name, const Type &textureType)
 
static std::unique_ptr< TypeMakeScalarType (std::string_view name, const char *abbrev, Type::NumberKind numberKind, int8_t priority, int8_t bitWidth)
 
static std::unique_ptr< TypeMakeSpecialType (const char *name, const char *abbrev, Type::TypeKind typeKind)
 
static std::unique_ptr< TypeMakeStructType (const Context &context, Position pos, std::string_view name, skia_private::TArray< Field > fields, bool interfaceBlock=false)
 
static std::unique_ptr< TypeMakeTextureType (const char *name, SpvDim_ dimensions, bool isDepth, bool isArrayedTexture, bool isMultisampled, TextureAccess textureAccess)
 
static std::unique_ptr< TypeMakeVectorType (std::string_view name, const char *abbrev, const Type &componentType, int columns)
 
static std::unique_ptr< TypeMakeAtomicType (std::string_view name, const char *abbrev)
 
- Static Public Member Functions inherited from SkSL::Poolable
static void * operator new (const size_t size)
 
static void operator delete (void *ptr)
 
- Public Attributes inherited from SkSL::IRNode
Position fPosition
 
- Protected Member Functions inherited from SkSL::Type
 Type (std::string_view name, const char *abbrev, TypeKind kind, Position pos=Position())
 
const TypeapplyPrecisionQualifiers (const Context &context, ModifierFlags *modifierFlags, Position pos) const
 
const TypeapplyAccessQualifiers (const Context &context, ModifierFlags *modifierFlags, Position pos) const
 
bool isInRootSymbolTable () const
 
- Protected Member Functions inherited from SkSL::IRNode
 IRNode (Position position, int kind)
 
- Protected Attributes inherited from SkSL::IRNode
int fKind
 

Detailed Description

Definition at line 593 of file SkSLType.cpp.

Constructor & Destructor Documentation

◆ StructType()

SkSL::StructType::StructType ( Position  pos,
std::string_view  name,
TArray< Field fields,
int  nestingDepth,
bool  interfaceBlock,
bool  isBuiltin 
)
inline

Definition at line 597 of file SkSLType.cpp.

599 : INHERITED(std::move(name), "S", kTypeKind, pos)
600 , fFields(std::move(fields))
601 , fNestingDepth(nestingDepth)
602 , fInterfaceBlock(interfaceBlock)
603 , fIsBuiltin(isBuiltin) {
604 for (const Field& f : fFields) {
605 fContainsArray = fContainsArray || f.fType->isOrContainsArray();
606 fContainsUnsizedArray = fContainsUnsizedArray || f.fType->isOrContainsUnsizedArray();
607 fContainsAtomic = fContainsAtomic || f.fType->isOrContainsAtomic();
608 fIsAllowedInES2 = fIsAllowedInES2 && f.fType->isAllowedInES2();
609 }
610 for (const Field& f : fFields) {
611 Position errorPosition = f.fPosition;
612 if (!f.fType->isAllowedInUniform(&errorPosition)) {
613 fUniformErrorPosition = errorPosition;
614 break;
615 }
616 }
617 if (!fContainsUnsizedArray) {
618 for (const Field& f : fFields) {
619 fSlotCount += f.fType->slotCount();
620 }
621 }
622 }
SkPoint pos
SkSpan< const Field > fields() const override
Definition SkSLType.cpp:624
static constexpr TypeKind kTypeKind
Definition SkSLType.cpp:595
bool isBuiltin() const override
Definition SkSLType.cpp:636
std::string_view name() const
Definition SkSLSymbol.h:51

Member Function Documentation

◆ fields()

SkSpan< const Field > SkSL::StructType::fields ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 624 of file SkSLType.cpp.

624 {
625 return fFields;
626 }

◆ isAllowedInES2()

bool SkSL::StructType::isAllowedInES2 ( ) const
inlineoverridevirtual

Returns true if this type is legal to use in a strict-ES2 program.

Reimplemented from SkSL::Type.

Definition at line 640 of file SkSLType.cpp.

640 {
641 return fIsAllowedInES2;
642 }

◆ isAllowedInUniform()

bool SkSL::StructType::isAllowedInUniform ( Position errorPosition) const
inlineoverridevirtual

Returns true if this type is legal to use as a uniform. If false is returned, the errorPosition field may be populated; if it is, this position can be used to emit an extra diagnostic "caused by: <a field>" for nested types. Note that runtime effects enforce additional, much stricter rules about uniforms; these limitations are not handled here.

Reimplemented from SkSL::Type.

Definition at line 644 of file SkSLType.cpp.

644 {
645 if (errorPosition != nullptr) {
646 *errorPosition = fUniformErrorPosition;
647 }
648 return !fUniformErrorPosition.valid();
649 }
bool valid() const

◆ isBuiltin()

bool SkSL::StructType::isBuiltin ( ) const
inlineoverridevirtual

Returns true if this type is known to come from BuiltinTypes, or is declared in a module. If this returns true, the Type will always be available in the root SymbolTable and never needs to be copied to migrate an Expression from one location to another. If it returns false, the Type might not exist in a separate SymbolTable and you'll need to consider cloning it.

Reimplemented from SkSL::Type.

Definition at line 636 of file SkSLType.cpp.

636 {
637 return fIsBuiltin;
638 }

◆ isInterfaceBlock()

bool SkSL::StructType::isInterfaceBlock ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 632 of file SkSLType.cpp.

632 {
633 return fInterfaceBlock;
634 }

◆ isOrContainsArray()

bool SkSL::StructType::isOrContainsArray ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 651 of file SkSLType.cpp.

651 {
652 return fContainsArray;
653 }

◆ isOrContainsAtomic()

bool SkSL::StructType::isOrContainsAtomic ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 659 of file SkSLType.cpp.

659 {
660 return fContainsAtomic;
661 }

◆ isOrContainsUnsizedArray()

bool SkSL::StructType::isOrContainsUnsizedArray ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 655 of file SkSLType.cpp.

655 {
656 return fContainsUnsizedArray;
657 }

◆ isStruct()

bool SkSL::StructType::isStruct ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 628 of file SkSLType.cpp.

628 {
629 return true;
630 }

◆ slotCount()

size_t SkSL::StructType::slotCount ( ) const
inlineoverridevirtual

Returns the number of scalars needed to hold this type.

Reimplemented from SkSL::Type.

Definition at line 663 of file SkSLType.cpp.

663 {
664 SkASSERT(!fContainsUnsizedArray);
665 return fSlotCount;
666 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ slotType()

const Type & SkSL::StructType::slotType ( size_t  ) const
inlineoverridevirtual

Returns the type of the value in the nth slot. For scalar, vector and matrix types, should always match componentType().

Reimplemented from SkSL::Type.

Definition at line 672 of file SkSLType.cpp.

672 {
673 for (const Field& field : fFields) {
674 size_t fieldSlots = field.fType->slotCount();
675 if (n < fieldSlots) {
676 return field.fType->slotType(n);
677 } else {
678 n -= fieldSlots;
679 }
680 }
681 SkDEBUGFAIL("slot index out of range");
682 return *this;
683 }
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118

◆ structNestingDepth()

int SkSL::StructType::structNestingDepth ( ) const
inlineoverridevirtual

If the type is a struct, returns the depth of the struct's most deeply-nested field.

Reimplemented from SkSL::Type.

Definition at line 668 of file SkSLType.cpp.

668 {
669 return fNestingDepth;
670 }

Member Data Documentation

◆ kTypeKind

constexpr TypeKind SkSL::StructType::kTypeKind = TypeKind::kStruct
inlinestaticconstexpr

Definition at line 595 of file SkSLType.cpp.


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