aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ops/GrLatticeOp.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2018-06-19 01:40:57 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 01:41:10 +0000
commit5045e501d2aec23e5f1e4b46346033ac3202c6b0 (patch)
treeb0179c300d6bc1822b0d945be812fff267bb414a /src/gpu/ops/GrLatticeOp.cpp
parent63b3bfb711d7e3d4f9ad75681d77a69a3c454ab0 (diff)
Revert "Change how vertex/instance attributes are handled in geometry processors."
This reverts commit 19c1233c447f625c2522e7ecd0a0adecc629bb2f. Reason for revert: want to make sure Google3 can roll Original change's description: > Change how vertex/instance attributes are handled in geometry processors. > > * No longer register vertex/instance attributes on base class, just counts > > * Separate instance and vertex attributes and remove InputRate and offset > > * Make attributes constexpr where possible > > Change-Id: I1f1d5e772fa177a96d2aeb805aab7b69f35bfae6 > Reviewed-on: https://skia-review.googlesource.com/132405 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Chris Dalton <csmartdalton@google.com> TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com Change-Id: I4800632515e14fbf54af52826928ac915657b59f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/135661 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/gpu/ops/GrLatticeOp.cpp')
-rw-r--r--src/gpu/ops/GrLatticeOp.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 7bfa72ec94..5903231cb2 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -62,19 +62,19 @@ public:
latticeGP.fColorSpaceXform.get());
args.fVaryingHandler->emitAttributes(latticeGP);
- this->writeOutputPosition(args.fVertBuilder, gpArgs, latticeGP.kPositions.name());
+ this->writeOutputPosition(args.fVertBuilder, gpArgs, latticeGP.fPositions.name());
this->emitTransforms(args.fVertBuilder,
args.fVaryingHandler,
args.fUniformHandler,
- latticeGP.kTextureCoords.asShaderVar(),
+ latticeGP.fTextureCoords.asShaderVar(),
args.fFPCoordTransformHandler);
args.fFragBuilder->codeAppend("float2 textureCoords;");
- args.fVaryingHandler->addPassThroughAttribute(latticeGP.kTextureCoords,
+ args.fVaryingHandler->addPassThroughAttribute(&latticeGP.fTextureCoords,
"textureCoords");
args.fFragBuilder->codeAppend("float4 textureDomain;");
args.fVaryingHandler->addPassThroughAttribute(
- latticeGP.kTextureDomain, "textureDomain", Interpolation::kCanBeFlat);
- args.fVaryingHandler->addPassThroughAttribute(latticeGP.kColors, args.fOutputColor,
+ &latticeGP.fTextureDomain, "textureDomain", Interpolation::kCanBeFlat);
+ args.fVaryingHandler->addPassThroughAttribute(&latticeGP.fColors, args.fOutputColor,
Interpolation::kCanBeFlat);
args.fFragBuilder->codeAppendf("%s = ", args.fOutputColor);
args.fFragBuilder->appendTextureLookupAndModulate(
@@ -95,31 +95,24 @@ private:
LatticeGP(sk_sp<GrTextureProxy> proxy, sk_sp<GrColorSpaceXform> csxf,
GrSamplerState::Filter filter)
: INHERITED(kLatticeGP_ClassID), fColorSpaceXform(std::move(csxf)) {
+ fPositions = this->addVertexAttrib("position", kFloat2_GrVertexAttribType);
fSampler.reset(std::move(proxy), filter);
this->addTextureSampler(&fSampler);
- this->setVertexAttributeCnt(4);
+ fTextureCoords = this->addVertexAttrib("textureCoords", kFloat2_GrVertexAttribType);
+ fTextureDomain = this->addVertexAttrib("textureDomain", kFloat4_GrVertexAttribType);
+ fColors = this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType);
}
- const Attribute& onVertexAttribute(int i) const override {
- return IthAttribute(i, kPositions, kTextureCoords, kTextureDomain, kColors);
- }
-
- static constexpr Attribute kPositions = {"position", kFloat2_GrVertexAttribType};
- static constexpr Attribute kTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType};
- static constexpr Attribute kTextureDomain = {"textureDomain", kFloat4_GrVertexAttribType};
- static constexpr Attribute kColors = {"color", kUByte4_norm_GrVertexAttribType};
-
+ Attribute fPositions;
+ Attribute fTextureCoords;
+ Attribute fTextureDomain;
+ Attribute fColors;
sk_sp<GrColorSpaceXform> fColorSpaceXform;
TextureSampler fSampler;
typedef GrGeometryProcessor INHERITED;
};
-constexpr GrPrimitiveProcessor::Attribute LatticeGP::kPositions;
-constexpr GrPrimitiveProcessor::Attribute LatticeGP::kTextureCoords;
-constexpr GrPrimitiveProcessor::Attribute LatticeGP::kTextureDomain;
-constexpr GrPrimitiveProcessor::Attribute LatticeGP::kColors;
-
class NonAALatticeOp final : public GrMeshDrawOp {
private:
using Helper = GrSimpleMeshDrawOpHelper;
@@ -207,10 +200,7 @@ private:
return;
}
- static constexpr size_t kVertexStide =
- sizeof(SkPoint) + sizeof(SkPoint) + sizeof(SkRect) + sizeof(uint32_t);
- SkASSERT(kVertexStide == gp->debugOnly_vertexStride());
-
+ size_t vertexStride = gp->getVertexStride();
int patchCnt = fPatches.count();
int numRects = 0;
for (int i = 0; i < patchCnt; i++) {
@@ -223,7 +213,7 @@ private:
sk_sp<const GrBuffer> indexBuffer = target->resourceProvider()->refQuadIndexBuffer();
PatternHelper helper(GrPrimitiveType::kTriangles);
- void* vertices = helper.init(target, kVertexStide, indexBuffer.get(), kVertsPerRect,
+ void* vertices = helper.init(target, vertexStride, indexBuffer.get(), kVertsPerRect,
kIndicesPerRect, numRects);
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
@@ -251,7 +241,7 @@ private:
static const Sk4f kFlipMuls(1.f, -1.f, 1.f, -1.f);
while (patch.fIter->next(&srcR, &dstR)) {
auto vertices = reinterpret_cast<LatticeGP::Vertex*>(verts);
- SkPointPriv::SetRectTriStrip(&vertices->fPosition, dstR, kVertexStide);
+ SkPointPriv::SetRectTriStrip(&vertices->fPosition, dstR, vertexStride);
Sk4f coords(SkIntToScalar(srcR.fLeft), SkIntToScalar(srcR.fTop),
SkIntToScalar(srcR.fRight), SkIntToScalar(srcR.fBottom));
Sk4f domain = coords + kDomainOffsets;
@@ -262,7 +252,7 @@ private:
domain = SkNx_shuffle<0, 3, 2, 1>(kFlipMuls * domain + kFlipOffsets);
}
SkPointPriv::SetRectTriStrip(&vertices->fTextureCoords, coords[0], coords[1],
- coords[2], coords[3], kVertexStide);
+ coords[2], coords[3], vertexStride);
for (int j = 0; j < kVertsPerRect; ++j) {
vertices[j].fTextureDomain = {domain[0], domain[1], domain[2], domain[3]};
}
@@ -270,13 +260,13 @@ private:
for (int j = 0; j < kVertsPerRect; ++j) {
vertices[j].fColor = patch.fColor;
}
- verts += kVertsPerRect * kVertexStide;
+ verts += kVertsPerRect * vertexStride;
}
// If we didn't handle it above, apply the matrix here.
if (!isScaleTranslate) {
SkPoint* positions = reinterpret_cast<SkPoint*>(patchVerts);
- SkMatrixPriv::MapPointsWithStride(patch.fViewMatrix, positions, kVertexStide,
+ SkMatrixPriv::MapPointsWithStride(patch.fViewMatrix, positions, vertexStride,
kVertsPerRect * patch.fIter->numRectsToDraw());
}
}