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

Public Types

using int_limits = std::numeric_limits< int32_t >
 
using short_limits = std::numeric_limits< int16_t >
 
using uint_limits = std::numeric_limits< uint32_t >
 
using ushort_limits = std::numeric_limits< uint16_t >
 
using float_limits = std::numeric_limits< float >
 
- 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
 

Public Member Functions

 ScalarType (std::string_view name, const char *abbrev, NumberKind numberKind, int8_t priority, int8_t bitWidth)
 
NumberKind numberKind () const override
 
int priority () const override
 
int bitWidth () const override
 
int columns () const override
 
int rows () const override
 
bool isScalar () const override
 
bool isAllowedInES2 () const override
 
bool isAllowedInUniform (Position *) const override
 
size_t slotCount () const override
 
const TypeslotType (size_t n) const override
 
double minimumValue () const override
 
double maximumValue () 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
 
virtual bool isBuiltin () 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
 
bool isBoolean () const
 
bool isNumber () const
 
bool isFloat () const
 
bool isSigned () const
 
bool isUnsigned () const
 
bool isInteger () const
 
bool isOpaque () const
 
bool isStorageTexture () 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 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 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 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 ()
 
 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::kScalar
 
- 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

- 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
 
virtual int structNestingDepth () 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 322 of file SkSLType.cpp.

Member Typedef Documentation

◆ float_limits

using SkSL::ScalarType::float_limits = std::numeric_limits<float>

Definition at line 378 of file SkSLType.cpp.

◆ int_limits

using SkSL::ScalarType::int_limits = std::numeric_limits<int32_t>

Definition at line 374 of file SkSLType.cpp.

◆ short_limits

using SkSL::ScalarType::short_limits = std::numeric_limits<int16_t>

Definition at line 375 of file SkSLType.cpp.

◆ uint_limits

using SkSL::ScalarType::uint_limits = std::numeric_limits<uint32_t>

Definition at line 376 of file SkSLType.cpp.

◆ ushort_limits

using SkSL::ScalarType::ushort_limits = std::numeric_limits<uint16_t>

Definition at line 377 of file SkSLType.cpp.

Constructor & Destructor Documentation

◆ ScalarType()

SkSL::ScalarType::ScalarType ( std::string_view  name,
const char *  abbrev,
NumberKind  numberKind,
int8_t  priority,
int8_t  bitWidth 
)
inline

Definition at line 326 of file SkSLType.cpp.

328 : INHERITED(name, abbrev, kTypeKind)
329 , fNumberKind(numberKind)
330 , fPriority(priority)
331 , fBitWidth(bitWidth) {}
int bitWidth() const override
Definition SkSLType.cpp:341
int priority() const override
Definition SkSLType.cpp:337
static constexpr TypeKind kTypeKind
Definition SkSLType.cpp:324
NumberKind numberKind() const override
Definition SkSLType.cpp:333
std::string_view name() const
Definition SkSLSymbol.h:51

Member Function Documentation

◆ bitWidth()

int SkSL::ScalarType::bitWidth ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 341 of file SkSLType.cpp.

341 {
342 return fBitWidth;
343 }

◆ columns()

int SkSL::ScalarType::columns ( ) const
inlineoverridevirtual

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 from SkSL::Type.

Definition at line 345 of file SkSLType.cpp.

345 {
346 return 1;
347 }

◆ isAllowedInES2()

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

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

Reimplemented from SkSL::Type.

Definition at line 357 of file SkSLType.cpp.

357 {
358 return fNumberKind != NumberKind::kUnsigned;
359 }

◆ isAllowedInUniform()

bool SkSL::ScalarType::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 361 of file SkSLType.cpp.

361 {
362 return fNumberKind != NumberKind::kBoolean;
363 }

◆ isScalar()

bool SkSL::ScalarType::isScalar ( ) const
inlineoverridevirtual

Reimplemented from SkSL::Type.

Definition at line 353 of file SkSLType.cpp.

353 {
354 return true;
355 }

◆ maximumValue()

double SkSL::ScalarType::maximumValue ( ) const
inlineoverridevirtual

Returns the maximum value that can fit in the type.

Reimplemented from SkSL::Type.

Definition at line 397 of file SkSLType.cpp.

397 {
398 switch (this->numberKind()) {
400 return this->highPrecision() ? int_limits::max()
401 : short_limits::max();
402
404 return this->highPrecision() ? uint_limits::max()
405 : ushort_limits::max();
406
408 default:
409 return float_limits::max();
410 }
411 }
std::numeric_limits< uint16_t > ushort_limits
Definition SkSLType.cpp:377
std::numeric_limits< int16_t > short_limits
Definition SkSLType.cpp:375
bool highPrecision() const
Definition SkSLType.h:570
static float max(float r, float g, float b)
Definition hsl.cpp:49

◆ minimumValue()

double SkSL::ScalarType::minimumValue ( ) const
inlineoverridevirtual

Returns the maximum value that can fit in the type.

Reimplemented from SkSL::Type.

Definition at line 381 of file SkSLType.cpp.

381 {
382 switch (this->numberKind()) {
384 return this->highPrecision() ? int_limits::lowest()
385 : short_limits::lowest();
386
388 return 0;
389
391 default:
392 return float_limits::lowest();
393 }
394 }

◆ numberKind()

NumberKind SkSL::ScalarType::numberKind ( ) const
inlineoverridevirtual

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

Reimplemented from SkSL::Type.

Definition at line 333 of file SkSLType.cpp.

333 {
334 return fNumberKind;
335 }

◆ priority()

int SkSL::ScalarType::priority ( ) const
inlineoverridevirtual

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 from SkSL::Type.

Definition at line 337 of file SkSLType.cpp.

337 {
338 return fPriority;
339 }

◆ rows()

int SkSL::ScalarType::rows ( ) const
inlineoverridevirtual

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 from SkSL::Type.

Definition at line 349 of file SkSLType.cpp.

349 {
350 return 1;
351 }

◆ slotCount()

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

Returns the number of scalars needed to hold this type.

Reimplemented from SkSL::Type.

Definition at line 365 of file SkSLType.cpp.

365 {
366 return 1;
367 }

◆ slotType()

const Type & SkSL::ScalarType::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 369 of file SkSLType.cpp.

369 {
370 SkASSERT(n == 0);
371 return *this;
372 }
#define SkASSERT(cond)
Definition SkAssert.h:116

Member Data Documentation

◆ kTypeKind

constexpr TypeKind SkSL::ScalarType::kTypeKind = TypeKind::kScalar
inlinestaticconstexpr

Definition at line 324 of file SkSLType.cpp.


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