Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Unified Diff: src/gpu/glsl/GrGLSLGeometryProcessor.cpp

Issue 2351753002: Revert of Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLGeometryProcessor.h ('k') | src/gpu/glsl/GrGLSLPrimitiveProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLGeometryProcessor.cpp
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index bea49e5069df3c5e5b132ddb1432049ed32e7349..ddbe8e133a81f55ca039c21621550c7496f9a764 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -29,82 +29,71 @@
const GrShaderVar& posVar,
const char* localCoords,
const SkMatrix& localMatrix,
- FPCoordTransformHandler* handler) {
- int i = 0;
- while (const GrCoordTransform* coordTransform = handler->nextCoordTransform()) {
- SkString strUniName;
- strUniName.printf("CoordTransformMatrix_%d", i);
- GrSLType varyingType;
+ const TransformsIn& tin,
+ TransformsOut* tout) {
+ tout->push_back_n(tin.count());
+ fInstalledTransforms.push_back_n(tin.count());
+ for (int i = 0; i < tin.count(); i++) {
+ const ProcCoords& coordTransforms = tin[i];
+ fInstalledTransforms[i].push_back_n(coordTransforms.count());
+ for (int t = 0; t < coordTransforms.count(); t++) {
+ SkString strUniName("StageMatrix");
+ strUniName.appendf("_%i_%i", i, t);
+ GrSLType varyingType;
- GrCoordSet coordType = coordTransform->sourceCoords();
- uint32_t type = coordTransform->getMatrix().getType();
- if (kLocal_GrCoordSet == coordType) {
- type |= localMatrix.getType();
- }
- varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
- kVec2f_GrSLType;
- GrSLPrecision precision = coordTransform->precision();
+ GrCoordSet coordType = coordTransforms[t]->sourceCoords();
+ uint32_t type = coordTransforms[t]->getMatrix().getType();
+ if (kLocal_GrCoordSet == coordType) {
+ type |= localMatrix.getType();
+ }
+ varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
+ GrSLPrecision precision = coordTransforms[t]->precision();
- const char* uniName;
+ const char* uniName;
+ fInstalledTransforms[i][t].fHandle =
+ uniformHandler->addUniform(kVertex_GrShaderFlag,
+ kMat33f_GrSLType, precision,
+ strUniName.c_str(),
+ &uniName).toIndex();
+ SkString strVaryingName("MatrixCoord");
+ strVaryingName.appendf("_%i_%i", i, t);
- fInstalledTransforms.push_back().fHandle = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kMat33f_GrSLType,
- precision,
- strUniName.c_str(),
- &uniName).toIndex();
- SkString strVaryingName;
- strVaryingName.printf("TransformedCoords_%d", i);
+ GrGLSLVertToFrag v(varyingType);
+ varyingHandler->addVarying(strVaryingName.c_str(), &v, precision);
- GrGLSLVertToFrag v(varyingType);
- varyingHandler->addVarying(strVaryingName.c_str(), &v, precision);
+ SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
+ (*tout)[i].emplace_back(SkString(v.fsIn()), varyingType);
- SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
- handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
-
- // varying = matrix * coords (logically)
- if (kDevice_GrCoordSet == coordType) {
- if (kVec2f_GrSLType == varyingType) {
- if (kVec2f_GrSLType == posVar.getType()) {
- vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
- v.vsOut(), uniName, posVar.c_str());
+ // varying = matrix * coords (logically)
+ if (kDevice_GrCoordSet == coordType) {
+ if (kVec2f_GrSLType == varyingType) {
+ if (kVec2f_GrSLType == posVar.getType()) {
+ vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
+ v.vsOut(), uniName, posVar.c_str());
+ } else {
+ // The brackets here are just to scope the temp variable
+ vb->codeAppendf("{ vec3 temp = %s * %s;", uniName, posVar.c_str());
+ vb->codeAppendf("%s = vec2(temp.x/temp.z, temp.y/temp.z); }", v.vsOut());
+ }
} else {
- // The brackets here are just to scope the temp variable
- vb->codeAppendf("{ vec3 temp = %s * %s;", uniName, posVar.c_str());
- vb->codeAppendf("%s = vec2(temp.x/temp.z, temp.y/temp.z); }", v.vsOut());
+ if (kVec2f_GrSLType == posVar.getType()) {
+ vb->codeAppendf("%s = %s * vec3(%s, 1);",
+ v.vsOut(), uniName, posVar.c_str());
+ } else {
+ vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, posVar.c_str());
+ }
}
} else {
- if (kVec2f_GrSLType == posVar.getType()) {
- vb->codeAppendf("%s = %s * vec3(%s, 1);",
- v.vsOut(), uniName, posVar.c_str());
+ if (kVec2f_GrSLType == varyingType) {
+ vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
} else {
- vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, posVar.c_str());
+ vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName, localCoords);
}
}
- } else {
- if (kVec2f_GrSLType == varyingType) {
- vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
- } else {
- vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName, localCoords);
- }
}
- ++i;
}
-}
-
-void GrGLSLGeometryProcessor::setTransformDataHelper(const SkMatrix& localMatrix,
- const GrGLSLProgramDataManager& pdman,
- FPCoordTransformIter* transformIter) {
- int i = 0;
- while (const GrCoordTransform* coordTransform = transformIter->next()) {
- const SkMatrix& m = GetTransformMatrix(localMatrix, *coordTransform);
- if (!fInstalledTransforms[i].fCurrentValue.cheapEqualTo(m)) {
- pdman.setSkMatrix(fInstalledTransforms[i].fHandle.toIndex(), m);
- fInstalledTransforms[i].fCurrentValue = m;
- }
- ++i;
- }
- SkASSERT(i == fInstalledTransforms.count());
}
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
« no previous file with comments | « src/gpu/glsl/GrGLSLGeometryProcessor.h ('k') | src/gpu/glsl/GrGLSLPrimitiveProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698