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

Side by Side Diff: tests/PrimitiveProcessorTest.cpp

Issue 2248323003: Simplify adding attributes to GrGeometryProcessor (Closed) Base URL: https://chromium.googlesource.com/skia.git@xformhelper
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // This is a GPU-backend specific test. It relies on static intializers to work 8 // This is a GPU-backend specific test. It relies on static intializers to work
9 9
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 this->setBounds(SkRect::MakeWH(1.f, 1.f), HasAABloat::kNo, IsZeroArea::k No); 44 this->setBounds(SkRect::MakeWH(1.f, 1.f), HasAABloat::kNo, IsZeroArea::k No);
45 } 45 }
46 46
47 private: 47 private:
48 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; } 48 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; }
49 void onPrepareDraws(Target* target) const override { 49 void onPrepareDraws(Target* target) const override {
50 class GP : public GrGeometryProcessor { 50 class GP : public GrGeometryProcessor {
51 public: 51 public:
52 GP(int numAttribs) { 52 GP(int numAttribs) {
53 this->initClassID<GP>(); 53 this->initClassID<GP>();
54 SkASSERT(numAttribs > 1); 54 SkASSERT(numAttribs > 1);
robertphillips 2016/08/17 16:11:32 fAttribNames doesn't seem particularly useful.
bsalomon 2016/08/17 16:17:44 Done.
bsalomon 2016/08/17 16:19:27 Actually, it sadly is useful. The Attribute struct
55 for (auto i = 0; i < numAttribs; ++i) { 55 for (auto i = 0; i < numAttribs; ++i) {
56 fAttribNames.push_back().printf("attr%d", i); 56 fAttribNames.push_back().printf("attr%d", i);
57 } 57 }
58 for (auto i = 0; i < numAttribs; ++i) { 58 for (auto i = 0; i < numAttribs; ++i) {
robertphillips 2016/08/17 16:11:32 rm attribute ?
bsalomon 2016/08/17 16:17:44 Done.
59 Attribute attribute; 59 Attribute attribute;
60 attribute.fType = kVec2f_GrVertexAttribType; 60 this->addVertexAttrib(fAttribNames[i].c_str(), kVec2f_GrVert exAttribType);
61 attribute.fName = fAttribNames[i].c_str();
62 attribute.fOffset = 2 * sizeof(float) * i;
63 attribute.fPrecision = kDefault_GrSLPrecision;
64 this->addVertexAttrib(attribute);
65 } 61 }
66 }; 62 };
67 const char* name() const override { return "Dummy GP"; } 63 const char* name() const override { return "Dummy GP"; }
68 64
69 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) cons t override { 65 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) cons t override {
70 class GLSLGP : public GrGLSLGeometryProcessor { 66 class GLSLGP : public GrGLSLGeometryProcessor {
71 public: 67 public:
72 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { 68 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
73 const GP& gp = args.fGP.cast<GP>(); 69 const GP& gp = args.fGP.cast<GP>();
74 args.fVaryingHandler->emitAttributes(gp); 70 args.fVaryingHandler->emitAttributes(gp);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // This one should fail. 132 // This one should fail.
137 batch.reset(new Batch(attribCnt+1)); 133 batch.reset(new Batch(attribCnt+1));
138 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch); 134 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch);
139 context->flush(); 135 context->flush();
140 #if GR_GPU_STATS 136 #if GR_GPU_STATS
141 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); 137 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
142 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1) ; 138 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1) ;
143 #endif 139 #endif
144 } 140 }
145 #endif 141 #endif
OLDNEW
« src/gpu/GrGeometryProcessor.h ('K') | « src/gpu/instanced/InstanceProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698