OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |