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

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

Issue 1295773003: fill rect batch refactor into separate batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 4 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
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 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
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
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
OLDNEW
« src/gpu/batches/GrAAFillRectBatch.cpp ('K') | « src/gpu/batches/GrBWFillRectBatch.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698