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 "GrGLSLCaps.h" |
9 #include "SkString.h" | 10 #include "SkString.h" |
10 | 11 |
11 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) { | 12 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) { |
12 switch (gen) { | 13 switch (gen) { |
13 case k110_GrGLSLGeneration: | 14 case k110_GrGLSLGeneration: |
14 return false; | 15 return false; |
15 case k130_GrGLSLGeneration: | 16 case k130_GrGLSLGeneration: |
16 case k140_GrGLSLGeneration: | 17 case k140_GrGLSLGeneration: |
17 case k150_GrGLSLGeneration: | 18 case k150_GrGLSLGeneration: |
18 case k330_GrGLSLGeneration: | 19 case k330_GrGLSLGeneration: |
19 case k310es_GrGLSLGeneration: | 20 case k310es_GrGLSLGeneration: |
20 return true; | 21 return true; |
21 } | 22 } |
22 return false; | 23 return false; |
23 } | 24 } |
24 | 25 |
| 26 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, |
| 27 const GrGLSLCaps& glslCaps, |
| 28 SkString* out) { |
| 29 if (glslCaps.usesPrecisionModifiers()) { |
| 30 switch (p) { |
| 31 case kHigh_GrSLPrecision: |
| 32 out->append("precision highp float;\n"); |
| 33 break; |
| 34 case kMedium_GrSLPrecision: |
| 35 out->append("precision mediump float;\n"); |
| 36 break; |
| 37 case kLow_GrSLPrecision: |
| 38 out->append("precision lowp float;\n"); |
| 39 break; |
| 40 default: |
| 41 SkFAIL("Unknown precision value."); |
| 42 } |
| 43 } |
| 44 } |
| 45 |
25 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor) { | 46 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor) { |
26 if (mulFactor.isOnes()) { | 47 if (mulFactor.isOnes()) { |
27 *outAppend = SkString(); | 48 *outAppend = SkString(); |
28 } | 49 } |
29 | 50 |
30 if (mulFactor.isZeros()) { | 51 if (mulFactor.isZeros()) { |
31 outAppend->appendf("%s = vec4(0);", vec4VarName); | 52 outAppend->appendf("%s = vec4(0);", vec4VarName); |
32 } else { | 53 } else { |
33 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); | 54 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); |
34 } | 55 } |
35 } | 56 } |
OLD | NEW |