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 GrTInstanceBatch_DEFINED | 8 #ifndef GrTInstanceBatch_DEFINED |
9 #define GrTInstanceBatch_DEFINED | 9 #define GrTInstanceBatch_DEFINED |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 * const GrPipelineOptimizations& opts) | 33 * const GrPipelineOptimizations& opts) |
34 * | 34 * |
35 * const GrIndexBuffer* GetIndexBuffer(GrResourceProvider*) | 35 * const GrIndexBuffer* GetIndexBuffer(GrResourceProvider*) |
36 * | 36 * |
37 * Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, | 37 * Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, |
38 * const GrPipelineOptimizations& opts) | 38 * const GrPipelineOptimizations& opts) |
39 */ | 39 */ |
40 template <typename Impl> | 40 template <typename Impl> |
41 class GrTInstanceBatch : public GrVertexBatch { | 41 class GrTInstanceBatch : public GrVertexBatch { |
42 public: | 42 public: |
| 43 DEFINE_BATCH_CLASS_ID |
| 44 |
43 typedef typename Impl::Geometry Geometry; | 45 typedef typename Impl::Geometry Geometry; |
44 | 46 |
45 static GrTInstanceBatch* Create() { return new GrTInstanceBatch; } | 47 static GrTInstanceBatch* Create() { return new GrTInstanceBatch; } |
46 | 48 |
47 const char* name() const override { return Impl::Name(); } | 49 const char* name() const override { return Impl::Name(); } |
48 | 50 |
49 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 51 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
50 // When this is called on a batch, there is only one geometry bundle | 52 // When this is called on a batch, there is only one geometry bundle |
51 out->setKnownFourComponents(fGeoData[0].fColor); | 53 out->setKnownFourComponents(fGeoData[0].fColor); |
52 } | 54 } |
(...skipping 12 matching lines...) Expand all Loading... |
65 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which | 67 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which |
66 // is used to seed the batch with its initial geometry. After seeding, the
client should call | 68 // is used to seed the batch with its initial geometry. After seeding, the
client should call |
67 // init() so the Batch can initialize itself | 69 // init() so the Batch can initialize itself |
68 Geometry* geometry() { return &fGeoData[0]; } | 70 Geometry* geometry() { return &fGeoData[0]; } |
69 void init() { | 71 void init() { |
70 const Geometry& geo = fGeoData[0]; | 72 const Geometry& geo = fGeoData[0]; |
71 Impl::SetBounds(geo, &fBounds); | 73 Impl::SetBounds(geo, &fBounds); |
72 } | 74 } |
73 | 75 |
74 private: | 76 private: |
75 GrTInstanceBatch() { | 77 GrTInstanceBatch() : INHERITED(ClassID()) { |
76 this->initClassID<GrTInstanceBatch<Impl>>(); | |
77 | |
78 // Push back an initial geometry | 78 // Push back an initial geometry |
79 fGeoData.push_back(); | 79 fGeoData.push_back(); |
80 } | 80 } |
81 | 81 |
82 void onPrepareDraws(Target* target) override { | 82 void onPrepareDraws(Target* target) override { |
83 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom
etry(), fOpts)); | 83 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom
etry(), fOpts)); |
84 if (!gp) { | 84 if (!gp) { |
85 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 85 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
86 return; | 86 return; |
87 } | 87 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 fOpts = that->fOpts; | 129 fOpts = that->fOpts; |
130 } | 130 } |
131 | 131 |
132 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 132 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
133 this->joinBounds(that->bounds()); | 133 this->joinBounds(that->bounds()); |
134 return true; | 134 return true; |
135 } | 135 } |
136 | 136 |
137 GrPipelineOptimizations fOpts; | 137 GrPipelineOptimizations fOpts; |
138 SkSTArray<1, Geometry, true> fGeoData; | 138 SkSTArray<1, Geometry, true> fGeoData; |
| 139 |
| 140 typedef GrVertexBatch INHERITED; |
139 }; | 141 }; |
140 | 142 |
141 #endif | 143 #endif |
OLD | NEW |