Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
GrShaderVar Class Reference

#include <GrShaderVar.h>

Public Types

enum class  TypeModifier {
  None , Out , In , InOut ,
  Uniform
}
 
enum  { kNonArray = 0 }
 

Public Member Functions

 GrShaderVar ()
 
 GrShaderVar (SkString name, SkSLType type, int arrayCount=kNonArray)
 
 GrShaderVar (const char *name, SkSLType type, int arrayCount=kNonArray)
 
 GrShaderVar (SkString name, SkSLType type, TypeModifier typeModifier)
 
 GrShaderVar (const char *name, SkSLType type, TypeModifier typeModifier)
 
 GrShaderVar (SkString name, SkSLType type, TypeModifier typeModifier, int arrayCount)
 
 GrShaderVar (SkString name, SkSLType type, TypeModifier typeModifier, int arrayCount, SkString layoutQualifier, SkString extraModifier)
 
 GrShaderVar (const GrShaderVar &)=default
 
GrShaderVaroperator= (const GrShaderVar &)=default
 
 GrShaderVar (GrShaderVar &&)=default
 
GrShaderVaroperator= (GrShaderVar &&)=default
 
void set (SkSLType type, const char *name)
 
bool isArray () const
 
int getArrayCount () const
 
const SkStringgetName () const
 
const char * c_str () const
 
SkSLType getType () const
 
TypeModifier getTypeModifier () const
 
void setTypeModifier (TypeModifier type)
 
void addLayoutQualifier (const char *layoutQualifier)
 
void addModifier (const char *modifier)
 
void appendDecl (const GrShaderCaps *, SkString *out) const
 

Detailed Description

Represents a variable in a shader

Definition at line 20 of file GrShaderVar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Values for array count that have special meaning. We allow 1-sized arrays.

Enumerator
kNonArray 

Definition at line 31 of file GrShaderVar.h.

31 {
32 kNonArray = 0, // not an array
33 };

◆ TypeModifier

enum class GrShaderVar::TypeModifier
strong
Enumerator
None 
Out 
In 
InOut 
Uniform 

Definition at line 22 of file GrShaderVar.h.

Constructor & Destructor Documentation

◆ GrShaderVar() [1/9]

GrShaderVar::GrShaderVar ( )
inline

Defaults to a void with no type modifier or layout qualifier.

Definition at line 36 of file GrShaderVar.h.

37 : fType(SkSLType::kVoid)
38 , fTypeModifier(TypeModifier::None)
39 , fCount(kNonArray) {}

◆ GrShaderVar() [2/9]

GrShaderVar::GrShaderVar ( SkString  name,
SkSLType  type,
int  arrayCount = kNonArray 
)
inline

Definition at line 41 of file GrShaderVar.h.

42 : fType(type)
43 , fTypeModifier(TypeModifier::None)
44 , fCount(arrayCount)
45 , fName(std::move(name)) {}
const char * name
Definition fuchsia.cc:50

◆ GrShaderVar() [3/9]

GrShaderVar::GrShaderVar ( const char *  name,
SkSLType  type,
int  arrayCount = kNonArray 
)
inline

Definition at line 46 of file GrShaderVar.h.

47 : GrShaderVar(SkString(name), type, arrayCount) {}

◆ GrShaderVar() [4/9]

GrShaderVar::GrShaderVar ( SkString  name,
SkSLType  type,
TypeModifier  typeModifier 
)
inline

Definition at line 49 of file GrShaderVar.h.

50 : fType(type)
51 , fTypeModifier(typeModifier)
52 , fCount(kNonArray)
53 , fName(std::move(name)) {}

◆ GrShaderVar() [5/9]

GrShaderVar::GrShaderVar ( const char *  name,
SkSLType  type,
TypeModifier  typeModifier 
)
inline

Definition at line 54 of file GrShaderVar.h.

55 : GrShaderVar(SkString(name), type, typeModifier) {}

◆ GrShaderVar() [6/9]

GrShaderVar::GrShaderVar ( SkString  name,
SkSLType  type,
TypeModifier  typeModifier,
int  arrayCount 
)
inline

Definition at line 57 of file GrShaderVar.h.

58 : fType(type)
59 , fTypeModifier(typeModifier)
60 , fCount(arrayCount)
61 , fName(std::move(name)) {}

◆ GrShaderVar() [7/9]

GrShaderVar::GrShaderVar ( SkString  name,
SkSLType  type,
TypeModifier  typeModifier,
int  arrayCount,
SkString  layoutQualifier,
SkString  extraModifier 
)
inline

Definition at line 63 of file GrShaderVar.h.

65 : fType(type)
66 , fTypeModifier(typeModifier)
67 , fCount(arrayCount)
68 , fName(std::move(name))
69 , fLayoutQualifier(std::move(layoutQualifier))
70 , fExtraModifiers(std::move(extraModifier)) {}

