From 5045e501d2aec23e5f1e4b46346033ac3202c6b0 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 19 Jun 2018 01:40:57 +0000 Subject: 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 > Reviewed-by: Chris Dalton 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 Commit-Queue: Mike Klein --- tests/PrimitiveProcessorTest.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'tests/PrimitiveProcessorTest.cpp') diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 27902000c9..3a76e6c5e0 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -57,15 +57,15 @@ private: void onPrepareDraws(Target* target) override { class GP : public GrGeometryProcessor { public: - GP(int numAttribs) : INHERITED(kGP_ClassID), fNumAttribs(numAttribs) { + GP(int numAttribs) + : INHERITED(kGP_ClassID) { SkASSERT(numAttribs > 1); - fAttribNames.reset(new SkString[numAttribs]); - fAttributes.reset(new Attribute[numAttribs]); for (auto i = 0; i < numAttribs; ++i) { - fAttribNames[i].printf("attr%d", i); - fAttributes[i] = {fAttribNames[i].c_str(), kFloat2_GrVertexAttribType}; + fAttribNames.push_back().printf("attr%d", i); + } + for (auto i = 0; i < numAttribs; ++i) { + this->addVertexAttrib(fAttribNames[i].c_str(), kFloat2_GrVertexAttribType); } - this->setVertexAttributeCnt(numAttribs); } const char* name() const override { return "Dummy GP"; } @@ -76,7 +76,7 @@ private: const GP& gp = args.fGP.cast(); args.fVaryingHandler->emitAttributes(gp); this->writeOutputPosition(args.fVertBuilder, gpArgs, - gp.fAttributes[0].name()); + gp.getAttrib(0).name()); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; fragBuilder->codeAppendf("%s = half4(1);", args.fOutputColor); fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage); @@ -89,24 +89,17 @@ private: } void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* builder) const override { - builder->add32(fNumAttribs); + builder->add32(this->numAttribs()); } private: - const GrPrimitiveProcessor::Attribute& onVertexAttribute(int i) const override { - return fAttributes[i]; - } - - int fNumAttribs; - std::unique_ptr fAttribNames; - std::unique_ptr fAttributes; + SkTArray fAttribNames; typedef GrGeometryProcessor INHERITED; }; sk_sp gp(new GP(fNumAttribs)); QuadHelper helper; - size_t vertexStride = fNumAttribs * GrVertexAttribTypeSize(kFloat2_GrVertexAttribType); - SkASSERT(vertexStride == gp->debugOnly_vertexStride()); + size_t vertexStride = gp->getVertexStride(); SkPoint* vertices = reinterpret_cast(helper.init(target, vertexStride, 1)); SkPointPriv::SetRectTriStrip(vertices, 0.f, 0.f, 1.f, 1.f, vertexStride); helper.recordDraw(target, gp.get(), -- cgit v1.2.3