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 "GrGLGLSL.h" | 8 #include "GrGLGLSL.h" |
9 #include "GrGLContext.h" | 9 #include "GrGLContext.h" |
10 #include "GrGLUtil.h" | 10 #include "GrGLUtil.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } else { | 41 } else { |
42 *generation = k110_GrGLSLGeneration; | 42 *generation = k110_GrGLSLGeneration; |
43 } | 43 } |
44 return true; | 44 return true; |
45 default: | 45 default: |
46 SkFAIL("Unknown GL Standard"); | 46 SkFAIL("Unknown GL Standard"); |
47 return false; | 47 return false; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
| 51 const char* GrGLGetGLSLVersionDecl(const GrGLContextInfo& info) { |
| 52 switch (info.glslGeneration()) { |
| 53 case k110_GrGLSLGeneration: |
| 54 if (kGLES_GrGLStandard == info.standard()) { |
| 55 // ES2s shader language is based on version 1.20 but is version |
| 56 // 1.00 of the ES language. |
| 57 return "#version 100\n"; |
| 58 } else { |
| 59 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 60 return "#version 110\n"; |
| 61 } |
| 62 case k130_GrGLSLGeneration: |
| 63 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 64 return "#version 130\n"; |
| 65 case k140_GrGLSLGeneration: |
| 66 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 67 return "#version 140\n"; |
| 68 case k150_GrGLSLGeneration: |
| 69 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 70 if (info.caps()->isCoreProfile()) { |
| 71 return "#version 150\n"; |
| 72 } else { |
| 73 return "#version 150 compatibility\n"; |
| 74 } |
| 75 case k330_GrGLSLGeneration: |
| 76 if (kGLES_GrGLStandard == info.standard()) { |
| 77 return "#version 300 es\n"; |
| 78 } else { |
| 79 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 80 if (info.caps()->isCoreProfile()) { |
| 81 return "#version 330\n"; |
| 82 } else { |
| 83 return "#version 330 compatibility\n"; |
| 84 } |
| 85 } |
| 86 case k310es_GrGLSLGeneration: |
| 87 SkASSERT(kGLES_GrGLStandard == info.standard()); |
| 88 return "#version 310 es\n"; |
| 89 } |
| 90 return "<no version>"; |
| 91 } |
| 92 |
51 void GrGLAppendGLSLDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandar
d s, SkString* out) { | 93 void GrGLAppendGLSLDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandar
d s, SkString* out) { |
52 // Desktop GLSL has added precision qualifiers but they don't do anything. | 94 // Desktop GLSL has added precision qualifiers but they don't do anything. |
53 if (kGLES_GrGLStandard == s) { | 95 if (kGLES_GrGLStandard == s) { |
54 switch (p) { | 96 switch (p) { |
55 case kHigh_GrSLPrecision: | 97 case kHigh_GrSLPrecision: |
56 out->append("precision highp float;\n"); | 98 out->append("precision highp float;\n"); |
57 break; | 99 break; |
58 case kMedium_GrSLPrecision: | 100 case kMedium_GrSLPrecision: |
59 out->append("precision mediump float;\n"); | 101 out->append("precision mediump float;\n"); |
60 break; | 102 break; |
61 case kLow_GrSLPrecision: | 103 case kLow_GrSLPrecision: |
62 out->append("precision lowp float;\n"); | 104 out->append("precision lowp float;\n"); |
63 break; | 105 break; |
64 default: | 106 default: |
65 SkFAIL("Unknown precision value."); | 107 SkFAIL("Unknown precision value."); |
66 } | 108 } |
67 } | 109 } |
68 } | 110 } |
OLD | NEW |