◆ GrShaderVar() [8/9]

GrShaderVar::GrShaderVar ( const GrShaderVar )
default

◆ GrShaderVar() [9/9]

GrShaderVar::GrShaderVar ( GrShaderVar &&  )
default

Member Function Documentation

◆ addLayoutQualifier()

void GrShaderVar::addLayoutQualifier ( const char *  layoutQualifier)
inline

Appends to the layout qualifier.

Definition at line 103 of file GrShaderVar.h.

103 {
104 if (!layoutQualifier || !strlen(layoutQualifier)) {
105 return;
106 }
107 if (fLayoutQualifier.isEmpty()) {
108 fLayoutQualifier = layoutQualifier;
109 } else {
110 fLayoutQualifier.appendf(", %s", layoutQualifier);
111 }
112 }
bool isEmpty() const
Definition SkString.h:130
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550

◆ addModifier()

void GrShaderVar::addModifier ( const char *  modifier)
inline

Appends to the modifiers.

Definition at line 115 of file GrShaderVar.h.

115 {
116 if (!modifier || !strlen(modifier)) {
117 return;
118 }
119 if (fExtraModifiers.isEmpty()) {
120 fExtraModifiers = modifier;
121 } else {
122 fExtraModifiers.appendf(" %s", modifier);
123 }
124 }

◆ appendDecl()

void GrShaderVar::appendDecl ( const GrShaderCaps shaderCaps,
SkString out 
) const

Write a declaration of this variable to out.

Definition at line 23 of file GrShaderVar.cpp.

23 {
24 if (!fLayoutQualifier.isEmpty()) {
25 out->appendf("layout(%s) ", fLayoutQualifier.c_str());
26 }
27 if (!fExtraModifiers.isEmpty()) {
28 out->appendf("%s ", fExtraModifiers.c_str());
29 }
30 if (this->getTypeModifier() != TypeModifier::None) {
31 out->appendf("%s ", type_modifier_string(this->getTypeModifier()));
32 }
33 SkSLType effectiveType = this->getType();
34 if (this->isArray()) {
35 SkASSERT(this->getArrayCount() > 0);
36 out->appendf("%s %s[%d]",
37 SkSLTypeString(effectiveType),
38 this->getName().c_str(),
39 this->getArrayCount());
40 } else {
41 out->appendf("%s %s", SkSLTypeString(effectiveType), this->getName().c_str());
42 }
43}
static const char * type_modifier_string(GrShaderVar::TypeModifier t)
#define SkASSERT(cond)
Definition SkAssert.h:116
const char * SkSLTypeString(SkSLType t)
SkSLType
SkSLType getType() const
Definition GrShaderVar.h:97
int getArrayCount() const
Definition GrShaderVar.h:88
bool isArray() const
Definition GrShaderVar.h:85
const char * c_str() const
Definition GrShaderVar.h:94
TypeModifier getTypeModifier() const
Definition GrShaderVar.h:99
const SkString & getName() const
Definition GrShaderVar.h:91
const char * c_str() const
Definition SkString.h:133

◆ c_str()

const char * GrShaderVar::c_str ( ) const
inline

Shortcut for this->getName().c_str();

Definition at line 94 of file GrShaderVar.h.

94{ return this->getName().c_str(); }

◆ getArrayCount()

int GrShaderVar::getArrayCount ( ) const
inline

Get the array length.

Definition at line 88 of file GrShaderVar.h.

88{ return fCount; }

◆ getName()

const SkString & GrShaderVar::getName ( ) const
inline

Get the name.

Definition at line 91 of file GrShaderVar.h.

91{ return fName; }

◆ getType()

SkSLType GrShaderVar::getType ( ) const
inline

Get the type.

Definition at line 97 of file GrShaderVar.h.

97{ return fType; }

◆ getTypeModifier()

TypeModifier GrShaderVar::getTypeModifier ( ) const
inline

Definition at line 99 of file GrShaderVar.h.

99{ return fTypeModifier; }

◆ isArray()

bool GrShaderVar::isArray ( ) const
inline

Is the var an array.

Definition at line 85 of file GrShaderVar.h.

85{ return kNonArray != fCount; }

◆ operator=() [1/2]

GrShaderVar & GrShaderVar::operator= ( const GrShaderVar )
default

◆ operator=() [2/2]

GrShaderVar & GrShaderVar::operator= ( GrShaderVar &&  )
default

◆ set()

void GrShaderVar::set ( SkSLType  type,
const char *  name 
)
inline

Sets as a non-array.

Definition at line 78 of file GrShaderVar.h.

78 {
80 fType = type;
81 fName = name;
82 }

◆ setTypeModifier()

void GrShaderVar::setTypeModifier ( TypeModifier  type)
inline

Definition at line 100 of file GrShaderVar.h.

100{ fTypeModifier = type; }

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