OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrGLEffectMatrix.h" | 8 #include "GrGLEffectMatrix.h" |
9 #include "GrTexture.h" | 9 #include "GrTexture.h" |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 varyingName = suffixedVaryingName.c_str(); | 86 varyingName = suffixedVaryingName.c_str(); |
87 } | 87 } |
88 const char* vsVaryingName; | 88 const char* vsVaryingName; |
89 const char* fsVaryingName; | 89 const char* fsVaryingName; |
90 builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName
); | 90 builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName
); |
91 | 91 |
92 // varying = matrix * vertex-coords (logically) | 92 // varying = matrix * vertex-coords (logically) |
93 switch (fUniType) { | 93 switch (fUniType) { |
94 case kVoid_GrSLType: | 94 case kVoid_GrSLType: |
95 GrAssert(kVec2f_GrSLType == varyingType); | 95 GrAssert(kVec2f_GrSLType == varyingType); |
96 builder->fVSCode.appendf("\t%s = %s;\n", vsVaryingName, vertexCoords
); | 96 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, vertexCoords); |
97 break; | 97 break; |
98 case kVec2f_GrSLType: | 98 case kVec2f_GrSLType: |
99 GrAssert(kVec2f_GrSLType == varyingType); | 99 GrAssert(kVec2f_GrSLType == varyingType); |
100 builder->fVSCode.appendf("\t%s = %s + %s;\n", vsVaryingName, uniName
, vertexCoords); | 100 builder->vsCodeAppendf("\t%s = %s + %s;\n", vsVaryingName, uniName,
vertexCoords); |
101 break; | 101 break; |
102 case kMat33f_GrSLType: { | 102 case kMat33f_GrSLType: { |
103 GrAssert(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin
gType); | 103 GrAssert(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin
gType); |
104 if (kVec2f_GrSLType == varyingType) { | 104 if (kVec2f_GrSLType == varyingType) { |
105 builder->fVSCode.appendf("\t%s = (%s * vec3(%s, 1)).xy;\n", | 105 builder->vsCodeAppendf("\t%s = (%s * vec3(%s, 1)).xy;\n", |
106 vsVaryingName, uniName, vertexCoords); | 106 vsVaryingName, uniName, vertexCoords); |
107 } else { | 107 } else { |
108 builder->fVSCode.appendf("\t%s = %s * vec3(%s, 1);\n", | 108 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n", |
109 vsVaryingName, uniName, vertexCoords); | 109 vsVaryingName, uniName, vertexCoords); |
110 } | 110 } |
111 break; | 111 break; |
112 } | 112 } |
113 default: | 113 default: |
114 GrCrash("Unexpected uniform type."); | 114 GrCrash("Unexpected uniform type."); |
115 } | 115 } |
116 if (NULL != vsCoordName) { | 116 if (NULL != vsCoordName) { |
117 *vsCoordName = vsVaryingName; | 117 *vsCoordName = vsVaryingName; |
118 } | 118 } |
119 if (NULL != fsCoordName) { | 119 if (NULL != fsCoordName) { |
(...skipping 23 matching lines...) Expand all Loading... |
143 suffix); | 143 suffix); |
144 if (kVec3f_GrSLType == varyingType) { | 144 if (kVec3f_GrSLType == varyingType) { |
145 | 145 |
146 const char* coordName = "coords2D"; | 146 const char* coordName = "coords2D"; |
147 SkString suffixedCoordName; | 147 SkString suffixedCoordName; |
148 if (NULL != suffix) { | 148 if (NULL != suffix) { |
149 suffixedCoordName.append(coordName); | 149 suffixedCoordName.append(coordName); |
150 suffixedCoordName.append(suffix); | 150 suffixedCoordName.append(suffix); |
151 coordName = suffixedCoordName.c_str(); | 151 coordName = suffixedCoordName.c_str(); |
152 } | 152 } |
153 builder->fFSCode.appendf("\tvec2 %s = %s.xy / %s.z;", | 153 builder->fsCodeAppendf("\tvec2 %s = %s.xy / %s.z;", |
154 coordName, fsVaryingName, fsVaryingName); | 154 coordName, fsVaryingName, fsVaryingName); |
155 if (NULL != fsCoordName) { | 155 if (NULL != fsCoordName) { |
156 *fsCoordName = coordName; | 156 *fsCoordName = coordName; |
157 } | 157 } |
158 } else if(NULL != fsCoordName) { | 158 } else if(NULL != fsCoordName) { |
159 *fsCoordName = fsVaryingName; | 159 *fsCoordName = fsVaryingName; |
160 } | 160 } |
161 if (NULL != vsVaryingType) { | 161 if (NULL != vsVaryingType) { |
162 *vsVaryingType = varyingType; | 162 *vsVaryingType = varyingType; |
163 } | 163 } |
164 } | 164 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 if (!fPrevMatrix.cheapEqualTo(combined)) { | 204 if (!fPrevMatrix.cheapEqualTo(combined)) { |
205 uniformManager.setSkMatrix(fUni, combined); | 205 uniformManager.setSkMatrix(fUni, combined); |
206 fPrevMatrix = combined; | 206 fPrevMatrix = combined; |
207 } | 207 } |
208 break; | 208 break; |
209 } | 209 } |
210 default: | 210 default: |
211 GrCrash("Unexpected uniform type."); | 211 GrCrash("Unexpected uniform type."); |
212 } | 212 } |
213 } | 213 } |
OLD | NEW |