| 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 16 matching lines...) Expand all Loading... |
| 27 } else { | 27 } else { |
| 28 *generation = k110_GrGLSLGeneration; | 28 *generation = k110_GrGLSLGeneration; |
| 29 } | 29 } |
| 30 return true; | 30 return true; |
| 31 case kGLES_GrGLStandard: | 31 case kGLES_GrGLStandard: |
| 32 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL | 32 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL |
| 33 SkASSERT(ver >= GR_GL_VER(1,00)); | 33 SkASSERT(ver >= GR_GL_VER(1,00)); |
| 34 *generation = k110_GrGLSLGeneration; | 34 *generation = k110_GrGLSLGeneration; |
| 35 return true; | 35 return true; |
| 36 default: | 36 default: |
| 37 GrCrash("Unknown GL Standard"); | 37 SkFAIL("Unknown GL Standard"); |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { | 42 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { |
| 43 switch (info.glslGeneration()) { | 43 switch (info.glslGeneration()) { |
| 44 case k110_GrGLSLGeneration: | 44 case k110_GrGLSLGeneration: |
| 45 if (kGLES_GrGLStandard == info.standard()) { | 45 if (kGLES_GrGLStandard == info.standard()) { |
| 46 // ES2s shader language is based on version 1.20 but is version | 46 // ES2s shader language is based on version 1.20 but is version |
| 47 // 1.00 of the ES language. | 47 // 1.00 of the ES language. |
| 48 return "#version 100\n"; | 48 return "#version 100\n"; |
| 49 } else { | 49 } else { |
| 50 SkASSERT(kGL_GrGLStandard == info.standard()); | 50 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 51 return "#version 110\n"; | 51 return "#version 110\n"; |
| 52 } | 52 } |
| 53 case k130_GrGLSLGeneration: | 53 case k130_GrGLSLGeneration: |
| 54 SkASSERT(kGL_GrGLStandard == info.standard()); | 54 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 55 return "#version 130\n"; | 55 return "#version 130\n"; |
| 56 case k140_GrGLSLGeneration: | 56 case k140_GrGLSLGeneration: |
| 57 SkASSERT(kGL_GrGLStandard == info.standard()); | 57 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 58 return "#version 140\n"; | 58 return "#version 140\n"; |
| 59 case k150_GrGLSLGeneration: | 59 case k150_GrGLSLGeneration: |
| 60 SkASSERT(kGL_GrGLStandard == info.standard()); | 60 SkASSERT(kGL_GrGLStandard == info.standard()); |
| 61 if (info.caps()->isCoreProfile()) { | 61 if (info.caps()->isCoreProfile()) { |
| 62 return "#version 150\n"; | 62 return "#version 150\n"; |
| 63 } else { | 63 } else { |
| 64 return "#version 150 compatibility\n"; | 64 return "#version 150 compatibility\n"; |
| 65 } | 65 } |
| 66 default: | 66 default: |
| 67 GrCrash("Unknown GL version."); | 67 SkFAIL("Unknown GL version."); |
| 68 return ""; // suppress warning | 68 return ""; // suppress warning |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 namespace { | 72 namespace { |
| 73 void append_tabs(SkString* outAppend, int tabCnt) { | 73 void append_tabs(SkString* outAppend, int tabCnt) { |
| 74 static const char kTabs[] = "\t\t\t\t\t\t\t\t"; | 74 static const char kTabs[] = "\t\t\t\t\t\t\t\t"; |
| 75 while (tabCnt) { | 75 while (tabCnt) { |
| 76 int cnt = SkTMin((int)SK_ARRAY_COUNT(kTabs), tabCnt); | 76 int cnt = SkTMin((int)SK_ARRAY_COUNT(kTabs), tabCnt); |
| 77 outAppend->append(kTabs, cnt); | 77 outAppend->append(kTabs, cnt); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 append_tabs(outAppend, tabCnt); | 91 append_tabs(outAppend, tabCnt); |
| 92 | 92 |
| 93 if (mulFactor.isZeros()) { | 93 if (mulFactor.isZeros()) { |
| 94 outAppend->appendf("%s = vec4(0);\n", vec4VarName); | 94 outAppend->appendf("%s = vec4(0);\n", vec4VarName); |
| 95 } else { | 95 } else { |
| 96 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); | 96 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |