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

Side by Side Diff: src/gpu/batches/GrDrawVerticesBatch.cpp

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 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/GrDrawBatch.h ('k') | src/gpu/batches/GrNinePatch.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 #include "GrDrawVerticesBatch.h" 8 #include "GrDrawVerticesBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 fGeoData[0].fLocalCoords.reset(); 90 fGeoData[0].fLocalCoords.reset();
91 } 91 }
92 } 92 }
93 93
94 void GrDrawVerticesBatch::onPrepareDraws(Target* target) const { 94 void GrDrawVerticesBatch::onPrepareDraws(Target* target) const {
95 bool hasLocalCoords = !fGeoData[0].fLocalCoords.isEmpty(); 95 bool hasLocalCoords = !fGeoData[0].fLocalCoords.isEmpty();
96 int colorOffset = -1, texOffset = -1; 96 int colorOffset = -1, texOffset = -1;
97 SkAutoTUnref<const GrGeometryProcessor> gp( 97 SkAutoTUnref<const GrGeometryProcessor> gp(
98 set_vertex_attributes(hasLocalCoords, &colorOffset, &texOffset, fViewMat rix, 98 set_vertex_attributes(hasLocalCoords, &colorOffset, &texOffset, fViewMat rix,
99 fCoverageIgnored)); 99 fCoverageIgnored));
100 target->initDraw(gp);
101
102 size_t vertexStride = gp->getVertexStride(); 100 size_t vertexStride = gp->getVertexStride();
103 101
104 SkASSERT(vertexStride == sizeof(SkPoint) + (hasLocalCoords ? sizeof(SkPoint) : 0) 102 SkASSERT(vertexStride == sizeof(SkPoint) + (hasLocalCoords ? sizeof(SkPoint) : 0)
105 + sizeof(GrColor)); 103 + sizeof(GrColor));
106 104
107 int instanceCount = fGeoData.count(); 105 int instanceCount = fGeoData.count();
108 106
109 const GrBuffer* vertexBuffer; 107 const GrBuffer* vertexBuffer;
110 int firstVertex; 108 int firstVertex;
111 109
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 155 }
158 156
159 GrMesh mesh; 157 GrMesh mesh;
160 if (indices) { 158 if (indices) {
161 mesh.initIndexed(this->primitiveType(), vertexBuffer, indexBuffer, first Vertex, 159 mesh.initIndexed(this->primitiveType(), vertexBuffer, indexBuffer, first Vertex,
162 firstIndex, fVertexCount, fIndexCount); 160 firstIndex, fVertexCount, fIndexCount);
163 161
164 } else { 162 } else {
165 mesh.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexCount ); 163 mesh.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexCount );
166 } 164 }
167 target->draw(mesh); 165 target->draw(gp, mesh);
168 } 166 }
169 167
170 bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { 168 bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
171 GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>(); 169 GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>();
172 170
173 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(), 171 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(),
174 that->bounds(), caps)) { 172 that->bounds(), caps)) {
175 return false; 173 return false;
176 } 174 }
177 175
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 geometry.fColor = GrRandomColor(random); 315 geometry.fColor = GrRandomColor(random);
318 return GrDrawVerticesBatch::Create(geometry, type, viewMatrix, 316 return GrDrawVerticesBatch::Create(geometry, type, viewMatrix,
319 positions.begin(), vertexCount, 317 positions.begin(), vertexCount,
320 indices.begin(), hasIndices ? vertexCount : 0, 318 indices.begin(), hasIndices ? vertexCount : 0,
321 colors.begin(), 319 colors.begin(),
322 texCoords.begin(), 320 texCoords.begin(),
323 bounds); 321 bounds);
324 } 322 }
325 323
326 #endif 324 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawBatch.h ('k') | src/gpu/batches/GrNinePatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698