Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
SkSL::Type Class Reference

#include <SkSLType.h>

Inheritance diagram for SkSL::Type:
SkSL::Symbol SkSL::IRNode SkSL::Poolable SkSL::AliasType SkSL::ArrayType SkSL::AtomicType SkSL::GenericType SkSL::LiteralType SkSL::MatrixType SkSL::SamplerType SkSL::ScalarType SkSL::StructType SkSL::TextureType SkSL::VectorType

Public Types

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
 

Public Member Functions

 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
 
virtual bool isBuiltin () const
 
std::string displayName () const
 
std::string description () const override
 
bool isAllowedInES2 (const Context &context) const
 
virtual bool isAllowedInES2 () const
 
virtual bool isAllowedInUniform (Position *errorPosition=nullptr) 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 size_t slotCount () const
 
virtual const TypeslotType (size_t) const
 
virtual SkSpan< const Fieldfields () 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
 
virtual bool isStruct () const
 
virtual bool isInterfaceBlock () const
 
bool isEffectChild () const
 
virtual bool isMultisampled () const
 
virtual TextureAccess textureAccess () const
 
bool hasPrecision () const
 
bool highPrecision () const
 
virtual int bitWidth () const
 
virtual bool isOrContainsArray () const
 
virtual bool isOrContainsUnsizedArray () const
 
virtual bool isOrContainsAtomic () 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 ()
 
virtual std::string description () const =0
 
 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< 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)
 

Static Public Attributes

static constexpr Kind kIRNodeKind = Kind::kType
 
static constexpr int kMaxAbbrevLength = 3
 
static constexpr int kUnsizedArray = -1
 

Protected Member Functions

 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
 
virtual int structNestingDepth () const
 
- Protected Member Functions inherited from SkSL::IRNode
 IRNode (Position position, int kind)
 

Additional Inherited Members

- Public Attributes inherited from SkSL::IRNode
Position fPosition
 
- Protected Attributes inherited from SkSL::IRNode
int fKind
 

Detailed Description

Represents a type, such as int or float4.

Definition at line 94 of file SkSLType.h.

Member Enumeration Documentation

◆ NumberKind

enum class SkSL::Type::NumberKind : int8_t
strong
Enumerator
kFloat 
kSigned 
kUnsigned 
kBoolean 
kNonnumeric 

Definition at line 122 of file SkSLType.h.

122 : int8_t {
123 kFloat,
124 kSigned,
125 kUnsigned,
126 kBoolean,
127 kNonnumeric
128 };

◆ TextureAccess

enum class SkSL::Type::TextureAccess : int8_t
strong
Enumerator
kSample 
kRead 
kWrite 
kReadWrite 

Definition at line 130 of file SkSLType.h.

130 : int8_t {
131 kSample, // `kSample` access level allows both sampling and reading
132 kRead,
133 kWrite,
135 };

◆ TypeKind

enum class SkSL::Type::TypeKind : int8_t
strong
Enumerator
kArray 
kAtomic 
kGeneric 
kLiteral 
kMatrix 
kOther 
kSampler 
kSeparateSampler 
kScalar 
kStruct 
kTexture 
kVector 
kVoid 
kColorFilter 
kShader 
kBlender 

Definition at line 101 of file SkSLType.h.

101 : int8_t {
102 kArray,
103 kAtomic,
104 kGeneric,
105 kLiteral,
106 kMatrix,
107 kOther,
108 kSampler,
109 kSeparateSampler,
110 kScalar,
111 kStruct,
112 kTexture,
113 kVector,
114 kVoid,
115
116 // Types that represent stages in the Skia pipeline
118 kShader,
119 kBlender,
120 };

Constructor & Destructor Documentation

◆ Type() [1/2]

SkSL::Type::Type ( const Type other)
delete

◆ Type() [2/2]

SkSL::Type::Type ( std::string_view  name,
const char *  abbrev,
TypeKind  kind,
Position  pos = Position() 
)
inlineprotected

Definition at line 639 of file SkSLType.h.

640 : INHERITED(pos, kIRNodeKind, name)
641 , fTypeKind(kind) {
642 SkASSERT(strlen(abbrev) <= kMaxAbbrevLength);
643 strcpy(fAbbreviatedName, abbrev);
644 }
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
std::string_view name() const
Definition: SkSLSymbol.h:51
Kind kind() const
Definition: SkSLSymbol.h:47
static constexpr Kind kIRNodeKind
Definition: SkSLType.h:96
static constexpr int kMaxAbbrevLength
Definition: SkSLType.h:97

