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

Side by Side Diff: src/gpu/batches/GrTInstanceBatch.h

Issue 1352813003: add a ClassID function to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 3 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
« no previous file with comments | « src/gpu/batches/GrStrokeRectBatch.cpp ('k') | src/gpu/batches/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « src/gpu/batches/GrStrokeRectBatch.cpp ('k') | src/gpu/batches/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698