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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 SkASSERT(kGL_GrGLStandard == info.standard()); | 78 SkASSERT(kGL_GrGLStandard == info.standard()); |
79 if (info.caps()->isCoreProfile()) { | 79 if (info.caps()->isCoreProfile()) { |
80 return "#version 330\n"; | 80 return "#version 330\n"; |
81 } else { | 81 } else { |
82 return "#version 330 compatibility\n"; | 82 return "#version 330 compatibility\n"; |
83 } | 83 } |
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: | |
89 SkFAIL("Unknown GL version."); | |
90 return ""; // suppress warning | |
91 } | 88 } |
| 89 return "<no version>"; |
| 90 } |
| 91 |
| 92 bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) { |
| 93 switch (gen) { |
| 94 case k110_GrGLSLGeneration: |
| 95 return false; |
| 96 case k130_GrGLSLGeneration: |
| 97 case k140_GrGLSLGeneration: |
| 98 case k150_GrGLSLGeneration: |
| 99 case k330_GrGLSLGeneration: |
| 100 case k310es_GrGLSLGeneration: |
| 101 return true; |
| 102 } |
| 103 return false; |
92 } | 104 } |
93 | 105 |
94 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandard
s, SkString* out) { | 106 void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandard
s, SkString* out) { |
95 // Desktop GLSL has added precision qualifiers but they don't do anything. | 107 // Desktop GLSL has added precision qualifiers but they don't do anything. |
96 if (kGLES_GrGLStandard == s) { | 108 if (kGLES_GrGLStandard == s) { |
97 switch (p) { | 109 switch (p) { |
98 case kHigh_GrSLPrecision: | 110 case kHigh_GrSLPrecision: |
99 out->append("precision highp float;\n"); | 111 out->append("precision highp float;\n"); |
100 break; | 112 break; |
101 case kMedium_GrSLPrecision: | 113 case kMedium_GrSLPrecision: |
(...skipping 12 matching lines...) Expand all Loading... |
114 if (mulFactor.isOnes()) { | 126 if (mulFactor.isOnes()) { |
115 *outAppend = SkString(); | 127 *outAppend = SkString(); |
116 } | 128 } |
117 | 129 |
118 if (mulFactor.isZeros()) { | 130 if (mulFactor.isZeros()) { |
119 outAppend->appendf("%s = vec4(0);", vec4VarName); | 131 outAppend->appendf("%s = vec4(0);", vec4VarName); |
120 } else { | 132 } else { |
121 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); | 133 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); |
122 } | 134 } |
123 } | 135 } |
OLD | NEW |