| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 case k310es_GrGLSLGeneration: | 85 case k310es_GrGLSLGeneration: |
| 86 SkASSERT(kGLES_GrGLStandard == info.standard()); | 86 SkASSERT(kGLES_GrGLStandard == info.standard()); |
| 87 return "#version 310 es\n"; | 87 return "#version 310 es\n"; |
| 88 default: | 88 default: |
| 89 SkFAIL("Unknown GL version."); | 89 SkFAIL("Unknown GL version."); |
| 90 return ""; // suppress warning | 90 return ""; // suppress warning |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandard
s, SkString* out) { | |
| 95 // Desktop GLSL has added precision qualifiers but they don't do anything. | |
| 96 if (kGLES_GrGLStandard == s) { | |
| 97 switch (p) { | |
| 98 case kHigh_GrSLPrecision: | |
| 99 out->append("precision highp float;\n"); | |
| 100 break; | |
| 101 case kMedium_GrSLPrecision: | |
| 102 out->append("precision mediump float;\n"); | |
| 103 break; | |
| 104 case kLow_GrSLPrecision: | |
| 105 out->append("precision lowp float;\n"); | |
| 106 break; | |
| 107 default: | |
| 108 SkFAIL("Unknown precision value."); | |
| 109 } | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor) { | 94 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor) { |
| 114 if (mulFactor.isOnes()) { | 95 if (mulFactor.isOnes()) { |
| 115 *outAppend = SkString(); | 96 *outAppend = SkString(); |
| 116 } | 97 } |
| 117 | 98 |
| 118 if (mulFactor.isZeros()) { | 99 if (mulFactor.isZeros()) { |
| 119 outAppend->appendf("%s = vec4(0);", vec4VarName); | 100 outAppend->appendf("%s = vec4(0);", vec4VarName); |
| 120 } else { | 101 } else { |
| 121 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); | 102 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); |
| 122 } | 103 } |
| 123 } | 104 } |
| OLD | NEW |