OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLSLShaderVar_DEFINED | 8 #ifndef GrGLSLShaderVar_DEFINED |
9 #define GrGLSLShaderVar_DEFINED | 9 #define GrGLSLShaderVar_DEFINED |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 /** | 66 /** |
67 * Sets as a non-array. | 67 * Sets as a non-array. |
68 */ | 68 */ |
69 void set(GrSLType type, | 69 void set(GrSLType type, |
70 TypeModifier typeModifier, | 70 TypeModifier typeModifier, |
71 const SkString& name, | 71 const SkString& name, |
72 GrSLPrecision precision = kDefault_GrSLPrecision, | 72 GrSLPrecision precision = kDefault_GrSLPrecision, |
73 const char* layoutQualifier = nullptr, | 73 const char* layoutQualifier = nullptr, |
74 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 74 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
75 SkASSERT(kVoid_GrSLType != type); | 75 SkASSERT(kVoid_GrSLType != type); |
76 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; | 76 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
77 INHERITED::set(type, name, typeModifier, precision); | 77 INHERITED::set(type, name, typeModifier, precision); |
78 fLayoutQualifier = layoutQualifier; | 78 fLayoutQualifier = layoutQualifier; |
79 fUseUniformFloatArrays = useUniformFloatArrays; | 79 fUseUniformFloatArrays = useUniformFloatArrays; |
80 } | 80 } |
81 | 81 |
82 /** | 82 /** |
83 * Sets as a non-array. | 83 * Sets as a non-array. |
84 */ | 84 */ |
85 void set(GrSLType type, | 85 void set(GrSLType type, |
86 TypeModifier typeModifier, | 86 TypeModifier typeModifier, |
87 const char* name, | 87 const char* name, |
88 GrSLPrecision precision = kDefault_GrSLPrecision, | 88 GrSLPrecision precision = kDefault_GrSLPrecision, |
89 const char* layoutQualifier = nullptr, | 89 const char* layoutQualifier = nullptr, |
90 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 90 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
91 SkASSERT(kVoid_GrSLType != type); | 91 SkASSERT(kVoid_GrSLType != type); |
92 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; | 92 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
93 INHERITED::set(type, name, typeModifier, precision); | 93 INHERITED::set(type, name, typeModifier, precision); |
94 fLayoutQualifier = layoutQualifier; | 94 fLayoutQualifier = layoutQualifier; |
95 fUseUniformFloatArrays = useUniformFloatArrays; | 95 fUseUniformFloatArrays = useUniformFloatArrays; |
96 } | 96 } |
97 | 97 |
98 /** | 98 /** |
99 * Set all var options | 99 * Set all var options |
100 */ | 100 */ |
101 void set(GrSLType type, | 101 void set(GrSLType type, |
102 TypeModifier typeModifier, | 102 TypeModifier typeModifier, |
103 const SkString& name, | 103 const SkString& name, |
104 int count, | 104 int count, |
105 GrSLPrecision precision = kDefault_GrSLPrecision, | 105 GrSLPrecision precision = kDefault_GrSLPrecision, |
106 const char* layoutQualifier = nullptr, | 106 const char* layoutQualifier = nullptr, |
107 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 107 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
108 SkASSERT(kVoid_GrSLType != type); | 108 SkASSERT(kVoid_GrSLType != type); |
109 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; | 109 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
110 INHERITED::set(type, name, typeModifier, precision, count); | 110 INHERITED::set(type, name, typeModifier, precision, count); |
111 fLayoutQualifier = layoutQualifier; | 111 fLayoutQualifier = layoutQualifier; |
112 fUseUniformFloatArrays = useUniformFloatArrays; | 112 fUseUniformFloatArrays = useUniformFloatArrays; |
113 } | 113 } |
114 | 114 |
115 /** | 115 /** |
116 * Set all var options | 116 * Set all var options |
117 */ | 117 */ |
118 void set(GrSLType type, | 118 void set(GrSLType type, |
119 TypeModifier typeModifier, | 119 TypeModifier typeModifier, |
120 const char* name, | 120 const char* name, |
121 int count, | 121 int count, |
122 GrSLPrecision precision = kDefault_GrSLPrecision, | 122 GrSLPrecision precision = kDefault_GrSLPrecision, |
123 const char* layoutQualifier = nullptr, | 123 const char* layoutQualifier = nullptr, |
124 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 124 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
125 SkASSERT(kVoid_GrSLType != type); | 125 SkASSERT(kVoid_GrSLType != type); |
126 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; | 126 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
127 INHERITED::set(type, name, typeModifier, precision, count); | 127 INHERITED::set(type, name, typeModifier, precision, count); |
128 fLayoutQualifier = layoutQualifier; | 128 fLayoutQualifier = layoutQualifier; |
129 fUseUniformFloatArrays = useUniformFloatArrays; | 129 fUseUniformFloatArrays = useUniformFloatArrays; |
130 } | 130 } |
131 | 131 |
132 /** | 132 /** |
133 * Set the layout qualifier | 133 * Set the layout qualifier |
134 */ | 134 */ |
135 void setLayoutQualifier(const char* layoutQualifier) { | 135 void setLayoutQualifier(const char* layoutQualifier) { |
136 fLayoutQualifier = layoutQualifier; | 136 fLayoutQualifier = layoutQualifier; |
137 } | 137 } |
138 | 138 |
139 /** | 139 /** |
140 * Write a declaration of this variable to out. | 140 * Write a declaration of this variable to out. |
141 */ | 141 */ |
142 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const { | 142 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const { |
143 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType
)); | 143 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsFloatType(fTy
pe)); |
144 if (!fLayoutQualifier.isEmpty()) { | 144 if (!fLayoutQualifier.isEmpty()) { |
145 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); | 145 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); |
146 } | 146 } |
147 if (this->getTypeModifier() != kNone_TypeModifier) { | 147 if (this->getTypeModifier() != kNone_TypeModifier) { |
148 if (GrSLTypeIsIntType(fType) && (this->getTypeModifier() == kVarying
In_TypeModifier || | 148 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); |
149 this->getTypeModifier() == kVarying
Out_TypeModifier)) { | 149 out->append(" "); |
150 out->append("flat "); | |
151 } | |
152 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); | |
153 out->append(" "); | |
154 } | 150 } |
| 151 out->append(PrecisionString(glslCaps, fPrecision)); |
155 GrSLType effectiveType = this->getType(); | 152 GrSLType effectiveType = this->getType(); |
156 if (effectiveType != kBool_GrSLType) { | |
157 out->append(PrecisionString(glslCaps, fPrecision)); | |
158 } | |
159 if (this->isArray()) { | 153 if (this->isArray()) { |
160 if (this->isUnsizedArray()) { | 154 if (this->isUnsizedArray()) { |
161 out->appendf("%s %s[]", | 155 out->appendf("%s %s[]", |
162 GrGLSLTypeString(effectiveType), | 156 GrGLSLTypeString(effectiveType), |
163 this->getName().c_str()); | 157 this->getName().c_str()); |
164 } else { | 158 } else { |
165 SkASSERT(this->getArrayCount() > 0); | 159 SkASSERT(this->getArrayCount() > 0); |
166 out->appendf("%s %s[%d]", | 160 out->appendf("%s %s[%d]", |
167 GrGLSLTypeString(effectiveType), | 161 GrGLSLTypeString(effectiveType), |
168 this->getName().c_str(), | 162 this->getName().c_str(), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 /// Work around driver bugs on some hardware that don't correctly | 229 /// Work around driver bugs on some hardware that don't correctly |
236 /// support uniform float [] | 230 /// support uniform float [] |
237 bool fUseUniformFloatArrays; | 231 bool fUseUniformFloatArrays; |
238 | 232 |
239 SkString fLayoutQualifier; | 233 SkString fLayoutQualifier; |
240 | 234 |
241 typedef GrShaderVar INHERITED; | 235 typedef GrShaderVar INHERITED; |
242 }; | 236 }; |
243 | 237 |
244 #endif | 238 #endif |
OLD | NEW |