Flutter Engine
The Flutter Engine
|
#include <SkSLType.h>
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 T & | as () const |
template<typename T > | |
T & | as () |
const Type * | clone (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 Type & | resolve () 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 Type & | componentType () const |
const Type & | columnType (const Context &context) const |
virtual const Type & | textureType () const |
virtual int | columns () const |
virtual int | rows () const |
virtual double | minimumValue () const |
virtual double | maximumValue () const |
virtual size_t | slotCount () const |
virtual const Type & | slotType (size_t) const |
virtual SkSpan< const Field > | fields () 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 Type & | scalarTypeForLiteral () 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 Type & | toCompound (const Context &context, int columns, int rows) const |
const Type * | applyQualifiers (const Context &context, ModifierFlags *modifierFlags, Position pos) const |
std::unique_ptr< Expression > | coerceExpression (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< Expression > | instantiate (const Context &context, Position pos) const |
const Type & | type () 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 | |
IRNode & | operator= (const IRNode &)=delete |
Position | position () const |
void | setPosition (Position p) |
template<typename T > | |
bool | is () const |
template<typename T > | |
const T & | as () const |
template<typename T > | |
T & | as () |
Static Public Member Functions | |
static std::unique_ptr< Type > | MakeArrayType (const Context &context, std::string_view name, const Type &componentType, int columns) |
static std::unique_ptr< Type > | MakeAliasType (std::string_view name, const Type &targetType) |
static std::unique_ptr< Type > | MakeGenericType (const char *name, SkSpan< const Type *const > types, const Type *slotType) |
static std::unique_ptr< Type > | MakeLiteralType (const char *name, const Type &scalarType, int8_t priority) |
static std::unique_ptr< Type > | MakeMatrixType (std::string_view name, const char *abbrev, const Type &componentType, int columns, int8_t rows) |
static std::unique_ptr< Type > | MakeSamplerType (const char *name, const Type &textureType) |
static std::unique_ptr< Type > | MakeScalarType (std::string_view name, const char *abbrev, Type::NumberKind numberKind, int8_t priority, int8_t bitWidth) |
static std::unique_ptr< Type > | MakeSpecialType (const char *name, const char *abbrev, Type::TypeKind typeKind) |
static std::unique_ptr< Type > | MakeStructType (const Context &context, Position pos, std::string_view name, skia_private::TArray< Field > fields, bool interfaceBlock=false) |
static std::unique_ptr< Type > | MakeTextureType (const char *name, SpvDim_ dimensions, bool isDepth, bool isArrayedTexture, bool isMultisampled, TextureAccess textureAccess) |
static std::unique_ptr< Type > | MakeVectorType (std::string_view name, const char *abbrev, const Type &componentType, int columns) |
static std::unique_ptr< Type > | MakeAtomicType (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 Type * | applyPrecisionQualifiers (const Context &context, ModifierFlags *modifierFlags, Position pos) const |
const Type * | applyAccessQualifiers (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 |
Represents a type, such as int or float4.
Definition at line 94 of file SkSLType.h.
|
strong |
Enumerator | |
---|---|
kFloat | |
kSigned | |
kUnsigned | |
kBoolean | |
kNonnumeric |
Definition at line 122 of file SkSLType.h.
|
strong |
Enumerator | |
---|---|
kSample | |
kRead | |
kWrite | |
kReadWrite |
Definition at line 130 of file SkSLType.h.
|
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.
|
delete |
|
inlineprotected |
Definition at line 639 of file SkSLType.h.
|
inline |
Returns an abbreviated name of the type, meant for name-mangling. (e.g. float4x4 -> f44)
Definition at line 276 of file SkSLType.h.
|
protected |
|
protected |
const Type * SkSL::Type::applyQualifiers | ( | const Context & | context, |
ModifierFlags * | modifierFlags, | ||
Position | pos | ||
) | const |
Definition at line 216 of file SkSLType.h.
Definition at line 210 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::ArrayType, SkSL::LiteralType, SkSL::ScalarType, SkSL::MatrixType, and SkSL::VectorType.
Definition at line 574 of file SkSLType.h.
|
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.
bool SkSL::Type::checkForOutOfRangeLiteral | ( | const Context & | context, |
const Expression & | expr | ||
) | const |
Detects any IntLiterals in the expression which can't fit in this type.
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.
Reports errors and returns false if this type cannot be used as the base type for an array.
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.
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.
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.
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.
|
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.
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.
|
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.
SKSL_INT SkSL::Type::convertArraySize | ( | const Context & | context, |
Position | arrayPos, | ||
Position | sizePos, | ||
SKSL_INT | size | ||
) | const |
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.
|
inlineoverridevirtual |
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.
Definition at line 481 of file SkSLType.h.
|
inline |
Definition at line 234 of file SkSLType.h.
std::string SkSL::Type::getArrayName | ( | int | arraySize | ) | const |
Converts a component type and a size (float, 10) into an array name ("float[10]").
|
inline |
Definition at line 566 of file SkSLType.h.
|
inline |
Definition at line 570 of file SkSLType.h.
|
inline |
Definition at line 205 of file SkSLType.h.
|
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.
bool SkSL::Type::isAllowedInES2 | ( | const Context & | context | ) | const |
Returns true if the program supports this type. Strict ES2 programs can't use ES3 types.
|
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.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::ArrayType.
Definition at line 532 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.
Definition at line 491 of file SkSLType.h.
|
inline |
Definition at line 508 of file SkSLType.h.
|
inline |
Returns true if this type is a bool.
Definition at line 297 of file SkSLType.h.
|
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.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.
Definition at line 486 of file SkSLType.h.
|
inline |
Definition at line 550 of file SkSLType.h.
|
inline |
Returns true if this is a floating-point scalar type (float or half).
Definition at line 318 of file SkSLType.h.
|
inline |
Definition at line 500 of file SkSLType.h.
|
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.
|
inline |
Returns true if this is a signed or unsigned integer.
Definition at line 339 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::StructType.
Definition at line 544 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::LiteralType.
Definition at line 516 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::MatrixType.
Definition at line 528 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.
Definition at line 556 of file SkSLType.h.
|
inline |
Returns true if this is a numeric scalar type.
Definition at line 304 of file SkSLType.h.
|
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.
|
inlinevirtual |
Reimplemented in SkSL::ArrayType, and SkSL::StructType.
Definition at line 578 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::ArrayType, SkSL::AtomicType, and SkSL::StructType.
Definition at line 586 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::ArrayType, and SkSL::StructType.
Definition at line 582 of file SkSLType.h.
|
inline |
Definition at line 504 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::LiteralType, and SkSL::ScalarType.
Definition at line 512 of file SkSLType.h.
|
inline |
Returns true if this is a signed scalar type (int or short).
Definition at line 325 of file SkSLType.h.
|
inline |
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::StructType.
Definition at line 540 of file SkSLType.h.
|
inline |
Returns true if this is an unsigned scalar type (uint or ushort).
Definition at line 332 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::ArrayType.
Definition at line 536 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, and SkSL::VectorType.
Definition at line 524 of file SkSLType.h.
|
inline |
Definition at line 496 of file SkSLType.h.
|
static |
Creates an alias which maps to another type.
|
static |
Creates an array type. columns
may be kUnsizedArray.
|
static |
Create an atomic type.
|
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.
|
static |
Create a type for literal scalars.
|
static |
Create a matrix type.
|
static |
Create a sampler type.
|
static |
Create a scalar type.
|
static |
Create a "special" type with the given name, abbreviation, and TypeKind.
|
static |
Creates a struct type with the given fields. Reports an error if the struct is not well-formed.
|
static |
Create a texture type.
|
static |
Create a vector type.
|
inline |
Returns true if these types are equal after alias resolution.
Definition at line 269 of file SkSLType.h.
|
inlinevirtual |
Reimplemented in SkSL::LiteralType, and SkSL::ScalarType.
Definition at line 449 of file SkSLType.h.
|
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.
|
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.
|
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.
|
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.
|
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.
|
inlinevirtual |
Reimplemented in SkSL::LiteralType.
Definition at line 520 of file SkSLType.h.
|
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.
|
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.
|
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.
|
inlinevirtual |
Reimplemented in SkSL::AliasType, SkSL::TextureType, and SkSL::SamplerType.
Definition at line 561 of file SkSLType.h.
|
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.
Returns the corresponding vector or matrix type with the specified number of columns and rows.
|
inline |
Returns the category (scalar, vector, matrix, etc.) of this type.
Definition at line 283 of file SkSLType.h.
|
inlinestaticconstexpr |
Definition at line 96 of file SkSLType.h.
|
inlinestaticconstexpr |
Definition at line 97 of file SkSLType.h.
|
inlinestaticconstexpr |
Definition at line 99 of file SkSLType.h.