aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-09-19 09:26:40 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-19 09:26:40 -0700
commit56b7dc476ba5e4a53ab24b5830b5ed03e404006d (patch)
tree043e07baf151bab960421fbfc06af7e09bf9b67e /src
parent9f262811b79f2c3f2c52c03cc2947431a36e8fbe (diff)
Revert of Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (patchset #3 id:40001 of https://codereview.chromium.org/2339203002/ )
Reason for revert: Crashing blink https://codereview.chromium.org/2351743002/ Original issue's description: > Stop flattening GrCoordTransforms in parent GrFragmentProcessors. > > This changes moves to a model that iterates over GrCTs in a GrFP hierarchy when inserting transformations by GrGLSLPrimitiveProcessors. > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339203002 > > Committed: https://skia.googlesource.com/skia/+/d91237ee051523f439238042674ade99207fe4a6 TBR=egdaniel@google.com,robertphillips@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2351753002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp18
-rw-r--r--src/gpu/GrFragmentProcessor.cpp49
-rw-r--r--src/gpu/GrOvalRenderer.cpp37
-rw-r--r--src/gpu/GrPathProcessor.cpp77
-rw-r--r--src/gpu/GrProgramDesc.cpp2
-rw-r--r--src/gpu/batches/GrAAConvexPathRenderer.cpp15
-rw-r--r--src/gpu/batches/GrAnalyticRectBatch.cpp17
-rw-r--r--src/gpu/batches/GrMSAAPathRenderer.cpp9
-rw-r--r--src/gpu/batches/GrPLSPathRenderer.cpp53
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp40
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp15
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp37
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp22
-rw-r--r--src/gpu/gl/GrGLProgram.cpp11
-rw-r--r--src/gpu/gl/GrGLProgram.h1
-rw-r--r--src/gpu/glsl/GrGLSLFragmentProcessor.cpp52
-rw-r--r--src/gpu/glsl/GrGLSLFragmentProcessor.h32
-rw-r--r--src/gpu/glsl/GrGLSLGeometryProcessor.cpp113
-rw-r--r--src/gpu/glsl/GrGLSLGeometryProcessor.h32
-rw-r--r--src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp13
-rw-r--r--src/gpu/glsl/GrGLSLPrimitiveProcessor.h72
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp42
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.h12
-rw-r--r--src/gpu/instanced/InstanceProcessor.cpp7
-rw-r--r--src/gpu/vk/GrVkPipelineState.cpp5
25 files changed, 392 insertions, 391 deletions
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 497f6b76d5..1b496b3657 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -99,7 +99,8 @@ public:
gpArgs->fPositionVar,
gp.inLocalCoords()->fName,
gp.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
} else {
// emit transforms with position
this->emitTransforms(vertBuilder,
@@ -108,7 +109,8 @@ public:
gpArgs->fPositionVar,
gp.inPosition()->fName,
gp.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
}
// Setup coverage as pass through
@@ -148,8 +150,7 @@ public:
}
void setData(const GrGLSLProgramDataManager& pdman,
- const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
+ const GrPrimitiveProcessor& gp) override {
const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.viewMatrix())) {
@@ -171,7 +172,14 @@ public:
pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverage()));
fCoverage = dgp.coverage();
}
- this->setTransformDataHelper(dgp.fLocalMatrix, pdman, &transformIter);
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<DefaultGeoProc>().fLocalMatrix, pdman, index,
+ transforms);
}
private:
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 3dfe25ea28..a9d4a5e8a1 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -8,7 +8,6 @@
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
#include "GrInvariantOutput.h"
-#include "GrPipeline.h"
#include "GrProcOptInfo.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -82,10 +81,16 @@ void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
fCoordTransforms.push_back(transform);
fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_GrCoordSet;
SkDEBUGCODE(transform->setInProcessor();)
+ fNumTransformsExclChildren++;
}
int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child) {
- // Append the child's textures array to our textures array
+ // Append the child's transforms to our transforms array and the child's textures array to our
+ // textures array
+ if (!child->fCoordTransforms.empty()) {
+ fCoordTransforms.push_back_n(child->fCoordTransforms.count(),
+ child->fCoordTransforms.begin());
+ }
if (!child->fTextureAccesses.empty()) {
fTextureAccesses.push_back_n(child->fTextureAccesses.count(),
child->fTextureAccesses.begin());
@@ -115,10 +120,10 @@ void GrFragmentProcessor::notifyRefCntIsZero() const {
}
bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) const {
- if (this->numCoordTransforms() != that.numCoordTransforms()) {
+ if (this->numTransforms() != that.numTransforms()) {
return false;
}
- int count = this->numCoordTransforms();
+ int count = this->numTransforms();
for (int i = 0; i < count; ++i) {
if (this->coordTransform(i) != that.coordTransform(i)) {
return false;
@@ -403,39 +408,3 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProc
}
return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt));
}
-
-//////////////////////////////////////////////////////////////////////////////
-
-GrFragmentProcessor::Iter::Iter(const GrPipeline& pipeline) {
- for (int i = pipeline.numFragmentProcessors() - 1; i >= 0; --i) {
- fFPStack.push_back(&pipeline.getFragmentProcessor(i));
- }
-}
-
-const GrFragmentProcessor* GrFragmentProcessor::Iter::next() {
- if (fFPStack.empty()) {
- return nullptr;
- }
- const GrFragmentProcessor* back = fFPStack.back();
- fFPStack.pop_back();
- for (int i = back->numChildProcessors() - 1; i >= 0; --i) {
- fFPStack.push_back(&back->childProcessor(i));
- }
- return back;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-const GrCoordTransform* GrFragmentProcessor::CoordTransformIter::next() {
- if (!fCurrFP) {
- return nullptr;
- }
- while (fCTIdx == fCurrFP->numCoordTransforms()) {
- fCTIdx = 0;
- fCurrFP = fFPIter.next();
- if (!fCurrFP) {
- return nullptr;
- }
- }
- return &fCurrFP->coordTransform(fCTIdx++);
-}
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 90b2d8e4f1..a04aa00711 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -161,7 +161,8 @@ private:
gpArgs->fPositionVar,
cgp.fInPosition->fName,
cgp.fLocalMatrix,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
fragBuilder->codeAppend("float d = length(circleEdge.xy);");
fragBuilder->codeAppend("float distanceToOuterEdge = circleEdge.z * (1.0 - d);");
@@ -209,10 +210,14 @@ private:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override {}
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper(primProc.cast<CircleGeometryProcessor>().fLocalMatrix,
- pdman, &transformIter);
+ pdman, index, transforms);
}
private:
@@ -314,7 +319,8 @@ private:
gpArgs->fPositionVar,
egp.fInPosition->fName,
egp.fLocalMatrix,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// for outer curve
fragBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
@@ -351,10 +357,15 @@ private:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
- const EllipseGeometryProcessor& egp = primProc.cast<EllipseGeometryProcessor>();
- this->setTransformDataHelper(egp.fLocalMatrix, pdman, &transformIter);
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<EllipseGeometryProcessor>().fLocalMatrix,
+ pdman, index, transforms);
}
private:
@@ -461,7 +472,8 @@ private:
uniformHandler,
gpArgs->fPositionVar,
diegp.fInPosition->fName,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
SkAssertResult(fragBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@@ -513,8 +525,8 @@ private:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const DIEllipseGeometryProcessor& diegp = gp.cast<DIEllipseGeometryProcessor>();
if (!diegp.fViewMatrix.isIdentity() && !fViewMatrix.cheapEqualTo(diegp.fViewMatrix)) {
@@ -523,7 +535,6 @@ private:
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
}
private:
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index c90481b8da..aa776ec2fb 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -34,7 +34,7 @@ public:
}
// emit transforms
- this->emitTransforms(args.fVaryingHandler, args.fFPCoordTransformHandler);
+ this->emitTransforms(args.fVaryingHandler, args.fTransformsIn, args.fTransformsOut);
// Setup uniform color
if (pathProc.overrides().readsColor()) {
@@ -54,30 +54,34 @@ public:
}
void emitTransforms(GrGLSLVaryingHandler* varyingHandler,
- FPCoordTransformHandler* transformHandler) {
- int i = 0;
- while (const GrCoordTransform* coordTransform = transformHandler->nextCoordTransform()) {
- GrSLType varyingType =
- coordTransform->getMatrix().hasPerspective() ? kVec3f_GrSLType
- : kVec2f_GrSLType;
-
- SkString strVaryingName;
- strVaryingName.printf("TransformedCoord_%d", i);
- GrGLSLVertToFrag v(varyingType);
- GrGLVaryingHandler* glVaryingHandler = (GrGLVaryingHandler*) varyingHandler;
- fInstalledTransforms.push_back().fHandle =
- glVaryingHandler->addPathProcessingVarying(strVaryingName.c_str(),
- &v).toIndex();
- fInstalledTransforms.back().fType = varyingType;
-
- transformHandler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
- ++i;
+ 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++) {
+ GrSLType varyingType =
+ coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
+
+ SkString strVaryingName("MatrixCoord");
+ strVaryingName.appendf("_%i_%i", i, t);
+ GrGLSLVertToFrag v(varyingType);
+ GrGLVaryingHandler* glVaryingHandler = (GrGLVaryingHandler*) varyingHandler;
+ fInstalledTransforms[i][t].fHandle =
+ glVaryingHandler->addPathProcessingVarying(strVaryingName.c_str(),
+ &v).toIndex();
+ fInstalledTransforms[i][t].fType = varyingType;
+
+ (*tout)[i].emplace_back(SkString(v.fsIn()), varyingType);
+ }
}
}
void setData(const GrGLSLProgramDataManager& pd,
- const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
+ const GrPrimitiveProcessor& primProc) override {
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
if (pathProc.overrides().readsColor() && pathProc.color() != fColor) {
float c[4];
@@ -85,21 +89,28 @@ public:
pd.set4fv(fColorUniform, 1, c);
fColor = pathProc.color();
}
+ }
- int t = 0;
- while (const GrCoordTransform* coordTransform = transformIter.next()) {
- SkASSERT(fInstalledTransforms[t].fHandle.isValid());
- const SkMatrix& m = GetTransformMatrix(pathProc.localMatrix(), *coordTransform);
- if (fInstalledTransforms[t].fCurrentValue.cheapEqualTo(m)) {
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& coordTransforms) override {
+ const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
+ SkTArray<TransformVarying, true>& transforms = fInstalledTransforms[index];
+ int numTransforms = transforms.count();
+ for (int t = 0; t < numTransforms; ++t) {
+ SkASSERT(transforms[t].fHandle.isValid());
+ const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(),
+ *coordTransforms[t]);
+ if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
continue;
}
- fInstalledTransforms[t].fCurrentValue = m;
+ transforms[t].fCurrentValue = transform;
- SkASSERT(fInstalledTransforms[t].fType == kVec2f_GrSLType ||
- fInstalledTransforms[t].fType == kVec3f_GrSLType);
- unsigned components = fInstalledTransforms[t].fType == kVec2f_GrSLType ? 2 : 3;
- pd.setPathFragmentInputTransform(fInstalledTransforms[t].fHandle, components, m);
- ++t;
+ SkASSERT(transforms[t].fType == kVec2f_GrSLType ||
+ transforms[t].fType == kVec3f_GrSLType);
+ unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
+ pdman.setPathFragmentInputTransform(transforms[t].fHandle, components, transform);
}
}
@@ -111,7 +122,7 @@ private:
GrSLType fType = kVoid_GrSLType;
};
- SkTArray<TransformVarying, true> fInstalledTransforms;
+ SkSTArray<8, SkSTArray<2, TransformVarying, true> > fInstalledTransforms;
UniformHandle fColorUniform;
GrColor fColor;
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index c452d34900..a22063c3f4 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -101,7 +101,7 @@ static bool gen_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc,
fp.getGLSLProcessorKey(glslCaps, b);
return gen_meta_key(fp, glslCaps, primProc.getTransformKey(fp.coordTransforms(),
- fp.numCoordTransforms()), b);
+ fp.numTransformsExclChildren()), b);
}
bool GrProgramDesc::Build(GrProgramDesc* desc,
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index 224567acff..a24a0c5945 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -577,7 +577,8 @@ public:
gpArgs->fPositionVar,
qe.inPosition()->fName,
qe.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
SkAssertResult(fragBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@@ -613,8 +614,7 @@ public:
}
void setData(const GrGLSLProgramDataManager& pdman,
- const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
+ const GrPrimitiveProcessor& gp) override {
const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>();
if (qe.color() != fColor) {
float c[4];
@@ -622,7 +622,14 @@ public:
pdman.set4fv(fColorUniform, 1, c);
fColor = qe.color();
}
- this->setTransformDataHelper(qe.fLocalMatrix, pdman, &transformIter);
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<QuadEdgeEffect>().fLocalMatrix, pdman, index,
+ transforms);
}
private:
diff --git a/src/gpu/batches/GrAnalyticRectBatch.cpp b/src/gpu/batches/GrAnalyticRectBatch.cpp
index 8c0f419178..7be0ad33be 100644
--- a/src/gpu/batches/GrAnalyticRectBatch.cpp
+++ b/src/gpu/batches/GrAnalyticRectBatch.cpp
@@ -18,7 +18,6 @@
#include "batches/GrVertexBatch.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
-#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
@@ -121,7 +120,8 @@ public:
gpArgs->fPositionVar,
rgp.inPosition()->fName,
rgp.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// TODO: compute all these offsets, spans, and scales in the VS
fragBuilder->codeAppendf("float insetW = min(1.0, %s.x) - 0.5;",
@@ -194,10 +194,15 @@ public:
b->add32(0x0);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
- const RectGeometryProcessor& rgp = primProc.cast<RectGeometryProcessor>();
- this->setTransformDataHelper(rgp.fLocalMatrix, pdman,&transformIter);
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {}
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<RectGeometryProcessor>().fLocalMatrix, pdman,
+ index, transforms);
}
private:
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index 19dd3663e5..d6b5578d8a 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -148,8 +148,8 @@ public:
// emit transforms
this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- qp.inPosition()->fName, SkMatrix::I(),
- args.fFPCoordTransformHandler);
+ qp.inPosition()->fName, SkMatrix::I(), args.fTransformsIn,
+ args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
@@ -167,15 +167,14 @@ public:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
+ virtual void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const MSAAQuadProcessor& qp = gp.cast<MSAAQuadProcessor>();
if (!qp.viewMatrix().isIdentity()) {
float viewMatrix[3 * 3];
GrGLSLGetMatrix<3>(viewMatrix, qp.viewMatrix());
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
}
private:
diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp
index e8711c09de..81009a6a3c 100644
--- a/src/gpu/batches/GrPLSPathRenderer.cpp
+++ b/src/gpu/batches/GrPLSPathRenderer.cpp
@@ -333,8 +333,8 @@ public:
// emit transforms
this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- te.inPosition()->fName, te.localMatrix(),
- args.fFPCoordTransformHandler);
+ te.inPosition()->fName, te.localMatrix(), args.fTransformsIn,
+ args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
@@ -391,10 +391,16 @@ public:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
- this->setTransformDataHelper(gp.cast<PLSAATriangleEffect>().fLocalMatrix, pdman,
- &transformIter);
+ virtual void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<PLSAATriangleEffect>().fLocalMatrix, pdman,
+ index, transforms);
}
private:
@@ -516,8 +522,8 @@ public:
// emit transforms
this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- qe.inPosition()->fName, qe.localMatrix(),
- args.fFPCoordTransformHandler);
+ qe.inPosition()->fName, qe.localMatrix(), args.fTransformsIn,
+ args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
@@ -575,10 +581,16 @@ public:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
- this->setTransformDataHelper(gp.cast<PLSQuadEdgeEffect>().fLocalMatrix, pdman,
- &transformIter);
+ virtual void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<PLSQuadEdgeEffect>().fLocalMatrix, pdman,
+ index, transforms);
}
private:
@@ -668,8 +680,8 @@ public:
varyingHandler->emitAttributes(fe);
this->setupPosition(vsBuilder, gpArgs, fe.inPosition()->fName);
this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- fe.inPosition()->fName, fe.localMatrix(),
- args.fFPCoordTransformHandler);
+ fe.inPosition()->fName, fe.localMatrix(), args.fTransformsIn,
+ args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
@@ -704,8 +716,8 @@ public:
b->add32(key);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
+ virtual void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>();
pdman.set1f(fUseEvenOdd, fe.fUseEvenOdd);
if (fe.color() != fColor && !fe.colorIgnored()) {
@@ -714,7 +726,14 @@ public:
pdman.set4fv(fColorUniform, 1, c);
fColor = fe.color();
}
- this->setTransformDataHelper(fe.fLocalMatrix, pdman, &transformIter);
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<PLSFinishEffect>().fLocalMatrix, pdman,
+ index, transforms);
}
private:
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 798695d4ec..1894192d58 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -25,8 +25,8 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& primProc) override {
const GrConicEffect& ce = primProc.cast<GrConicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
@@ -47,7 +47,14 @@ public:
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(ce.coverageScale()));
fCoverageScale = ce.coverageScale();
}
- this->setTransformDataHelper(ce.localMatrix(), pdman, &transformIter);
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<GrConicEffect>().localMatrix(), pdman, index,
+ transforms);
}
private:
@@ -102,7 +109,8 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gpArgs->fPositionVar,
gp.inPosition()->fName,
gp.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// TODO: this precision check should actually be a check on the number of bits
// high and medium provide and the selection of the lowest level that suffices.
@@ -291,8 +299,8 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& primProc) override {
const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMatrix())) {
@@ -313,7 +321,14 @@ public:
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(qe.coverageScale()));
fCoverageScale = qe.coverageScale();
}
- this->setTransformDataHelper(qe.localMatrix(), pdman, &transformIter);
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<GrQuadEffect>().localMatrix(), pdman, index,
+ transforms);
}
private:
@@ -368,7 +383,8 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gpArgs->fPositionVar,
gp.inPosition()->fName,
gp.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
fragBuilder->codeAppendf("float edgeAlpha;");
@@ -500,8 +516,8 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& primProc) override {
const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
@@ -517,7 +533,6 @@ public:
pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color();
}
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
}
private:
@@ -569,7 +584,8 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
uniformHandler,
gpArgs->fPositionVar,
gp.inPosition()->fName,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 7f5366363f..20a4e937c0 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -60,7 +60,8 @@ public:
gpArgs->fPositionVar,
cte.inPosition()->fName,
cte.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
if (cte.maskFormat() == kARGB_GrMaskFormat) {
fragBuilder->codeAppendf("%s = ", args.fOutputColor);
@@ -83,8 +84,7 @@ public:
}
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
if (btgp.color() != fColor && !btgp.hasVertexColor()) {
float c[4];
@@ -92,7 +92,14 @@ public:
pdman.set4fv(fColorUniform, 1, c);
fColor = btgp.color();
}
- this->setTransformDataHelper(btgp.localMatrix(), pdman, &transformIter);
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<GrBitmapTextGeoProc>().localMatrix(), pdman,
+ index, transforms);
}
static inline void GenKey(const GrGeometryProcessor& proc,
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 9ce725b7e6..167cefa47e 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -817,8 +817,16 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&,
- FPCoordTransformIter&& transformIter) override;
+ void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<DashingCircleEffect>().localMatrix(), pdman,
+ index, transforms);
+ }
+
private:
UniformHandle fParamUniform;
UniformHandle fColorUniform;
@@ -871,7 +879,8 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gpArgs->fPositionVar,
dce.inPosition()->fName,
dce.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// transforms all points so that we can compare them to our test circle
fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
@@ -892,8 +901,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
}
void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
- const GrPrimitiveProcessor& processor,
- FPCoordTransformIter&& transformIter) {
+ const GrPrimitiveProcessor& processor) {
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
if (dce.color() != fColor) {
float c[4];
@@ -901,7 +909,6 @@ void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
pdman.set4fv(fColorUniform, 1, c);
fColor = dce.color();
}
- this->setTransformDataHelper(dce.localMatrix(), pdman, &transformIter);
}
void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
@@ -1030,8 +1037,15 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&,
- FPCoordTransformIter&& iter) override;
+ void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(primProc.cast<DashingLineEffect>().localMatrix(), pdman, index,
+ transforms);
+ }
private:
GrColor fColor;
@@ -1080,7 +1094,8 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gpArgs->fPositionVar,
de.inPosition()->fName,
de.localMatrix(),
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// transforms all points so that we can compare them to our test rect
fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
@@ -1119,8 +1134,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
}
void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
- const GrPrimitiveProcessor& processor,
- FPCoordTransformIter&& transformIter) {
+ const GrPrimitiveProcessor& processor) {
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
if (de.color() != fColor) {
float c[4];
@@ -1128,7 +1142,6 @@ void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
pdman.set4fv(fColorUniform, 1, c);
fColor = de.color();
}
- this->setTransformDataHelper(de.localMatrix(), pdman, &transformIter);
}
void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 5404b0c805..c74c5cec80 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -73,7 +73,8 @@ public:
uniformHandler,
gpArgs->fPositionVar,
dfTexEffect.inPosition()->fName,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// add varyings
GrGLSLVertToFrag recipScale(kFloat_GrSLType);
@@ -178,8 +179,7 @@ public:
fragBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
#ifdef SK_GAMMA_APPLY_TO_A8
const GrDistanceFieldA8TextGeoProc& dfTexEffect = proc.cast<GrDistanceFieldA8TextGeoProc>();
float distanceAdjust = dfTexEffect.getDistanceAdjust();
@@ -196,7 +196,6 @@ public:
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
}
static inline void GenKey(const GrGeometryProcessor& gp,
@@ -346,7 +345,8 @@ public:
uniformHandler,
gpArgs->fPositionVar,
dfTexEffect.inPosition()->fName,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
const char* textureSizeUniName = nullptr;
fTextureSizeUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
@@ -433,8 +433,7 @@ public:
fragBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
SkASSERT(fTextureSizeUni.isValid());
GrTexture* texture = proc.texture(0);
@@ -454,7 +453,6 @@ public:
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
}
static inline void GenKey(const GrGeometryProcessor& gp,
@@ -584,7 +582,8 @@ public:
uniformHandler,
gpArgs->fPositionVar,
dfTexEffect.inPosition()->fName,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn,
+ args.fTransformsOut);
// set up varyings
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
@@ -733,8 +732,8 @@ public:
fragBuilder->codeAppendf("%s = val;", args.fOutputCoverage);
}
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& processor,
- FPCoordTransformIter&& transformIter) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& processor) override {
SkASSERT(fDistanceAdjustUni.isValid());
const GrDistanceFieldLCDTextGeoProc& dflcd = processor.cast<GrDistanceFieldLCDTextGeoProc>();
@@ -753,7 +752,6 @@ public:
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
}
static inline void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index f34fce43b4..a87aa5ad5f 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -70,8 +70,7 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
// we set the textures, and uniforms for installed processors in a generic way, but subclasses
// of GLProgram determine how to set coord transforms
int nextSamplerIdx = 0;
- fGeometryProcessor->setData(fProgramDataManager, primProc,
- GrFragmentProcessor::CoordTransformIter(pipeline));
+ fGeometryProcessor->setData(fProgramDataManager, primProc);
this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextSamplerIdx);
this->setFragmentData(primProc, pipeline, &nextSamplerIdx);
@@ -108,10 +107,16 @@ void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
for (int i = 0; i < numProcessors; ++i) {
const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
fFragmentProcessors[i]->setData(fProgramDataManager, processor);
+ this->setTransformData(primProc, processor, i);
this->bindTextures(processor, pipeline.getAllowSRGBInputs(), nextSamplerIdx);
}
}
-
+void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrFragmentProcessor& processor,
+ int index) {
+ fGeometryProcessor->setTransformData(primProc, fProgramDataManager, index,
+ processor.coordTransforms());
+}
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline) {
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index 34037a2406..ea98d87915 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -120,6 +120,7 @@ protected:
// A helper to loop over effects, set the transforms (via subclass) and bind textures
void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&, int* nextSamplerIdx);
+ void setTransformData(const GrPrimitiveProcessor&, const GrFragmentProcessor&, int index);
// Helper for setData() that sets the view matrix and loads the render target height uniform
void setRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&);
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index 25cc14abca..9a58db77bd 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -43,16 +43,16 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
const GrFragmentProcessor& childProc = args.fFp.childProcessor(childIndex);
/*
- * TODO: Move textures and buffers to the iterator model used by coords.
- * We now want to find the subset of samplers that belong to the child and its descendants and
- * put that into childSamplers. To do so, we'll do a forwards linear search.
+ * We now want to find the subset of coords and samplers that belong to the child and its
+ * descendants and put that into childCoords and childSamplers. To do so, we'll do a forwards
+ * linear search.
*
* Explanation:
- * Each GrFragmentProcessor has a copy of all the textures of itself and all procs in its
- * subtree. For example, suppose we have frag proc A, who has two children B and D. B has a
- * child C, and D has two children E and F. Each frag proc's textures array contains its own
- * textures, followed by the textures of all its descendants (i.e. preorder traversal). Suppose
- * procs A, B, C, D, E, F have 1, 2, 1, 1, 3, 2 textures respectively.
+ * Each GrFragmentProcessor has a copy of all the transforms and textures of itself and
+ * all procs in its subtree. For example, suppose we have frag proc A, who has two children B
+ * and D. B has a child C, and D has two children E and F. Each frag proc's transforms array
+ * contains its own transforms, followed by the transforms of all its descendants (i.e. preorder
+ * traversal). Suppose procs A, B, C, D, E, F have 1, 2, 1, 1, 3, 2 transforms respectively.
*
* (A)
* [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2]
@@ -66,22 +66,28 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
* [c1] [e1,e2,e3] [f1,f2]
*
* So if we're inside proc A's emitCode, and A is about to call emitCode on proc D, we want the
- * EmitArgs that's passed onto D to only contain its and its descendants' textures. The
- * EmitArgs given to A would contain the textures [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2], and we want
+ * EmitArgs that's passed onto D to only contain its and its descendants' coords. The
+ * EmitArgs given to A would contain the transforms [a1,b1,b2,c1,d1,e1,e2,e3,f1,f2], and we want
* to extract the subset [d1,e1,e2,e3,f1,f2] to pass on to D. We can do this with a linear
- * search since we know that A has 1 texture (using A.numTexturesExclChildren()), and B's
- * subtree has 3 textures (using B.numTextures()), so we know the start of D's textures is
- * 4 after the start of A's textures.
- * Textures work the same way as textures.
+ * search since we know that A has 1 transform (using A.numTransformsExclChildren()), and B's
+ * subtree has 3 transforms (using B.numTransforms()), so we know the start of D's transforms is
+ * 4 after the start of A's transforms.
+ * Textures work the same way as transforms.
*/
+ int firstCoordAt = args.fFp.numTransformsExclChildren();
int firstTextureAt = args.fFp.numTexturesExclChildren();
int firstBufferAt = args.fFp.numBuffersExclChildren();
for (int i = 0; i < childIndex; ++i) {
+ firstCoordAt += args.fFp.childProcessor(i).numTransforms();
firstTextureAt += args.fFp.childProcessor(i).numTextures();
firstBufferAt += args.fFp.childProcessor(i).numBuffers();
}
+ SkTArray<GrShaderVar> childCoords;
const SamplerHandle* childTexSamplers = nullptr;
const SamplerHandle* childBufferSamplers = nullptr;
+ if (childProc.numTransforms() > 0) {
+ childCoords.push_back_n(childProc.numTransforms(), &args.fTransformedCoords[firstCoordAt]);
+ }
if (childProc.numTextures() > 0) {
childTexSamplers = &args.fTexSamplers[firstTextureAt];
}
@@ -99,7 +105,7 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
childProc,
outputColor,
inputColor,
- args.fTransformedCoords.childTransforms(childIndex),
+ childCoords,
childTexSamplers,
childBufferSamplers,
args.fGpImplementsDistanceVector);
@@ -108,19 +114,3 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
fragBuilder->onAfterChildProcEmitCode();
}
-
-//////////////////////////////////////////////////////////////////////////////
-
-using TransformedCoordVars = GrGLSLFragmentProcessor::TransformedCoordVars;
-TransformedCoordVars TransformedCoordVars::childTransforms(int childIdx) const {
- const GrFragmentProcessor* child = &fFP->childProcessor(childIdx);
- GrFragmentProcessor::Iter iter(fFP);
- int numToSkip = 0;
- while (true) {
- const GrFragmentProcessor* fp = iter.next();
- if (fp == child) {
- return TransformedCoordVars(child, fTransformedVars + numToSkip);
- }
- numToSkip += fp->numCoordTransforms();
- }
-}
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h
index 9889bcc9c6..f4a93ebe71 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.h
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h
@@ -33,30 +33,6 @@ public:
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle SamplerHandle;
- /**
- * When building a program from a GrPipeline this is used to provide the GrShaderVars that
- * contain the resulting transformed coords from each of a GrFragmentProcessor's
- * GrCoordTransforms. This allows the GrFragmentProcessor subclasses to refer to the transformed
- * coords in fragment code.
- */
- class TransformedCoordVars {
- public:
- TransformedCoordVars(const GrFragmentProcessor* fp, const GrShaderVar* vars)
- : fFP(fp)
- , fTransformedVars(vars) {}
-
- const GrShaderVar& operator[] (int i) const {
- SkASSERT(i >= 0 && i < fFP->numCoordTransforms());
- return fTransformedVars[i];
- }
-
- TransformedCoordVars childTransforms(int childIdx) const;
-
- private:
- const GrFragmentProcessor* fFP;
- const GrShaderVar* fTransformedVars;
- };
-
/** Called when the program stage should insert its code into the shaders. The code in each
shader will be in its own block ({}) and so locally scoped names will not collide across
stages.
@@ -74,7 +50,7 @@ public:
etc.) that allows the processor to communicate back similar known
info about its output.
@param transformedCoords Fragment shader variables containing the coords computed using
- each of the GrFragmentProcessor's GrCoordTransforms.
+ each of the GrFragmentProcessor's Coord Transforms.
@param texSamplers Contains one entry for each GrTextureAccess of the GrProcessor.
These can be passed to the builder to emit texture reads in the
generated code.
@@ -89,7 +65,7 @@ public:
const GrFragmentProcessor& fp,
const char* outputColor,
const char* inputColor,
- const TransformedCoordVars& transformedCoordVars,
+ const SkTArray<GrShaderVar>& transformedCoords,
const SamplerHandle* texSamplers,
const SamplerHandle* bufferSamplers,
bool gpImplementsDistanceVector)
@@ -99,7 +75,7 @@ public:
, fFp(fp)
, fOutputColor(outputColor)
, fInputColor(inputColor)
- , fTransformedCoords(transformedCoordVars)
+ , fTransformedCoords(transformedCoords)
, fTexSamplers(texSamplers)
, fBufferSamplers(bufferSamplers)
, fGpImplementsDistanceVector(gpImplementsDistanceVector) {}
@@ -109,7 +85,7 @@ public:
const GrFragmentProcessor& fFp;
const char* fOutputColor;
const char* fInputColor;
- const TransformedCoordVars& fTransformedCoords;
+ const SkTArray<GrShaderVar>& fTransformedCoords;
const SamplerHandle* fTexSamplers;
const SamplerHandle* fBufferSamplers;
bool fGpImplementsDistanceVector;
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index bea49e5069..ddbe8e133a 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -29,82 +29,71 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
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();
-
- const char* uniName;
+ 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;
+ fInstalledTransforms[i][t].fHandle =
+ uniformHandler->addUniform(kVertex_GrShaderFlag,
+ kMat33f_GrSLType, precision,
+ strUniName.c_str(),
+ &uniName).toIndex();
- fInstalledTransforms.push_back().fHandle = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kMat33f_GrSLType,
- precision,
- strUniName.c_str(),
- &uniName).toIndex();
- SkString strVaryingName;
- strVaryingName.printf("TransformedCoords_%d", i);
+ SkString strVaryingName("MatrixCoord");
+ strVaryingName.appendf("_%i_%i", i, t);
- 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);
- handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
+ SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
+ (*tout)[i].emplace_back(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,
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.h b/src/gpu/glsl/GrGLSLGeometryProcessor.h
index 6777620a88..d1e715f78a 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.h
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.h
@@ -22,11 +22,31 @@ public:
/* Any general emit code goes in the base class emitCode. Subclasses override onEmitCode */
void emitCode(EmitArgs&) override;
+ // By default we use the identity matrix
+ void setTransformData(const GrPrimitiveProcessor&,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) override {
+ this->setTransformDataHelper(SkMatrix::I(), pdman, index, transforms);
+ }
+
protected:
// A helper which subclasses can use if needed and used above in the default setTransformData().
void setTransformDataHelper(const SkMatrix& localMatrix,
const GrGLSLProgramDataManager& pdman,
- FPCoordTransformIter*);
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) {
+ SkTArray<TransformUniform, true>& procTransforms = fInstalledTransforms[index];
+ int numTransforms = transforms.count();
+ for (int t = 0; t < numTransforms; ++t) {
+ SkASSERT(procTransforms[t].fHandle.isValid());
+ const SkMatrix& transform = GetTransformMatrix(localMatrix, *transforms[t]);
+ if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) {
+ pdman.setSkMatrix(procTransforms[t].fHandle.toIndex(), transform);
+ procTransforms[t].fCurrentValue = transform;
+ }
+ }
+ }
// Emit a uniform matrix for each coord transform.
void emitTransforms(GrGLSLVertexBuilder* vb,
@@ -34,9 +54,10 @@ protected:
GrGLSLUniformHandler* uniformHandler,
const GrShaderVar& posVar,
const char* localCoords,
- FPCoordTransformHandler* handler) {
+ const TransformsIn& tin,
+ TransformsOut* tout) {
this->emitTransforms(vb, varyingHandler, uniformHandler,
- posVar, localCoords, SkMatrix::I(), handler);
+ posVar, localCoords, SkMatrix::I(), tin, tout);
}
// Emit pre-transformed coords as a vertex attribute per coord-transform.
@@ -46,7 +67,8 @@ protected:
const GrShaderVar& posVar,
const char* localCoords,
const SkMatrix& localMatrix,
- FPCoordTransformHandler*);
+ const TransformsIn&,
+ TransformsOut*);
struct GrGPArgs {
// The variable used by a GP to store its position. It can be
@@ -81,7 +103,7 @@ private:
SkMatrix fCurrentValue = SkMatrix::InvalidMatrix();
};
- SkTArray<TransformUniform, true> fInstalledTransforms;
+ SkSTArray<8, SkSTArray<2, TransformUniform, true> > fInstalledTransforms;
typedef GrGLSLPrimitiveProcessor INHERITED;
};
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index 5ae28a0bbc..c19239a5d5 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -47,16 +47,3 @@ void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLPPFragmentBuilder* fragBu
&stagedLocalVarName);
fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
}
-
-//////////////////////////////////////////////////////////////////////////////
-
-const GrCoordTransform* GrGLSLPrimitiveProcessor::FPCoordTransformHandler::nextCoordTransform() {
-#ifdef SK_DEBUG
- SkASSERT(nullptr == fCurr || fAddedCoord);
- fAddedCoord = false;
- fCurr = fIter.next();
- return fCurr;
-#else
- return fIter.next();
-#endif
-}
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
index d270fa18fe..6f3381f996 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
@@ -8,7 +8,6 @@
#ifndef GrGLSLPrimitiveProcessor_DEFINED
#define GrGLSLPrimitiveProcessor_DEFINED
-#include "GrFragmentProcessor.h"
#include "GrPrimitiveProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLSampler.h"
@@ -24,45 +23,14 @@ class GrGLSLVertexBuilder;
class GrGLSLPrimitiveProcessor {
public:
- using FPCoordTransformIter = GrFragmentProcessor::CoordTransformIter;
-
virtual ~GrGLSLPrimitiveProcessor() {}
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle SamplerHandle;
- /**
- * This class provides access to the GrCoordTransforms across all GrFragmentProcessors in a
- * GrPipeline. It is also used by the primitive processor to specify the fragment shader
- * variable that will hold the transformed coords for each GrCoordTransform. It is required that
- * the primitive processor iterate over each coord transform and insert a shader var result for
- * each. The GrGLSLFragmentProcessors will reference these variables in their fragment code.
- */
- class FPCoordTransformHandler : public SkNoncopyable {
- public:
- FPCoordTransformHandler(const GrPipeline& pipeline,
- SkTArray<GrShaderVar>* transformedCoordVars)
- : fIter(pipeline)
- , fTransformedCoordVars(transformedCoordVars) {}
-
- ~FPCoordTransformHandler() { SkASSERT(!this->nextCoordTransform());}
-
- const GrCoordTransform* nextCoordTransform();
-
- // 'args' are constructor params to GrShaderVar.
- template<typename... Args>
- void specifyCoordsForCurrCoordTransform(Args&&... args) {
- SkASSERT(!fAddedCoord);
- fTransformedCoordVars->emplace_back(std::forward<Args>(args)...);
- SkDEBUGCODE(fAddedCoord = true;)
- }
-
- private:
- GrFragmentProcessor::CoordTransformIter fIter;
- SkDEBUGCODE(bool fAddedCoord = false;)
- SkDEBUGCODE(const GrCoordTransform* fCurr = nullptr;)
- SkTArray<GrShaderVar>* fTransformedCoordVars;
- };
+ typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords;
+ typedef SkSTArray<8, ProcCoords> TransformsIn;
+ typedef SkSTArray<8, SkTArray<GrShaderVar>> TransformsOut;
struct EmitArgs {
EmitArgs(GrGLSLVertexBuilder* vertBuilder,
@@ -76,7 +44,8 @@ public:
const char* distanceVectorName,
const SamplerHandle* texSamplers,
const SamplerHandle* bufferSamplers,
- FPCoordTransformHandler* transformHandler)
+ const TransformsIn& transformsIn,
+ TransformsOut* transformsOut)
: fVertBuilder(vertBuilder)
, fFragBuilder(fragBuilder)
, fVaryingHandler(varyingHandler)
@@ -88,7 +57,8 @@ public:
, fDistanceVectorName(distanceVectorName)
, fTexSamplers(texSamplers)
, fBufferSamplers(bufferSamplers)
- , fFPCoordTransformHandler(transformHandler) {}
+ , fTransformsIn(transformsIn)
+ , fTransformsOut(transformsOut) {}
GrGLSLVertexBuilder* fVertBuilder;
GrGLSLPPFragmentBuilder* fFragBuilder;
GrGLSLVaryingHandler* fVaryingHandler;
@@ -100,7 +70,8 @@ public:
const char* fDistanceVectorName;
const SamplerHandle* fTexSamplers;
const SamplerHandle* fBufferSamplers;
- FPCoordTransformHandler* fFPCoordTransformHandler;
+ const TransformsIn& fTransformsIn;
+ TransformsOut* fTransformsOut;
};
/**
@@ -109,22 +80,21 @@ public:
*/
virtual void emitCode(EmitArgs&) = 0;
- /**
- * A GrGLSLPrimitiveProcessor instance can be reused with any GrGLSLPrimitiveProcessor that
- * produces the same stage key; this function reads data from a GrGLSLPrimitiveProcessor and
- * uploads any uniform variables required by the shaders created in emitCode(). The
- * GrPrimitiveProcessor parameter is guaranteed to be of the same type and to have an
- * identical processor key as the GrPrimitiveProcessor that created this
- * GrGLSLPrimitiveProcessor.
- * The subclass may use the transform iterator to perform any setup required for the particular
- * set of fp transform matrices, such as uploading via uniforms. The iterator will iterate over
- * the transforms in the same order as the TransformHandler passed to emitCode.
- */
- virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&,
- FPCoordTransformIter&&) = 0;
+ /** A GrGLSLPrimitiveProcessor instance can be reused with any GrGLSLPrimitiveProcessor that
+ produces the same stage key; this function reads data from a GrGLSLPrimitiveProcessor and
+ uploads any uniform variables required by the shaders created in emitCode(). The
+ GrPrimitiveProcessor parameter is guaranteed to be of the same type that created this
+ GrGLSLPrimitiveProcessor and to have an identical processor key as the one that created this
+ GrGLSLPrimitiveProcessor. */
+ virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) = 0;
static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoordTransform&);
+ virtual void setTransformData(const GrPrimitiveProcessor&,
+ const GrGLSLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& transforms) = 0;
+
protected:
void setupUniformColor(GrGLSLPPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 29470c4e2b..4d442f9752 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -53,9 +53,19 @@ bool GrGLSLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor,
// be sent to the GrGLSLPrimitiveProcessor in its emitCode function
const GrPrimitiveProcessor& primProc = this->primitiveProcessor();
+ for (int i = 0; i < this->pipeline().numFragmentProcessors(); i++) {
+ const GrFragmentProcessor& processor = this->pipeline().getFragmentProcessor(i);
+
+ SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
+ processor.gatherCoordTransforms(&procCoords);
+ }
+
this->emitAndInstallPrimProc(primProc, inputColor, inputCoverage);
- this->emitAndInstallFragProcs(inputColor, inputCoverage);
+ int numProcs = this->pipeline().numFragmentProcessors();
+ this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
+ this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
+ inputCoverage);
if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor,
@@ -99,8 +109,6 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers());
this->emitSamplers(proc, &texSamplers, &bufferSamplers);
- GrGLSLPrimitiveProcessor::FPCoordTransformHandler transformHandler(fPipeline,
- &fTransformedCoordVars);
GrGLSLGeometryProcessor::EmitArgs args(&fVS,
&fFS,
this->varyingHandler(),
@@ -112,7 +120,8 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
distanceVectorName,
texSamplers.begin(),
bufferSamplers.begin(),
- &transformHandler);
+ fCoordTransforms,
+ &fOutCoords);
fGeometryProcessor->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
@@ -122,21 +131,14 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
fFS.codeAppend("}");
}
-void GrGLSLProgramBuilder::emitAndInstallFragProcs(GrGLSLExpr4* color, GrGLSLExpr4* coverage) {
- int transformedCoordVarsIdx = 0;
- GrGLSLExpr4** inOut = &color;
- for (int i = 0; i < this->pipeline().numFragmentProcessors(); ++i) {
- if (i == this->pipeline().numColorFragmentProcessors()) {
- inOut = &coverage;
- }
+void GrGLSLProgramBuilder::emitAndInstallFragProcs(int procOffset,
+ int numProcs,
+ GrGLSLExpr4* inOut) {
+ for (int i = procOffset; i < numProcs; ++i) {
GrGLSLExpr4 output;
const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
- this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, &output);
- GrFragmentProcessor::Iter iter(&fp);
- while (const GrFragmentProcessor* fp = iter.next()) {
- transformedCoordVarsIdx += fp->numCoordTransforms();
- }
- **inOut = output;
+ this->emitAndInstallFragProc(fp, i, *inOut, &output);
+ *inOut = output;
}
}
@@ -144,7 +146,6 @@ void GrGLSLProgramBuilder::emitAndInstallFragProcs(GrGLSLExpr4* color, GrGLSLExp
// the fix is to allow effects to take the GrGLSLExpr4 directly
void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
int index,
- int transformedCoordVarsIdx,
const GrGLSLExpr4& input,
GrGLSLExpr4* output) {
// Program builders have a bit of state we need to clear with each effect
@@ -162,15 +163,13 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
SkSTArray<2, SamplerHandle> bufferSamplers(fp.numBuffers());
this->emitSamplers(fp, &texSamplers, &bufferSamplers);
- const GrShaderVar* coordVars = fTransformedCoordVars.begin() + transformedCoordVarsIdx;
- GrGLSLFragmentProcessor::TransformedCoordVars coords(&fp, coordVars);
GrGLSLFragmentProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
this->glslCaps(),
fp,
output->c_str(),
input.isOnes() ? nullptr : input.c_str(),
- coords,
+ fOutCoords[index],
texSamplers.begin(),
bufferSamplers.begin(),
this->primitiveProcessor().implementsDistanceVector());
@@ -419,4 +418,5 @@ void GrGLSLProgramBuilder::finalizeShaders() {
this->varyingHandler()->finalize();
fVS.finalize(kVertex_GrShaderFlag);
fFS.finalize(kFragment_GrShaderFlag);
+
}
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.h b/src/gpu/glsl/GrGLSLProgramBuilder.h
index 8a8cff55ad..27c84372c1 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.h
@@ -139,10 +139,9 @@ private:
void emitAndInstallPrimProc(const GrPrimitiveProcessor&,
GrGLSLExpr4* outputColor,
GrGLSLExpr4* outputCoverage);
- void emitAndInstallFragProcs(GrGLSLExpr4* colorInOut, GrGLSLExpr4* coverageInOut);
+ void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut);
void emitAndInstallFragProc(const GrFragmentProcessor&,
int index,
- int transformedCoordVarsIdx,
const GrGLSLExpr4& input,
GrGLSLExpr4* output);
void emitAndInstallXferProc(const GrXferProcessor&,
@@ -168,10 +167,11 @@ private:
void verify(const GrFragmentProcessor&);
#endif
- int fNumVertexSamplers;
- int fNumGeometrySamplers;
- int fNumFragmentSamplers;
- SkSTArray<4, GrShaderVar> fTransformedCoordVars;
+ GrGLSLPrimitiveProcessor::TransformsIn fCoordTransforms;
+ GrGLSLPrimitiveProcessor::TransformsOut fOutCoords;
+ int fNumVertexSamplers;
+ int fNumGeometrySamplers;
+ int fNumFragmentSamplers;
};
#endif
diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp
index 480155b683..2b05ec1683 100644
--- a/src/gpu/instanced/InstanceProcessor.cpp
+++ b/src/gpu/instanced/InstanceProcessor.cpp
@@ -80,10 +80,7 @@ public:
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override;
private:
- void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor&,
- FPCoordTransformIter&& transformIter) override {
- this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter);
- }
+ void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override {}
class VertexInputs;
class Backend;
@@ -391,7 +388,7 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gpArgs->fPositionVar.set(positionType, "deviceCoords");
this->emitTransforms(v, varyingHandler, uniHandler, gpArgs->fPositionVar, localCoords,
- args.fFPCoordTransformHandler);
+ args.fTransformsIn, args.fTransformsOut);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp
index 50250a5ead..23983854da 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -194,13 +194,14 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
SkSTArray<8, const GrTextureAccess*> textureBindings;
- fGeometryProcessor->setData(fDataManager, primProc,
- GrFragmentProcessor::CoordTransformIter(pipeline));
+ fGeometryProcessor->setData(fDataManager, primProc);
append_texture_bindings(primProc, &textureBindings);
for (int i = 0; i < fFragmentProcessors.count(); ++i) {
const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
fFragmentProcessors[i]->setData(fDataManager, processor);
+ fGeometryProcessor->setTransformData(primProc, fDataManager, i,
+ processor.coordTransforms());
append_texture_bindings(processor, &textureBindings);
}