Member Function Documentation

◆ abbreviatedName()

const char * SkSL::Type::abbreviatedName ( ) const
inline

Returns an abbreviated name of the type, meant for name-mangling. (e.g. float4x4 -> f44)

Definition at line 276 of file SkSLType.h.

276 {
277 return fAbbreviatedName;
278 }

◆ applyAccessQualifiers()

const Type * SkSL::Type::applyAccessQualifiers ( const Context context,
ModifierFlags modifierFlags,
Position  pos 
) const
protected

◆ applyPrecisionQualifiers()

const Type * SkSL::Type::applyPrecisionQualifiers ( const Context context,
ModifierFlags modifierFlags,
Position  pos 
) const
protected

◆ applyQualifiers()

const Type * SkSL::Type::applyQualifiers ( const Context context,
ModifierFlags modifierFlags,
Position  pos 
) const

Returns a type which honors the precision and access-level qualifiers set in ModifierFlags. For example:

  • Modifier mediump + Type float2: Type half2
  • Modifier readonly + Type texture2D: Type readonlyTexture2D Generates an error if the qualifiers don't make sense (highp bool, writeonly MyStruct)

◆ as() [1/2]

template<typename T >
T & SkSL::Type::as ( )
inline

Definition at line 216 of file SkSLType.h.

216 {
217 SkASSERT(this->is<T>());
218 return static_cast<T&>(*this);
219 }
#define T
Definition: precompiler.cc:65

◆ as() [2/2]

template<typename T >
const T & SkSL::Type::as ( ) const
inline

Definition at line 210 of file SkSLType.h.

210 {
211 SkASSERT(this->is<T>());
212 return static_cast<const T&>(*this);
213 }

◆ bitWidth()

virtual int SkSL::Type::bitWidth ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::LiteralType, SkSL::ScalarType, SkSL::MatrixType, and SkSL::VectorType.

Definition at line 574 of file SkSLType.h.

574 {
575 return 0;
576 }

◆ canCoerceTo()

bool SkSL::Type::canCoerceTo ( const Type other,
bool  allowNarrowing 
) const
inline

Returns true if an instance of this type can be freely coerced (implicitly converted) to another type.

Definition at line 388 of file SkSLType.h.

388 {
389 return this->coercionCost(other).isPossible(allowNarrowing);
390 }
CoercionCost coercionCost(const Type &other) const
bool isPossible(bool allowNarrowing) const
Definition: SkSLType.h:44

◆ checkForOutOfRangeLiteral() [1/2]

bool SkSL::Type::checkForOutOfRangeLiteral ( const Context context,
const Expression expr 
) const

Detects any IntLiterals in the expression which can't fit in this type.

◆ checkForOutOfRangeLiteral() [2/2]

bool SkSL::Type::checkForOutOfRangeLiteral ( const Context context,
double  value,
Position  pos 
) const

Checks if value can fit in this type. The type must be scalar.

◆ checkIfUsableInArray()

bool SkSL::Type::checkIfUsableInArray ( const Context context,
Position  arrayPos 
) const

Reports errors and returns false if this type cannot be used as the base type for an array.

◆ clone()

const Type * SkSL::Type::clone ( const Context context,
SymbolTable symbolTable 
) const

Creates a clone of this Type, if needed, and inserts it into a different symbol table.

◆ coerceExpression()

std::unique_ptr< Expression > SkSL::Type::coerceExpression ( std::unique_ptr< Expression expr,
const Context context 
) const

Coerces the passed-in expression to this type. If the types are incompatible, reports an error and returns null.

◆ coercibleTypes()

virtual SkSpan< const Type *const > SkSL::Type::coercibleTypes ( ) const
inlinevirtual

For generic types, returns the types that this generic type can substitute for.

Reimplemented in SkSL::AliasType, and SkSL::GenericType.

Definition at line 476 of file SkSLType.h.

476 {
477 SkDEBUGFAIL("Internal error: not a generic type");
478 return {};
479 }
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118

◆ coercionCost()

