Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: src/gpu/glsl/GrGLSLShaderVar.h

Issue 1673093002: Use noperspective interpolation for 2D draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: formatting Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 GrGLSLShaderVar(const GrShaderVar& var) 45 GrGLSLShaderVar(const GrShaderVar& var)
46 : GrShaderVar(var) 46 : GrShaderVar(var)
47 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) { 47 , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
48 SkASSERT(kVoid_GrSLType != var.getType()); 48 SkASSERT(kVoid_GrSLType != var.getType());
49 } 49 }
50 50
51 GrGLSLShaderVar(const GrGLSLShaderVar& var) 51 GrGLSLShaderVar(const GrGLSLShaderVar& var)
52 : GrShaderVar(var.c_str(), var.getType(), var.getTypeModifier(), 52 : GrShaderVar(var.c_str(), var.getType(), var.getTypeModifier(),
53 var.getArrayCount(), var.getPrecision()) 53 var.getArrayCount(), var.getPrecision())
54 , fUseUniformFloatArrays(var.fUseUniformFloatArrays) { 54 , fUseUniformFloatArrays(var.fUseUniformFloatArrays)
55 , fLayoutQualifier(var.fLayoutQualifier)
56 , fExtraModifiers(var.fExtraModifiers) {
55 SkASSERT(kVoid_GrSLType != var.getType()); 57 SkASSERT(kVoid_GrSLType != var.getType());
56 } 58 }
57 59
58 /** 60 /**
59 * Values for array count that have special meaning. We allow 1-sized arrays . 61 * Values for array count that have special meaning. We allow 1-sized arrays .
60 */ 62 */
61 enum { 63 enum {
62 kNonArray = 0, // not an array 64 kNonArray = 0, // not an array
63 kUnsizedArray = -1, // an unsized array (declared with []) 65 kUnsizedArray = -1, // an unsized array (declared with [])
64 }; 66 };
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 fUseUniformFloatArrays = useUniformFloatArrays; 131 fUseUniformFloatArrays = useUniformFloatArrays;
130 } 132 }
131 133
132 /** 134 /**
133 * Set the layout qualifier 135 * Set the layout qualifier
134 */ 136 */
135 void setLayoutQualifier(const char* layoutQualifier) { 137 void setLayoutQualifier(const char* layoutQualifier) {
136 fLayoutQualifier = layoutQualifier; 138 fLayoutQualifier = layoutQualifier;
137 } 139 }
138 140
141 void addModifier(const char* modifier) {
142 fExtraModifiers.appendf("%s ", modifier);
143 }
144
139 /** 145 /**
140 * Write a declaration of this variable to out. 146 * Write a declaration of this variable to out.
141 */ 147 */
142 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const { 148 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
143 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType )); 149 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType ));
144 if (!fLayoutQualifier.isEmpty()) { 150 if (!fLayoutQualifier.isEmpty()) {
145 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); 151 out->appendf("layout(%s) ", fLayoutQualifier.c_str());
146 } 152 }
153 out->append(fExtraModifiers);
147 if (this->getTypeModifier() != kNone_TypeModifier) { 154 if (this->getTypeModifier() != kNone_TypeModifier) {
148 if (GrSLTypeIsIntType(fType) && (this->getTypeModifier() == kVarying In_TypeModifier ||
149 this->getTypeModifier() == kVarying Out_TypeModifier)) {
150 out->append("flat ");
151 }
152 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); 155 out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
153 out->append(" "); 156 out->append(" ");
154 } 157 }
155 GrSLType effectiveType = this->getType(); 158 GrSLType effectiveType = this->getType();
156 if (effectiveType != kBool_GrSLType) { 159 if (effectiveType != kBool_GrSLType) {
157 out->append(PrecisionString(glslCaps, fPrecision)); 160 out->append(PrecisionString(glslCaps, fPrecision));
158 } 161 }
159 if (this->isArray()) { 162 if (this->isArray()) {
160 if (this->isUnsizedArray()) { 163 if (this->isUnsizedArray()) {
161 out->appendf("%s %s[]", 164 out->appendf("%s %s[]",
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 case kVaryingOut_TypeModifier: 230 case kVaryingOut_TypeModifier:
228 return k110_GrGLSLGeneration == gen ? "varying" : "out"; 231 return k110_GrGLSLGeneration == gen ? "varying" : "out";
229 default: 232 default:
230 SkFAIL("Unknown shader variable type modifier."); 233 SkFAIL("Unknown shader variable type modifier.");
231 return ""; // suppress warning 234 return ""; // suppress warning
232 } 235 }
233 } 236 }
234 237
235 /// Work around driver bugs on some hardware that don't correctly 238 /// Work around driver bugs on some hardware that don't correctly
236 /// support uniform float [] 239 /// support uniform float []
237 bool fUseUniformFloatArrays; 240 bool fUseUniformFloatArrays;
238 241
239 SkString fLayoutQualifier; 242 SkString fLayoutQualifier;
243 SkString fExtraModifiers;
240 244
241 typedef GrShaderVar INHERITED; 245 typedef GrShaderVar INHERITED;
242 }; 246 };
243 247
244 #endif 248 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698