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

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

Issue 1353553002: Create append methods in batch namespaces (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rob's feedback 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/GrNonAAStrokeRectBatch.cpp ('k') | no next file » | 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
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 InvariantOutputCoverage(GrInitInvariantOutput* out) 25 * void InvariantOutputCoverage(GrInitInvariantOutput* out)
26 * 26 *
27 * void SetBounds(const Geometry& seedGeometry, SkRect* outBounds) 27 * void SetBounds(const Geometry& seedGeometry, SkRect* outBounds)
28 * 28 *
29 * void UpdateBoundsAfterAppend(const Geometry& lastGeometry, SkRect* curren tBounds)
30 *
29 * bool CanCombine(const Geometry& mine, const Geometry& theirs, 31 * bool CanCombine(const Geometry& mine, const Geometry& theirs,
30 * const GrPipelineOptimizations&) 32 * const GrPipelineOptimizations&)
31 * 33 *
32 * const GrGeometryProcessor* CreateGP(const Geometry& seedGeometry, 34 * const GrGeometryProcessor* CreateGP(const Geometry& seedGeometry,
33 * const GrPipelineOptimizations& opts) 35 * const GrPipelineOptimizations& opts)
34 * 36 *
35 * const GrIndexBuffer* GetIndexBuffer(GrResourceProvider*) 37 * const GrIndexBuffer* GetIndexBuffer(GrResourceProvider*)
36 * 38 *
37 * Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo, 39 * Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo,
38 * const GrPipelineOptimizations& opts) 40 * const GrPipelineOptimizations& opts)
(...skipping 18 matching lines...) Expand all
57 Impl::InitInvariantOutputCoverage(out); 59 Impl::InitInvariantOutputCoverage(out);
58 } 60 }
59 61
60 void initBatchTracker(const GrPipelineOptimizations& opt) override { 62 void initBatchTracker(const GrPipelineOptimizations& opt) override {
61 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 63 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
62 fOpts = opt; 64 fOpts = opt;
63 } 65 }
64 66
65 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 67 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
66 68
67 // to avoid even the initial copy of the struct, we have a getter for the fi rst item which 69 // After seeding, the client should call init() so the Batch can initialize itself
68 // is used to seed the batch with its initial geometry. After seeding, the client should call
69 // init() so the Batch can initialize itself
70 Geometry* geometry() { return &fGeoData[0]; }
71 void init() { 70 void init() {
72 const Geometry& geo = fGeoData[0]; 71 const Geometry& geo = fGeoData[0];
73 Impl::SetBounds(geo, &fBounds); 72 Impl::SetBounds(geo, &fBounds);
74 } 73 }
75 74
75 void updateBoundsAfterAppend() {
76 const Geometry& geo = fGeoData.back();
77 Impl::UpdateBoundsAfterAppend(geo, &fBounds);
78 }
79
76 private: 80 private:
77 GrTInstanceBatch() : INHERITED(ClassID()) { 81 GrTInstanceBatch() : INHERITED(ClassID()) {}
78 // Push back an initial geometry
79 fGeoData.push_back();
80 }
81 82
82 void onPrepareDraws(Target* target) override { 83 void onPrepareDraws(Target* target) override {
83 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom etry(), fOpts)); 84 SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeom etry(), fOpts));
84 if (!gp) { 85 if (!gp) {
85 SkDebugf("Couldn't create GrGeometryProcessor\n"); 86 SkDebugf("Couldn't create GrGeometryProcessor\n");
86 return; 87 return;
87 } 88 }
88 89
89 target->initDraw(gp, this->pipeline()); 90 target->initDraw(gp, this->pipeline());
90 91
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return true; 135 return true;
135 } 136 }
136 137
137 GrPipelineOptimizations fOpts; 138 GrPipelineOptimizations fOpts;
138 SkSTArray<1, Geometry, true> fGeoData; 139 SkSTArray<1, Geometry, true> fGeoData;
139 140
140 typedef GrVertexBatch INHERITED; 141 typedef GrVertexBatch INHERITED;
141 }; 142 };
142 143
143 #endif 144 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNonAAStrokeRectBatch.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698