CoercionCost SkSL::Type::coercionCost ( const Type other) const

Determines the "cost" of coercing (implicitly converting) this type to another type. The cost is a number with no particular meaning other than that lower costs are preferable to higher costs. Returns INT_MAX if the coercion is not possible.

◆ columns()

virtual int SkSL::Type::columns ( ) const
inlinevirtual

For matrices and vectors, returns the number of columns (e.g. both mat3 and float3 return 3). For scalars, returns 1. For arrays, returns either the size of the array (if known) or -1. For all other types, causes an assertion failure.

Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::LiteralType, SkSL::ScalarType, SkSL::MatrixType, and SkSL::VectorType.

Definition at line 429 of file SkSLType.h.

429 {
430 SkDEBUGFAIL("type does not have columns");
431 return -1;
432 }

◆ columnType()

const Type & SkSL::Type::columnType ( const Context context) const
inline

For matrix types, returns the type of a single column (m[n]). Asserts for all other types.

Definition at line 411 of file SkSLType.h.

411 {
412 return this->componentType().toCompound(context, this->rows(), /*rows=*/1);
413 }
virtual int rows() const
Definition: SkSLType.h:438
virtual const Type & componentType() const
Definition: SkSLType.h:404
const Type & toCompound(const Context &context, int columns, int rows) const

◆ componentType()

virtual const Type & SkSL::Type::componentType ( ) const
inlinevirtual

For matrices and vectors, returns the type of individual cells (e.g. mat2 has a component type of Float). For arrays, returns the base type. For all other types, returns the type itself.

Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::MatrixType, and SkSL::VectorType.

Definition at line 404 of file SkSLType.h.

404 {
405 return *this;
406 }

◆ convertArraySize() [1/2]

SKSL_INT SkSL::Type::convertArraySize ( const Context context,
Position  arrayPos,
Position  sizePos,
SKSL_INT  size 
) const

◆ convertArraySize() [2/2]

SKSL_INT SkSL::Type::convertArraySize ( const Context context,
Position  arrayPos,
std::unique_ptr< Expression size 
) const

Verifies that the expression is a valid constant array size for this type. Returns the array size, or reports errors and returns zero if the expression isn't a valid literal value.

◆ description()

std::string SkSL::Type::description ( ) const
inlineoverridevirtual

Implements SkSL::IRNode.

Definition at line 238 of file SkSLType.h.

238 {
239 return this->displayName();
240 }
std::string displayName() const
Definition: SkSLType.h:234

◆ dimensions()

virtual SpvDim_ SkSL::Type::dimensions ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.

Definition at line 481 of file SkSLType.h.

481 {
482 SkDEBUGFAIL("Internal error: not a texture type");
483 return SpvDim1D;
484 }
@ SpvDim1D
Definition: spirv.h:142

◆ displayName()

std::string SkSL::Type::displayName ( ) const
inline

Definition at line 234 of file SkSLType.h.

234 {
235 return std::string(this->scalarTypeForLiteral().name());
236 }
virtual const Type & scalarTypeForLiteral() const
Definition: SkSLType.h:520

◆ fields()

virtual SkSpan< const Field > SkSL::Type::fields ( ) const
inlinevirtual

Reimplemented in SkSL::StructType.

Definition at line 469 of file SkSLType.h.

469 {
470 SK_ABORT("Internal error: not a struct");
471 }
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ getArrayName()

std::string SkSL::Type::getArrayName ( int  arraySize) const

Converts a component type and a size (float, 10) into an array name ("float[10]").

◆ hasPrecision()

bool SkSL::Type::hasPrecision ( ) const
inline

Definition at line 566 of file SkSLType.h.

566 {
567 return this->componentType().isNumber() || this->isSampler();
568 }
bool isSampler() const
Definition: SkSLType.h:504
bool isNumber() const
Definition: SkSLType.h:304

◆ highPrecision()

bool SkSL::Type::highPrecision ( ) const
inline

Definition at line 570 of file SkSLType.h.

570 {
571 return this->bitWidth() >= 32;
572 }
virtual int bitWidth() const
Definition: SkSLType.h:574

◆ is()

template<typename T >
bool SkSL::Type::is ( ) const
inline

Definition at line 205 of file SkSLType.h.

205 {
206 return this->typeKind() == T::kTypeKind;
207 }
TypeKind typeKind() const
Definition: SkSLType.h:283

