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