OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef GrTestBatch_DEFINED | 8 #ifndef GrTestBatch_DEFINED |
9 #define GrTestBatch_DEFINED | 9 #define GrTestBatch_DEFINED |
10 | 10 |
11 #include "GrBatchTarget.h" | 11 #include "GrBatchFlushState.h" |
12 #include "GrGeometryProcessor.h" | 12 #include "GrGeometryProcessor.h" |
13 #include "GrVertexBuffer.h" | 13 #include "GrVertexBuffer.h" |
14 | 14 |
15 #include "batches/GrVertexBatch.h" | 15 #include "batches/GrVertexBatch.h" |
16 | 16 |
17 /* | 17 /* |
18 * A simple batch only for testing purposes which actually doesn't batch at all,
but can fit into | 18 * A simple batch only for testing purposes which actually doesn't batch at all,
but can fit into |
19 * the batch pipeline and generate arbitrary geometry | 19 * the batch pipeline and generate arbitrary geometry |
20 */ | 20 */ |
21 class GrTestBatch : public GrVertexBatch { | 21 class GrTestBatch : public GrVertexBatch { |
(...skipping 20 matching lines...) Expand all Loading... |
42 } | 42 } |
43 opt.getOverrideColorIfSet(&this->geoData(0)->fColor); | 43 opt.getOverrideColorIfSet(&this->geoData(0)->fColor); |
44 | 44 |
45 // setup batch properties | 45 // setup batch properties |
46 fBatch.fColorIgnored = !opt.readsColor(); | 46 fBatch.fColorIgnored = !opt.readsColor(); |
47 fBatch.fColor = this->geoData(0)->fColor; | 47 fBatch.fColor = this->geoData(0)->fColor; |
48 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 48 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); |
49 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 49 fBatch.fCoverageIgnored = !opt.readsCoverage(); |
50 } | 50 } |
51 | 51 |
52 void generateGeometry(GrBatchTarget* batchTarget) override { | |
53 batchTarget->initDraw(fGeometryProcessor, this->pipeline()); | |
54 | |
55 this->onGenerateGeometry(batchTarget); | |
56 } | |
57 | |
58 protected: | 52 protected: |
59 GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) { | 53 GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) { |
60 fGeometryProcessor.reset(SkRef(gp)); | 54 fGeometryProcessor.reset(SkRef(gp)); |
61 | 55 |
62 this->setBounds(bounds); | 56 this->setBounds(bounds); |
63 } | 57 } |
64 | 58 |
65 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce
ssor; } | 59 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce
ssor; } |
66 | 60 |
67 private: | 61 private: |
| 62 void onPrepareDraws(Target* target) override { |
| 63 target->initDraw(fGeometryProcessor, this->pipeline()); |
| 64 this->generateGeometry(target); |
| 65 } |
| 66 |
68 virtual Geometry* geoData(int index) = 0; | 67 virtual Geometry* geoData(int index) = 0; |
69 virtual const Geometry* geoData(int index) const = 0; | 68 virtual const Geometry* geoData(int index) const = 0; |
70 | 69 |
71 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override { | 70 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override { |
72 return false; | 71 return false; |
73 } | 72 } |
74 | 73 |
75 virtual void onGenerateGeometry(GrBatchTarget* batchTarget) = 0; | 74 virtual void generateGeometry(Target*) = 0; |
76 | 75 |
77 struct BatchTracker { | 76 struct BatchTracker { |
78 GrColor fColor; | 77 GrColor fColor; |
79 bool fUsesLocalCoords; | 78 bool fUsesLocalCoords; |
80 bool fColorIgnored; | 79 bool fColorIgnored; |
81 bool fCoverageIgnored; | 80 bool fCoverageIgnored; |
82 }; | 81 }; |
83 | 82 |
84 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; | 83 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor; |
85 BatchTracker fBatch; | 84 BatchTracker fBatch; |
86 }; | 85 }; |
87 | 86 |
88 #endif | 87 #endif |
OLD | NEW |