◆ isAllowedInES2() [1/2]

virtual bool SkSL::Type::isAllowedInES2 ( ) const
inlinevirtual

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

Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::ScalarType, SkSL::AtomicType, SkSL::MatrixType, SkSL::StructType, and SkSL::VectorType.

Definition at line 246 of file SkSLType.h.

246 {
247 return true;
248 }

◆ isAllowedInES2() [2/2]

bool SkSL::Type::isAllowedInES2 ( const Context context) const

Returns true if the program supports this type. Strict ES2 programs can't use ES3 types.

◆ isAllowedInUniform()

virtual bool SkSL::Type::isAllowedInUniform ( Position errorPosition = nullptr) const
inlinevirtual

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 in SkSL::ScalarType, SkSL::AtomicType, SkSL::ArrayType, SkSL::StructType, and SkSL::VectorType.

Definition at line 257 of file SkSLType.h.

257 {
258 // We don't allow samplers, textures or atomics to be marked as uniforms.
259 // This rules out all opaque types.
260 return !this->isOpaque();
261 }
bool isOpaque() const
Definition: SkSLType.h:353

◆ isArray()

virtual bool SkSL::Type::isArray ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::ArrayType.

Definition at line 532 of file SkSLType.h.

532 {
533 return false;
534 }

◆ isArrayedTexture()

virtual bool SkSL::Type::isArrayedTexture ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.

Definition at line 491 of file SkSLType.h.

491 {
492 SkDEBUGFAIL("Internal error: not a texture type");
493 return false;
494 }

◆ isAtomic()

bool SkSL::Type::isAtomic ( ) const
inline

Definition at line 508 of file SkSLType.h.

508 {
509 return this->typeKind() == TypeKind::kAtomic;
510 }

◆ isBoolean()

bool SkSL::Type::isBoolean ( ) const
inline

Returns true if this type is a bool.

Definition at line 297 of file SkSLType.h.

297 {
298 return this->numberKind() == NumberKind::kBoolean;
299 }
virtual NumberKind numberKind() const
Definition: SkSLType.h:290

◆ isBuiltin()

virtual bool SkSL::Type::isBuiltin ( ) const
inlinevirtual

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 in SkSL::ArrayType, and SkSL::StructType.

Definition at line 230 of file SkSLType.h.

230 {
231 return true;
232 }

◆ isDepth()

virtual bool SkSL::Type::isDepth ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.

Definition at line 486 of file SkSLType.h.

486 {
487 SkDEBUGFAIL("Internal error: not a texture type");
488 return false;
489 }

◆ isEffectChild()

bool SkSL::Type::isEffectChild ( ) const
inline

Definition at line 550 of file SkSLType.h.

550 {
551 return fTypeKind == TypeKind::kColorFilter ||
552 fTypeKind == TypeKind::kShader ||
553 fTypeKind == TypeKind::kBlender;
554 }

◆ isFloat()

bool SkSL::Type::isFloat ( ) const
inline

Returns true if this is a floating-point scalar type (float or half).

Definition at line 318 of file SkSLType.h.

318 {
319 return this->numberKind() == NumberKind::kFloat;
320 }

◆ isGeneric()

bool SkSL::Type::isGeneric ( ) const
inline

Definition at line 500 of file SkSLType.h.

500 {
501 return fTypeKind == TypeKind::kGeneric;
502 }

◆ isInRootSymbolTable()

bool SkSL::Type::isInRootSymbolTable ( ) const
inlineprotected

Only structs and arrays can be created in code; all other types exist in the root.

Definition at line 655 of file SkSLType.h.

655 {
656 return !(this->isArray() || this->isStruct());
657 }
virtual bool isArray() const
Definition: SkSLType.h:532
virtual bool isStruct() const
Definition: SkSLType.h:540

◆ isInteger()

bool SkSL::Type::isInteger ( ) const
inline

Returns true if this is a signed or unsigned integer.

Definition at line 339 of file SkSLType.h.

339 {
340 switch (this->numberKind()) {
343 return true;
344 default:
345 return false;
346 }
347 }

◆ isInterfaceBlock()

virtual bool SkSL::Type::isInterfaceBlock ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::StructType.

Definition at line 544 of file SkSLType.h.

