| 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 || GrSLTypeIsFloatType(type
)); | 76 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(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 || GrSLTypeIsFloatType(type
)); | 92 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(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 || GrSLTypeIsFloatType(type
)); | 109 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(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 || GrSLTypeIsFloatType(type
)); | 126 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(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 * Write a declaration of this variable to out. | 133 * Write a declaration of this variable to out. |
| 134 */ | 134 */ |
| 135 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const { | 135 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const { |
| 136 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsFloatType(fTy
pe)); | 136 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType
)); |
| 137 if (!fLayoutQualifier.isEmpty()) { | 137 if (!fLayoutQualifier.isEmpty()) { |
| 138 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); | 138 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); |
| 139 } | 139 } |
| 140 if (this->getTypeModifier() != kNone_TypeModifier) { | 140 if (this->getTypeModifier() != kNone_TypeModifier) { |
| 141 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); | 141 if (GrSLTypeIsIntType(fType) && (this->getTypeModifier() == kVarying
In_TypeModifier || |
| 142 out->append(" "); | 142 this->getTypeModifier() == kVarying
Out_TypeModifier)) { |
| 143 out->append("flat "); |
| 144 } |
| 145 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); |
| 146 out->append(" "); |
| 143 } | 147 } |
| 144 out->append(PrecisionString(glslCaps, fPrecision)); | |
| 145 GrSLType effectiveType = this->getType(); | 148 GrSLType effectiveType = this->getType(); |
| 149 if (effectiveType != kBool_GrSLType) { |
| 150 out->append(PrecisionString(glslCaps, fPrecision)); |
| 151 } |
| 146 if (this->isArray()) { | 152 if (this->isArray()) { |
| 147 if (this->isUnsizedArray()) { | 153 if (this->isUnsizedArray()) { |
| 148 out->appendf("%s %s[]", | 154 out->appendf("%s %s[]", |
| 149 GrGLSLTypeString(effectiveType), | 155 GrGLSLTypeString(effectiveType), |
| 150 this->getName().c_str()); | 156 this->getName().c_str()); |
| 151 } else { | 157 } else { |
| 152 SkASSERT(this->getArrayCount() > 0); | 158 SkASSERT(this->getArrayCount() > 0); |
| 153 out->appendf("%s %s[%d]", | 159 out->appendf("%s %s[%d]", |
| 154 GrGLSLTypeString(effectiveType), | 160 GrGLSLTypeString(effectiveType), |
| 155 this->getName().c_str(), | 161 this->getName().c_str(), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 /// Work around driver bugs on some hardware that don't correctly | 228 /// Work around driver bugs on some hardware that don't correctly |
| 223 /// support uniform float [] | 229 /// support uniform float [] |
| 224 bool fUseUniformFloatArrays; | 230 bool fUseUniformFloatArrays; |
| 225 | 231 |
| 226 SkString fLayoutQualifier; | 232 SkString fLayoutQualifier; |
| 227 | 233 |
| 228 typedef GrShaderVar INHERITED; | 234 typedef GrShaderVar INHERITED; |
| 229 }; | 235 }; |
| 230 | 236 |
| 231 #endif | 237 #endif |
| OLD | NEW |