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 |
11 #include "GrVertexBatch.h" | 11 #include "GrVertexBatch.h" |
12 | 12 |
13 #include "GrBatchFlushState.h" | 13 #include "GrBatchFlushState.h" |
14 | 14 |
15 /** | 15 /** |
16 * GrTInstanceBatch is an optional template to help with writing batches | 16 * GrTInstanceBatch is an optional template to help with writing batches |
17 * To use this template, The 'Impl' must define the following statics: | 17 * To use this template, The 'Impl' must define the following statics: |
18 * A Geometry struct | 18 * A Geometry struct |
19 * | 19 * |
20 * static const int kVertsPerInstance | 20 * static const int kVertsPerInstance |
21 * static const int kIndicesPerInstance | 21 * static const int kIndicesPerInstance |
22 * | 22 * |
23 * const char* Name() | 23 * const char* Name() |
24 * | 24 * |
| 25 * void SetBounds(const Geometry& seedGeometry, SkRect* outBounds) |
| 26 * |
25 * bool CanCombine(const Geometry& mine, const Geometry& theirs, | 27 * bool CanCombine(const Geometry& mine, const Geometry& theirs, |
26 * const GrPipelineOptimizations&) | 28 * const GrPipelineOptimizations&) |
27 * | 29 * |
28 * const GrGeometryProcessor* CreateGP(const Geometry& seedGeometry, | 30 * const GrGeometryProcessor* CreateGP(const Geometry& seedGeometry, |
29 * const GrPipelineOptimizations& opts) | 31 * const GrPipelineOptimizations& opts) |
30 * | 32 * |
31 * const GrIndexBuffer* GetIndexBuffer(GrResourceProvider*) | 33 * const GrIndexBuffer* GetIndexBuffer(GrResourceProvider*) |
32 * | 34 * |
33 * Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, | 35 * Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, |
34 * const GrPipelineOptimizations& opts) | 36 * const GrPipelineOptimizations& opts) |
(...skipping 24 matching lines...) Expand all Loading... |
59 } | 61 } |
60 | 62 |
61 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 63 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
62 | 64 |
63 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which | 65 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which |
64 // is used to seed the batch with its initial geometry. After seeding, the
client should call | 66 // is used to seed the batch with its initial geometry. After seeding, the
client should call |
65 // init() so the Batch can initialize itself | 67 // init() so the Batch can initialize itself |
66 Geometry* geometry() { return &fGeoData[0]; } | 68 Geometry* geometry() { return &fGeoData[0]; } |
67 void init() { | 69 void init() { |
68 const Geometry& geo = fGeoData[0]; | 70 const Geometry& geo = fGeoData[0]; |
69 this->setBounds(geo.fDevRect); | 71 Impl::SetBounds(geo, &fBounds); |
70 } | 72 } |
71 | 73 |
72 private: | 74 private: |
73 GrTInstanceBatch() { | 75 GrTInstanceBatch() { |
74 this->initClassID<GrTInstanceBatch<Impl>>(); | 76 this->initClassID<GrTInstanceBatch<Impl>>(); |
75 | 77 |
76 // Push back an initial geometry | 78 // Push back an initial geometry |
77 fGeoData.push_back(); | 79 fGeoData.push_back(); |
78 } | 80 } |
79 | 81 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 132 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
131 this->joinBounds(that->bounds()); | 133 this->joinBounds(that->bounds()); |
132 return true; | 134 return true; |
133 } | 135 } |
134 | 136 |
135 GrPipelineOptimizations fOpts; | 137 GrPipelineOptimizations fOpts; |
136 SkSTArray<1, Geometry, true> fGeoData; | 138 SkSTArray<1, Geometry, true> fGeoData; |
137 }; | 139 }; |
138 | 140 |
139 #endif | 141 #endif |
OLD | NEW |