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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 if (kVec2f_GrSLType == varyingType) { | 89 if (kVec2f_GrSLType == varyingType) { |
90 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), un
iName, localCoords); | 90 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), un
iName, localCoords); |
91 } else { | 91 } else { |
92 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName
, localCoords); | 92 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName
, localCoords); |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb, | |
100 GrGLSLVaryingHandler* varyingHandle
r, | |
101 const char* localCoords, | |
102 const TransformsIn& tin, | |
103 TransformsOut* tout) { | |
104 tout->push_back_n(tin.count()); | |
105 for (int i = 0; i < tin.count(); i++) { | |
106 const ProcCoords& coordTransforms = tin[i]; | |
107 for (int t = 0; t < coordTransforms.count(); t++) { | |
108 GrSLType varyingType = kVec2f_GrSLType; | |
109 | |
110 // Device coords aren't supported | |
111 SkASSERT(kDevice_GrCoordSet != coordTransforms[t]->sourceCoords()); | |
112 GrSLPrecision precision = coordTransforms[t]->precision(); | |
113 | |
114 SkString strVaryingName("MatrixCoord"); | |
115 strVaryingName.appendf("_%i_%i", i, t); | |
116 | |
117 GrGLSLVertToFrag v(varyingType); | |
118 varyingHandler->addVarying(strVaryingName.c_str(), &v, precision); | |
119 vb->codeAppendf("%s = %s;", v.vsOut(), localCoords); | |
120 | |
121 (*tout)[i].emplace_back(SkString(v.fsIn()), varyingType); | |
122 } | |
123 } | |
124 } | |
125 | |
126 void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder, | 99 void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder, |
127 GrGPArgs* gpArgs, | 100 GrGPArgs* gpArgs, |
128 const char* posName) { | 101 const char* posName) { |
129 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 102 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
130 vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posN
ame); | 103 vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posN
ame); |
131 } | 104 } |
132 | 105 |
133 void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder, | 106 void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder, |
134 GrGLSLUniformHandler* uniformHandler
, | 107 GrGLSLUniformHandler* uniformHandler
, |
135 GrGPArgs* gpArgs, | 108 GrGPArgs* gpArgs, |
(...skipping 13 matching lines...) Expand all Loading... |
149 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 122 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
150 vertBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", | 123 vertBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", |
151 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); | 124 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); |
152 } else { | 125 } else { |
153 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); | 126 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); |
154 vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", | 127 vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", |
155 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); | 128 gpArgs->fPositionVar.c_str(), viewMatrixNam
e, posName); |
156 } | 129 } |
157 } | 130 } |
158 } | 131 } |
OLD | NEW |