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

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

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary 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 ddbe8e133a81f55ca039c21621550c7496f9a764..bea49e5069df3c5e5b132ddb1432049ed32e7349 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -29,71 +29,82 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
const GrShaderVar& posVar,
const char* localCoords,
const SkMatrix& localMatrix,
- 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;
+ FPCoordTransformHandler* handler) {
+ int i = 0;
+ while (const GrCoordTransform* coordTransform = handler->nextCoordTransform()) {
+ SkString strUniName;
+ strUniName.printf("CoordTransformMatrix_%d", i);
+ GrSLType varyingType;
- 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();
+ 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();
+
+ 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());
- } 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());
- }
+ // 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 {
- 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());
- }
+ // 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 {
- if (kVec2f_GrSLType == varyingType) {
- vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
+ if (kVec2f_GrSLType == posVar.getType()) {
+ vb->codeAppendf("%s = %s * vec3(%s, 1);",
+ v.vsOut(), uniName, posVar.c_str());
} else {
- vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName, localCoords);
+ vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, posVar.c_str());
}
}
+ } 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