544 {
545 return false;
546 }

◆ isLiteral()

virtual bool SkSL::Type::isLiteral ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::LiteralType.

Definition at line 516 of file SkSLType.h.

516 {
517 return false;
518 }

◆ isMatrix()

virtual bool SkSL::Type::isMatrix ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::MatrixType.

Definition at line 528 of file SkSLType.h.

528 {
529 return false;
530 }

◆ isMultisampled()

virtual bool SkSL::Type::isMultisampled ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.

Definition at line 556 of file SkSLType.h.

556 {
557 SkDEBUGFAIL("not a texture type");
558 return false;
559 }

◆ isNumber()

bool SkSL::Type::isNumber ( ) const
inline

Returns true if this is a numeric scalar type.

Definition at line 304 of file SkSLType.h.

304 {
305 switch (this->numberKind()) {
309 return true;
310 default:
311 return false;
312 }
313 }

◆ isOpaque()

bool SkSL::Type::isOpaque ( ) const
inline

Returns true if this is an "opaque type" (an external object which the shader references in some fashion). https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Opaque_types

Definition at line 353 of file SkSLType.h.

353 {
354 switch (fTypeKind) {
362 return true;
363 default:
364 return false;
365 }
366 }

◆ isOrContainsArray()

virtual bool SkSL::Type::isOrContainsArray ( ) const
inlinevirtual

Reimplemented in SkSL::ArrayType, and SkSL::StructType.

Definition at line 578 of file SkSLType.h.

578 {
579 return false;
580 }

◆ isOrContainsAtomic()

virtual bool SkSL::Type::isOrContainsAtomic ( ) const
inlinevirtual

Reimplemented in SkSL::ArrayType, SkSL::AtomicType, and SkSL::StructType.

Definition at line 586 of file SkSLType.h.

586 {
587 return false;
588 }

◆ isOrContainsUnsizedArray()

virtual bool SkSL::Type::isOrContainsUnsizedArray ( ) const
inlinevirtual

Reimplemented in SkSL::ArrayType, and SkSL::StructType.

Definition at line 582 of file SkSLType.h.

582 {
583 return false;
584 }

◆ isSampler()

bool SkSL::Type::isSampler ( ) const
inline

Definition at line 504 of file SkSLType.h.

504 {
505 return fTypeKind == TypeKind::kSampler;
506 }

◆ isScalar()

virtual bool SkSL::Type::isScalar ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::LiteralType, and SkSL::ScalarType.

Definition at line 512 of file SkSLType.h.

512 {
513 return false;
514 }

◆ isSigned()

bool SkSL::Type::isSigned ( ) const
inline

Returns true if this is a signed scalar type (int or short).

Definition at line 325 of file SkSLType.h.

325 {
326 return this->numberKind() == NumberKind::kSigned;
327 }

◆ isStorageTexture()

bool SkSL::Type::isStorageTexture ( ) const
inline

Returns true if this is a storage texture.

Definition at line 371 of file SkSLType.h.

371 {
372 return fTypeKind == TypeKind::kTexture && this->dimensions() != SpvDimSubpassData;
373 }
virtual SpvDim_ dimensions() const
Definition: SkSLType.h:481
@ SpvDimSubpassData
Definition: spirv.h:148

◆ isStruct()

virtual bool SkSL::Type::isStruct ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::StructType.

Definition at line 540 of file SkSLType.h.

540 {
541 return false;
542 }

◆ isUnsigned()

bool SkSL::Type::isUnsigned ( ) const
inline

Returns true if this is an unsigned scalar type (uint or ushort).

Definition at line 332 of file SkSLType.h.

332 {
333 return this->numberKind() == NumberKind::kUnsigned;
334 }

◆ isUnsizedArray()

virtual bool SkSL::Type::isUnsizedArray ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::ArrayType.

Definition at line 536 of file SkSLType.h.

536 {
537 return false;
538 }

◆ isVector()

virtual bool SkSL::Type::isVector ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, and SkSL::VectorType.

Definition at line 524 of file SkSLType.h.

524 {
525 return false;
526 }

◆ isVoid()

bool SkSL::Type::isVoid ( ) const
inline

Definition at line 496 of file SkSLType.h.

496 {
497 return fTypeKind == TypeKind::kVoid;
498 }

◆ MakeAliasType()

