| 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 GrGLShaderVar_DEFINED | 8 #ifndef GrGLShaderVar_DEFINED |
| 9 #define GrGLShaderVar_DEFINED | 9 #define GrGLShaderVar_DEFINED |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 /** | 80 /** |
| 81 * Sets as a non-array. | 81 * Sets as a non-array. |
| 82 */ | 82 */ |
| 83 void set(GrSLType type, | 83 void set(GrSLType type, |
| 84 TypeModifier typeModifier, | 84 TypeModifier typeModifier, |
| 85 const SkString& name, | 85 const SkString& name, |
| 86 GrSLPrecision precision = kDefault_GrSLPrecision, | 86 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 87 Origin origin = kDefault_Origin, | 87 Origin origin = kDefault_Origin, |
| 88 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 88 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 89 SkASSERT(kVoid_GrSLType != type); | 89 SkASSERT(kVoid_GrSLType != type); |
| 90 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
| 90 INHERITED::set(type, typeModifier, name, precision); | 91 INHERITED::set(type, typeModifier, name, precision); |
| 91 fOrigin = origin; | 92 fOrigin = origin; |
| 92 fUseUniformFloatArrays = useUniformFloatArrays; | 93 fUseUniformFloatArrays = useUniformFloatArrays; |
| 93 } | 94 } |
| 94 | 95 |
| 95 /** | 96 /** |
| 96 * Sets as a non-array. | 97 * Sets as a non-array. |
| 97 */ | 98 */ |
| 98 void set(GrSLType type, | 99 void set(GrSLType type, |
| 99 TypeModifier typeModifier, | 100 TypeModifier typeModifier, |
| 100 const char* name, | 101 const char* name, |
| 101 GrSLPrecision precision = kDefault_GrSLPrecision, | 102 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 102 Origin origin = kDefault_Origin, | 103 Origin origin = kDefault_Origin, |
| 103 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 104 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 104 SkASSERT(kVoid_GrSLType != type); | 105 SkASSERT(kVoid_GrSLType != type); |
| 106 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
| 105 INHERITED::set(type, typeModifier, name, precision); | 107 INHERITED::set(type, typeModifier, name, precision); |
| 106 fOrigin = origin; | 108 fOrigin = origin; |
| 107 fUseUniformFloatArrays = useUniformFloatArrays; | 109 fUseUniformFloatArrays = useUniformFloatArrays; |
| 108 } | 110 } |
| 109 | 111 |
| 110 /** | 112 /** |
| 111 * Set all var options | 113 * Set all var options |
| 112 */ | 114 */ |
| 113 void set(GrSLType type, | 115 void set(GrSLType type, |
| 114 TypeModifier typeModifier, | 116 TypeModifier typeModifier, |
| 115 const SkString& name, | 117 const SkString& name, |
| 116 int count, | 118 int count, |
| 117 GrSLPrecision precision = kDefault_GrSLPrecision, | 119 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 118 Origin origin = kDefault_Origin, | 120 Origin origin = kDefault_Origin, |
| 119 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 121 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 120 SkASSERT(kVoid_GrSLType != type); | 122 SkASSERT(kVoid_GrSLType != type); |
| 123 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
| 121 INHERITED::set(type, typeModifier, name, count, precision); | 124 INHERITED::set(type, typeModifier, name, count, precision); |
| 122 fOrigin = origin; | 125 fOrigin = origin; |
| 123 fUseUniformFloatArrays = useUniformFloatArrays; | 126 fUseUniformFloatArrays = useUniformFloatArrays; |
| 124 } | 127 } |
| 125 | 128 |
| 126 /** | 129 /** |
| 127 * Set all var options | 130 * Set all var options |
| 128 */ | 131 */ |
| 129 void set(GrSLType type, | 132 void set(GrSLType type, |
| 130 TypeModifier typeModifier, | 133 TypeModifier typeModifier, |
| 131 const char* name, | 134 const char* name, |
| 132 int count, | 135 int count, |
| 133 GrSLPrecision precision = kDefault_GrSLPrecision, | 136 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 134 Origin origin = kDefault_Origin, | 137 Origin origin = kDefault_Origin, |
| 135 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { | 138 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { |
| 136 SkASSERT(kVoid_GrSLType != type); | 139 SkASSERT(kVoid_GrSLType != type); |
| 140 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
| 137 INHERITED::set(type, typeModifier, name, count, precision); | 141 INHERITED::set(type, typeModifier, name, count, precision); |
| 138 fOrigin = origin; | 142 fOrigin = origin; |
| 139 fUseUniformFloatArrays = useUniformFloatArrays; | 143 fUseUniformFloatArrays = useUniformFloatArrays; |
| 140 } | 144 } |
| 141 | 145 |
| 142 /** | 146 /** |
| 143 * Get the origin of the var | 147 * Get the origin of the var |
| 144 */ | 148 */ |
| 145 Origin getOrigin() const { return fOrigin; } | 149 Origin getOrigin() const { return fOrigin; } |
| 146 | 150 |
| 147 /** | 151 /** |
| 148 * Set the origin of the var | 152 * Set the origin of the var |
| 149 */ | 153 */ |
| 150 void setOrigin(Origin origin) { fOrigin = origin; } | 154 void setOrigin(Origin origin) { fOrigin = origin; } |
| 151 | 155 |
| 152 /** | 156 /** |
| 153 * Write a declaration of this variable to out. | 157 * Write a declaration of this variable to out. |
| 154 */ | 158 */ |
| 155 void appendDecl(const GrGLContextInfo& ctxInfo, SkString* out) const { | 159 void appendDecl(const GrGLContextInfo& ctxInfo, SkString* out) const { |
| 160 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsFloatType(fTy
pe)); |
| 156 if (kUpperLeft_Origin == fOrigin) { | 161 if (kUpperLeft_Origin == fOrigin) { |
| 157 // this is the only place where we specify a layout modifier. If we
use other layout | 162 // this is the only place where we specify a layout modifier. If we
use other layout |
| 158 // modifiers in the future then they should be placed in a list. | 163 // modifiers in the future then they should be placed in a list. |
| 159 out->append("layout(origin_upper_left) "); | 164 out->append("layout(origin_upper_left) "); |
| 160 } | 165 } |
| 161 if (this->getTypeModifier() != kNone_TypeModifier) { | 166 if (this->getTypeModifier() != kNone_TypeModifier) { |
| 162 out->append(TypeModifierString(this->getTypeModifier(), ctxInfo.glslG
eneration())); | 167 out->append(TypeModifierString(this->getTypeModifier(), ctxInfo.glslG
eneration())); |
| 163 out->append(" "); | 168 out->append(" "); |
| 164 } | 169 } |
| 165 out->append(PrecisionString(fPrecision, ctxInfo.standard())); | 170 out->append(PrecisionString(fPrecision, ctxInfo.standard())); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 246 |
| 242 Origin fOrigin; | 247 Origin fOrigin; |
| 243 /// Work around driver bugs on some hardware that don't correctly | 248 /// Work around driver bugs on some hardware that don't correctly |
| 244 /// support uniform float [] | 249 /// support uniform float [] |
| 245 bool fUseUniformFloatArrays; | 250 bool fUseUniformFloatArrays; |
| 246 | 251 |
| 247 typedef GrShaderVar INHERITED; | 252 typedef GrShaderVar INHERITED; |
| 248 }; | 253 }; |
| 249 | 254 |
| 250 #endif | 255 #endif |
| OLD | NEW |