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 #include "GrGLSL.h" | 8 #include "GrGLSL.h" |
9 #include "GrGLShaderVar.h" | 9 #include "GrGLShaderVar.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, | 64 bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, |
65 const char* nameIfDeclared, | 65 const char* nameIfDeclared, |
66 GrGLShaderVar* var) { | 66 GrGLShaderVar* var) { |
67 bool declaredOutput = k110_GrGLSLGeneration != gen; | 67 bool declaredOutput = k110_GrGLSLGeneration != gen; |
68 var->set(kVec4f_GrSLType, | 68 var->set(kVec4f_GrSLType, |
69 GrGLShaderVar::kOut_TypeModifier, | 69 GrGLShaderVar::kOut_TypeModifier, |
70 declaredOutput ? nameIfDeclared : "gl_FragColor"); | 70 declaredOutput ? nameIfDeclared : "gl_FragColor"); |
71 return declaredOutput; | 71 return declaredOutput; |
72 } | 72 } |
73 | 73 |
74 GrSLType GrSLFloatVectorType (int count) { | |
75 GR_STATIC_ASSERT(kFloat_GrSLType == 1); | |
76 GR_STATIC_ASSERT(kVec2f_GrSLType == 2); | |
77 GR_STATIC_ASSERT(kVec3f_GrSLType == 3); | |
78 GR_STATIC_ASSERT(kVec4f_GrSLType == 4); | |
79 GrAssert(count > 0 && count <= 4); | |
80 return (GrSLType)(count); | |
81 } | |
82 | |
83 const char* GrGLSLVectorHomogCoord(int count) { | 74 const char* GrGLSLVectorHomogCoord(int count) { |
84 static const char* HOMOGS[] = {"ERROR", "", ".y", ".z", ".w"}; | 75 static const char* HOMOGS[] = {"ERROR", "", ".y", ".z", ".w"}; |
85 GrAssert(count >= 1 && count < (int)GR_ARRAY_COUNT(HOMOGS)); | 76 GrAssert(count >= 1 && count < (int)GR_ARRAY_COUNT(HOMOGS)); |
86 return HOMOGS[count]; | 77 return HOMOGS[count]; |
87 } | 78 } |
88 | 79 |
89 const char* GrGLSLVectorHomogCoord(GrSLType type) { | 80 const char* GrGLSLVectorHomogCoord(GrSLType type) { |
90 return GrGLSLVectorHomogCoord(GrSLTypeToVecLength(type)); | 81 return GrGLSLVectorHomogCoord(GrSLTypeToVecLength(type)); |
91 } | 82 } |
92 | 83 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return kNone_GrSLConstantVec; | 197 return kNone_GrSLConstantVec; |
207 } else if (!has1) { | 198 } else if (!has1) { |
208 GrAssert(kZeros_GrSLConstantVec == default1); | 199 GrAssert(kZeros_GrSLConstantVec == default1); |
209 outAppend->appendf("vec4(%s)", in0); | 200 outAppend->appendf("vec4(%s)", in0); |
210 return kNone_GrSLConstantVec; | 201 return kNone_GrSLConstantVec; |
211 } else { | 202 } else { |
212 outAppend->appendf("(vec4(%s) + vec4(%s))", in0, in1); | 203 outAppend->appendf("(vec4(%s) + vec4(%s))", in0, in1); |
213 return kNone_GrSLConstantVec; | 204 return kNone_GrSLConstantVec; |
214 } | 205 } |
215 } | 206 } |
OLD | NEW |