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

Side by Side Diff: src/gpu/GrBatch.h

Issue 1127273007: Iterate over instanced draws in GrGpu rather than above GrBatchTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove dead code Created 5 years, 7 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/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatch.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 GrBatch_DEFINED 8 #ifndef GrBatch_DEFINED
9 #define GrBatch_DEFINED 9 #define GrBatch_DEFINED
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 void setBounds(const SkRect& newBounds) { fBounds = newBounds; } 107 void setBounds(const SkRect& newBounds) { fBounds = newBounds; }
108 108
109 void joinBounds(const SkRect& otherBounds) { 109 void joinBounds(const SkRect& otherBounds) {
110 return fBounds.joinPossiblyEmptyRect(otherBounds); 110 return fBounds.joinPossiblyEmptyRect(otherBounds);
111 } 111 }
112 112
113 /** Helper for rendering instances using an instanced index index buffer. Th is class creates the 113 /** Helper for rendering instances using an instanced index index buffer. Th is class creates the
114 space for the vertices and flushes the draws to the batch target.*/ 114 space for the vertices and flushes the draws to the batch target.*/
115 class InstancedHelper { 115 class InstancedHelper {
116 public: 116 public:
117 InstancedHelper() : fInstancesRemaining(0) {} 117 InstancedHelper() {}
118 /** Returns the allocated storage for the vertices. The caller should po pulate the before 118 /** Returns the allocated storage for the vertices. The caller should po pulate the before
119 vertices before calling issueDraws(). */ 119 vertices before calling issueDraws(). */
120 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr ide, 120 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr ide,
121 const GrIndexBuffer*, int verticesPerInstance, int indicesPer Instance, 121 const GrIndexBuffer*, int verticesPerInstance, int indicesPer Instance,
122 int instancesToDraw); 122 int instancesToDraw);
123 123
124 /** Call after init() to issue draws to the batch target.*/ 124 /** Call after init() to issue draws to the batch target.*/
125 void issueDraws(GrBatchTarget* batchTarget) { 125 void issueDraw(GrBatchTarget* batchTarget) {
126 SkASSERT(fVertices.instanceCount()); 126 SkASSERT(fVertices.instanceCount());
127 do { 127 batchTarget->draw(fVertices);
128 batchTarget->draw(fVertices);
129 } while (fVertices.nextInstances(&fInstancesRemaining, fMaxInstances PerDraw));
130 } 128 }
131 private: 129 private:
132 int fInstancesRemaining;
133 int fMaxInstancesPerDraw;
134 GrVertices fVertices; 130 GrVertices fVertices;
135 }; 131 };
136 132
137 static const int kVerticesPerQuad = 4; 133 static const int kVerticesPerQuad = 4;
138 static const int kIndicesPerQuad = 6; 134 static const int kIndicesPerQuad = 6;
139 135
140 /** A specialization of InstanceHelper for quad rendering. */ 136 /** A specialization of InstanceHelper for quad rendering. */
141 class QuadHelper : private InstancedHelper { 137 class QuadHelper : private InstancedHelper {
142 public: 138 public:
143 QuadHelper() : INHERITED() {} 139 QuadHelper() : INHERITED() {}
144 /** Finds the cached quad index buffer and reserves vertex space. Return s NULL on failure 140 /** Finds the cached quad index buffer and reserves vertex space. Return s NULL on failure
145 and on sucess a pointer to the vertex data that the caller should po pulate before 141 and on sucess a pointer to the vertex data that the caller should po pulate before
146 calling issueDraws(). */ 142 calling issueDraws(). */
147 void* init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToD raw); 143 void* init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToD raw);
148 144
149 using InstancedHelper::issueDraws; 145 using InstancedHelper::issueDraw;
150 146
151 private: 147 private:
152 typedef InstancedHelper INHERITED; 148 typedef InstancedHelper INHERITED;
153 }; 149 };
154 150
155 SkRect fBounds; 151 SkRect fBounds;
156 152
157 private: 153 private:
158 static uint32_t GenClassID() { 154 static uint32_t GenClassID() {
159 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The 155 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The
(...skipping 13 matching lines...) Expand all
173 static int32_t gCurrBatchClassID; 169 static int32_t gCurrBatchClassID;
174 170
175 SkDEBUGCODE(bool fUsed;) 171 SkDEBUGCODE(bool fUsed;)
176 172
177 int fNumberOfDraws; 173 int fNumberOfDraws;
178 174
179 typedef SkRefCnt INHERITED; 175 typedef SkRefCnt INHERITED;
180 }; 176 };
181 177
182 #endif 178 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698