OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrGLSLGeometryProcessor.h" | 8 #include "GrGLSLGeometryProcessor.h" |
9 | 9 |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 uint32_t type = coordTransforms[t]->getMatrix().getType(); | 43 uint32_t type = coordTransforms[t]->getMatrix().getType(); |
44 if (kLocal_GrCoordSet == coordType) { | 44 if (kLocal_GrCoordSet == coordType) { |
45 type |= localMatrix.getType(); | 45 type |= localMatrix.getType(); |
46 } | 46 } |
47 varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_
GrSLType : | 47 varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_
GrSLType : |
48 kVec2f_
GrSLType; | 48 kVec2f_
GrSLType; |
49 GrSLPrecision precision = coordTransforms[t]->precision(); | 49 GrSLPrecision precision = coordTransforms[t]->precision(); |
50 | 50 |
51 const char* uniName; | 51 const char* uniName; |
52 fInstalledTransforms[i][t].fHandle = | 52 fInstalledTransforms[i][t].fHandle = |
53 uniformHandler->addUniform(GrGLSLUniformHandler::kVertex_Vis
ibility, | 53 uniformHandler->addUniform(kVertex_GrShaderFlag, |
54 kMat33f_GrSLType, precision, | 54 kMat33f_GrSLType, precision, |
55 strUniName.c_str(), | 55 strUniName.c_str(), |
56 &uniName).toIndex(); | 56 &uniName).toIndex(); |
57 | 57 |
58 SkString strVaryingName("MatrixCoord"); | 58 SkString strVaryingName("MatrixCoord"); |
59 strVaryingName.appendf("_%i_%i", i, t); | 59 strVaryingName.appendf("_%i_%i", i, t); |
60 | 60 |
61 GrGLSLVertToFrag v(varyingType); | 61 GrGLSLVertToFrag v(varyingType); |
62 varyingHandler->addVarying(strVaryingName.c_str(), &v, precision); | 62 varyingHandler->addVarying(strVaryingName.c_str(), &v, precision); |
63 | 63 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 GrGLSLUniformHandler* uniformHandler
, | 132 GrGLSLUniformHandler* uniformHandler
, |
133 GrGPArgs* gpArgs, | 133 GrGPArgs* gpArgs, |
134 const char* posName, | 134 const char* posName, |
135 const SkMatrix& mat, | 135 const SkMatrix& mat, |
136 UniformHandle* viewMatrixUniform) { | 136 UniformHandle* viewMatrixUniform) { |
137 if (mat.isIdentity()) { | 137 if (mat.isIdentity()) { |
138 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 138 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
139 vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(),
posName); | 139 vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(),
posName); |
140 } else { | 140 } else { |
141 const char* viewMatrixName; | 141 const char* viewMatrixName; |
142 *viewMatrixUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kV
ertex_Visibility, | 142 *viewMatrixUniform = uniformHandler->addUniform(kVertex_GrShaderFlag, |
143 kMat33f_GrSLType, kHigh_
GrSLPrecision, | 143 kMat33f_GrSLType, kHigh_
GrSLPrecision, |
144 "uViewM", | 144 "uViewM", |
145 &viewMatrixName); | 145 &viewMatrixName); |
146 if (!mat.hasPerspective()) { | 146 if (!mat.hasPerspective()) { |
147 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 147 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
148 vertBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", | 148 vertBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", |
149 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); | 149 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); |
150 } else { | 150 } else { |
151 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); | 151 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); |
152 vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", | 152 vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", |
153 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); | 153 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
OLD | NEW |