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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 default: | 60 default: |
61 GrCrash("Unknown GL version."); | 61 GrCrash("Unknown GL version."); |
62 return ""; // suppress warning | 62 return ""; // suppress warning |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 namespace { | 66 namespace { |
67 void append_tabs(SkString* outAppend, int tabCnt) { | 67 void append_tabs(SkString* outAppend, int tabCnt) { |
68 static const char kTabs[] = "\t\t\t\t\t\t\t\t"; | 68 static const char kTabs[] = "\t\t\t\t\t\t\t\t"; |
69 while (tabCnt) { | 69 while (tabCnt) { |
70 int cnt = GrMin((int)GR_ARRAY_COUNT(kTabs), tabCnt); | 70 int cnt = SkTMin((int)SK_ARRAY_COUNT(kTabs), tabCnt); |
71 outAppend->append(kTabs, cnt); | 71 outAppend->append(kTabs, cnt); |
72 tabCnt -= cnt; | 72 tabCnt -= cnt; |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void GrGLSLMulVarBy4f(SkString* outAppend, | 77 void GrGLSLMulVarBy4f(SkString* outAppend, |
78 unsigned tabCnt, | 78 unsigned tabCnt, |
79 const char* vec4VarName, | 79 const char* vec4VarName, |
80 const GrGLSLExpr4& mulFactor) { | 80 const GrGLSLExpr4& mulFactor) { |
81 if (mulFactor.isOnes()) { | 81 if (mulFactor.isOnes()) { |
82 *outAppend = SkString(); | 82 *outAppend = SkString(); |
83 } | 83 } |
84 | 84 |
85 append_tabs(outAppend, tabCnt); | 85 append_tabs(outAppend, tabCnt); |
86 | 86 |
87 if (mulFactor.isZeros()) { | 87 if (mulFactor.isZeros()) { |
88 outAppend->appendf("%s = vec4(0);\n", vec4VarName); | 88 outAppend->appendf("%s = vec4(0);\n", vec4VarName); |
89 } else { | 89 } else { |
90 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); | 90 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); |
91 } | 91 } |
92 } | 92 } |
OLD | NEW |