static std::unique_ptr< Type > SkSL::Type::MakeAliasType ( std::string_view  name,
const Type targetType 
)
static

Creates an alias which maps to another type.

◆ MakeArrayType()

static std::unique_ptr< Type > SkSL::Type::MakeArrayType ( const Context context,
std::string_view  name,
const Type componentType,
int  columns 
)
static

Creates an array type. columns may be kUnsizedArray.

◆ MakeAtomicType()

static std::unique_ptr< Type > SkSL::Type::MakeAtomicType ( std::string_view  name,
const char *  abbrev 
)
static

Create an atomic type.

◆ MakeGenericType()

static std::unique_ptr< Type > SkSL::Type::MakeGenericType ( const char *  name,
SkSpan< const Type *const >  types,
const Type slotType 
)
static

Create a generic type which maps to the listed types–e.g. $genType is a generic type which can match float, float2, float3 or float4.

◆ MakeLiteralType()

static std::unique_ptr< Type > SkSL::Type::MakeLiteralType ( const char *  name,
const Type scalarType,
int8_t  priority 
)
static

Create a type for literal scalars.

◆ MakeMatrixType()

static std::unique_ptr< Type > SkSL::Type::MakeMatrixType ( std::string_view  name,
const char *  abbrev,
const Type componentType,
int  columns,
int8_t  rows 
)
static

Create a matrix type.

◆ MakeSamplerType()

static std::unique_ptr< Type > SkSL::Type::MakeSamplerType ( const char *  name,
const Type textureType 
)
static

Create a sampler type.

◆ MakeScalarType()

static std::unique_ptr< Type > SkSL::Type::MakeScalarType ( std::string_view  name,
const char *  abbrev,
Type::NumberKind  numberKind,
int8_t  priority,
int8_t  bitWidth 
)
static

Create a scalar type.

◆ MakeSpecialType()

static std::unique_ptr< Type > SkSL::Type::MakeSpecialType ( const char *  name,
const char *  abbrev,
Type::TypeKind  typeKind 
)
static

Create a "special" type with the given name, abbreviation, and TypeKind.

◆ MakeStructType()

static std::unique_ptr< Type > SkSL::Type::MakeStructType ( const Context context,
Position  pos,
std::string_view  name,
skia_private::TArray< Field fields,
bool  interfaceBlock = false 
)
static

Creates a struct type with the given fields. Reports an error if the struct is not well-formed.

◆ MakeTextureType()

static std::unique_ptr< Type > SkSL::Type::MakeTextureType ( const char *  name,
SpvDim_  dimensions,
bool  isDepth,
bool  isArrayedTexture,
bool  isMultisampled,
TextureAccess  textureAccess 
)
static

Create a texture type.

◆ MakeVectorType()

static std::unique_ptr< Type > SkSL::Type::MakeVectorType ( std::string_view  name,
const char *  abbrev,
const Type componentType,
int  columns 
)
static

Create a vector type.

◆ matches()

bool SkSL::Type::matches ( const Type other) const
inline

Returns true if these types are equal after alias resolution.

Definition at line 269 of file SkSLType.h.

269 {
270 return this->resolve().name() == other.resolve().name();
271 }
virtual const Type & resolve() const
Definition: SkSLType.h:264

◆ maximumValue()

virtual double SkSL::Type::maximumValue ( ) const
inlinevirtual

Reimplemented in SkSL::LiteralType, and SkSL::ScalarType.

Definition at line 449 of file SkSLType.h.

449 {
450 SkDEBUGFAIL("type does not have a maximum value");
451 return +INFINITY;
452 }

◆ minimumValue()

virtual double SkSL::Type::minimumValue ( ) const
inlinevirtual

Returns the minimum value that can fit in the type.

Reimplemented in SkSL::LiteralType, and SkSL::ScalarType.

Definition at line 444 of file SkSLType.h.

444 {
445 SkDEBUGFAIL("type does not have a minimum value");
446 return -INFINITY;
447 }

◆ numberKind()

virtual NumberKind SkSL::Type::numberKind ( ) const
inlinevirtual

Returns the NumberKind of this type (always kNonnumeric for non-scalar values).

Reimplemented in SkSL::AliasType, SkSL::LiteralType, and SkSL::ScalarType.

