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

#include <SkSLSetting.h>

Inheritance diagram for SkSL::Setting:
SkSL::Expression SkSL::IRNode SkSL::Poolable

Public Types

using CapsPtr = const bool ShaderCaps::*
 
- Public Types inherited from SkSL::Expression
enum class  ComparisonResult { kUnknown = -1 , kNotEqual , kEqual }
 
using Kind = ExpressionKind
 

Public Member Functions

 Setting (Position pos, CapsPtr capsPtr, const Type *type)
 
std::unique_ptr< ExpressiontoLiteral (const ShaderCaps &caps) const
 
std::unique_ptr< Expressionclone (Position pos) const override
 
std::string_view name () const
 
CapsPtr capsPtr () const
 
std::string description (OperatorPrecedence) 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
 
virtual ComparisonResult compareConstant (const Expression &other) const
 
CoercionCost coercionCost (const Type &target) const
 
virtual bool supportsConstantValues () const
 
virtual std::optional< double > getConstantValue (int n) 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< ExpressionConvert (const Context &context, Position pos, const std::string_view &name)
 
static std::unique_ptr< ExpressionMake (const Context &context, Position pos, CapsPtr capsPtr)
 
- 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::kSetting
 

Additional Inherited Members

- 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 a compile-time constant setting, such as sk_Caps.integerSupport. These IRNodes are used when assembling a module. These nodes are replaced with the value of the setting during compilation when ShaderCaps are available.

Definition at line 33 of file SkSLSetting.h.

Member Typedef Documentation

◆ CapsPtr

using SkSL::Setting::CapsPtr = const bool ShaderCaps::*

Definition at line 37 of file SkSLSetting.h.

Constructor & Destructor Documentation

◆ Setting()

SkSL::Setting::Setting ( Position  pos,
CapsPtr  capsPtr,
const Type type 
)
inline

Definition at line 39 of file SkSLSetting.h.

40 : INHERITED(pos, kIRNodeKind, type)
41 , fCapsPtr(capsPtr) {}
SkPoint pos
virtual const Type & type() const
CapsPtr capsPtr() const
Definition SkSLSetting.h:63
static constexpr Kind kIRNodeKind
Definition SkSLSetting.h:35

Member Function Documentation

◆ capsPtr()

CapsPtr SkSL::Setting::capsPtr ( ) const
inline

Definition at line 63 of file SkSLSetting.h.

63{ return fCapsPtr; }

◆ clone()

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

Implements SkSL::Expression.

Definition at line 57 of file SkSLSetting.h.

57 {
58 return std::make_unique<Setting>(pos, fCapsPtr, &this->type());
59 }

◆ Convert()

std::unique_ptr< Expression > SkSL::Setting::Convert ( const Context context,
Position  pos,
const std::string_view &  name 
)
static

Definition at line 63 of file SkSLSetting.cpp.

65 {
66 SkASSERT(context.fConfig);
67
68 if (!ProgramConfig::AllowsPrivateIdentifiers(context.fConfig->fKind)) {
69 context.fErrors->error(pos, "name 'sk_Caps' is reserved");
70 return nullptr;
71 }
72
73 const CapsPtr* capsPtr = caps_lookup_table().find(name);
74 if (!capsPtr) {
75 context.fErrors->error(pos, "unknown capability flag '" + std::string(name) + "'");
76 return nullptr;
77 }
78
79 return Setting::Make(context, pos, *capsPtr);
80}
#define SkASSERT(cond)
Definition SkAssert.h:116
const bool ShaderCaps::* CapsPtr
Definition SkSLSetting.h:37
static std::unique_ptr< Expression > Make(const Context &context, Position pos, CapsPtr capsPtr)
std::string_view name() const
static bool AllowsPrivateIdentifiers(ProgramKind kind)

◆ description()

std::string SkSL::Setting::description ( OperatorPrecedence  ) const
inlineoverridevirtual

Implements SkSL::Expression.

Definition at line 65 of file SkSLSetting.h.

65 {
66 return "sk_Caps." + std::string(this->name());
67 }

◆ Make()

std::unique_ptr< Expression > SkSL::Setting::Make ( const Context context,
Position  pos,
CapsPtr  capsPtr 
)
static

Definition at line 82 of file SkSLSetting.cpp.

82 {
84
85 return std::make_unique<Setting>(pos, capsPtr, context.fTypes.fBool.get());
86}

◆ name()

std::string_view SkSL::Setting::name ( ) const

Definition at line 54 of file SkSLSetting.cpp.

54 {
55 for (const auto& [name, capsPtr] : caps_lookup_table()) {
56 if (capsPtr == fCapsPtr) {
57 return name;
58 }
59 }
61}
#define SkUNREACHABLE
Definition SkAssert.h:135

◆ toLiteral()

std::unique_ptr< Expression > SkSL::Setting::toLiteral ( const ShaderCaps caps) const

Definition at line 88 of file SkSLSetting.cpp.

88 {
89 return Literal::MakeBool(fPosition, caps.*fCapsPtr, &this->type());
90}
Position fPosition
Definition SkSLIRNode.h:109
static std::unique_ptr< Literal > MakeBool(const Context &context, Position pos, bool value)
Definition SkSLLiteral.h:69

Member Data Documentation

◆ kIRNodeKind

constexpr Kind SkSL::Setting::kIRNodeKind = Kind::kSetting
inlinestaticconstexpr

Definition at line 35 of file SkSLSetting.h.


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