| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SkFAIL("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 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL
Expr4& mulFactor) { |
| 73 void append_tabs(SkString* outAppend, int tabCnt) { | |
| 74 static const char kTabs[] = "\t\t\t\t\t\t\t\t"; | |
| 75 while (tabCnt) { | |
| 76 int cnt = SkTMin((int)SK_ARRAY_COUNT(kTabs), tabCnt); | |
| 77 outAppend->append(kTabs, cnt); | |
| 78 tabCnt -= cnt; | |
| 79 } | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 void GrGLSLMulVarBy4f(SkString* outAppend, | |
| 84 unsigned tabCnt, | |
| 85 const char* vec4VarName, | |
| 86 const GrGLSLExpr4& mulFactor) { | |
| 87 if (mulFactor.isOnes()) { | 73 if (mulFactor.isOnes()) { |
| 88 *outAppend = SkString(); | 74 *outAppend = SkString(); |
| 89 } | 75 } |
| 90 | 76 |
| 91 append_tabs(outAppend, tabCnt); | |
| 92 | |
| 93 if (mulFactor.isZeros()) { | 77 if (mulFactor.isZeros()) { |
| 94 outAppend->appendf("%s = vec4(0);\n", vec4VarName); | 78 outAppend->appendf("%s = vec4(0);", vec4VarName); |
| 95 } else { | 79 } else { |
| 96 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); | 80 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); |
| 97 } | 81 } |
| 98 } | 82 } |
| OLD | NEW |