Definition at line 290 of file SkSLType.h.

290 {
292 }

◆ priority()

virtual int SkSL::Type::priority ( ) const
inlinevirtual

Returns the "priority" of a number type, in order of float > half > int > short. When operating on two number types, the result is the higher-priority type.

Reimplemented in SkSL::AliasType, SkSL::LiteralType, and SkSL::ScalarType.

Definition at line 379 of file SkSLType.h.

379 {
380 SkDEBUGFAIL("not a number type");
381 return -1;
382 }

◆ resolve()

virtual const Type & SkSL::Type::resolve ( ) const
inlinevirtual

If this is an alias, returns the underlying type, otherwise returns this.

Reimplemented in SkSL::AliasType.

Definition at line 264 of file SkSLType.h.

264 {
265 return *this;
266 }

◆ rows()

virtual int SkSL::Type::rows ( ) const
inlinevirtual

For matrices, returns the number of rows (e.g. mat2x4 returns 4). For vectors and scalars, returns 1. For all other types, causes an assertion failure.

Reimplemented in SkSL::AliasType, SkSL::LiteralType, SkSL::ScalarType, SkSL::MatrixType, and SkSL::VectorType.

Definition at line 438 of file SkSLType.h.

438 {
439 SkDEBUGFAIL("type does not have rows");
440 return -1;
441 }

◆ scalarTypeForLiteral()

virtual const Type & SkSL::Type::scalarTypeForLiteral ( ) const
inlinevirtual

Reimplemented in SkSL::LiteralType.

Definition at line 520 of file SkSLType.h.

520 {
521 return *this;
522 }

◆ slotCount()

virtual size_t SkSL::Type::slotCount ( ) const
inlinevirtual

Returns the number of scalars needed to hold this type.

Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::LiteralType, SkSL::ScalarType, SkSL::MatrixType, SkSL::StructType, and SkSL::VectorType.

Definition at line 457 of file SkSLType.h.

457 {
458 return 0;
459 }

◆ slotType()

virtual const Type & SkSL::Type::slotType ( size_t  ) const
inlinevirtual

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

Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::LiteralType, SkSL::ScalarType, SkSL::AtomicType, SkSL::MatrixType, SkSL::TextureType, SkSL::SamplerType, SkSL::StructType, SkSL::VectorType, and SkSL::GenericType.

Definition at line 465 of file SkSLType.h.

465 {
466 return *this;
467 }

◆ structNestingDepth()

virtual int SkSL::Type::structNestingDepth ( ) const
inlineprotectedvirtual

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

Reimplemented in SkSL::StructType.

Definition at line 660 of file SkSLType.h.

660 {
661 return 0;
662 }

◆ textureAccess()

virtual TextureAccess SkSL::Type::textureAccess ( ) const
inlinevirtual

Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.

Definition at line 561 of file SkSLType.h.

561 {
562 SkDEBUGFAIL("not a texture type");
564 }

◆ textureType()

virtual const Type & SkSL::Type::textureType ( ) const
inlinevirtual

For texture samplers, returns the type of texture it samples (e.g., sampler2D has a texture type of texture2D).

Reimplemented in SkSL::SamplerType.

Definition at line 419 of file SkSLType.h.

419 {
420 SkDEBUGFAIL("not a sampler type");
421 return *this;
422 }

◆ toCompound()

const Type & SkSL::Type::toCompound ( const Context context,
int  columns,
int  rows 
) const

Returns the corresponding vector or matrix type with the specified number of columns and rows.

◆ typeKind()

TypeKind SkSL::Type::typeKind ( ) const
inline

Returns the category (scalar, vector, matrix, etc.) of this type.

Definition at line 283 of file SkSLType.h.

283 {
284 return fTypeKind;
285 }

Member Data Documentation

◆ kIRNodeKind

constexpr Kind SkSL::Type::kIRNodeKind = Kind::kType
inlinestaticconstexpr

Definition at line 96 of file SkSLType.h.

◆ kMaxAbbrevLength

constexpr int SkSL::Type::kMaxAbbrevLength = 3
inlinestaticconstexpr

Definition at line 97 of file SkSLType.h.

◆ kUnsizedArray

constexpr int SkSL::Type::kUnsizedArray = -1
inlinestaticconstexpr

Definition at line 99 of file SkSLType.h.


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