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

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

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 4 years, 9 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/GrDrawPathBatch.cpp ('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, this->pipeline()); 100 target->initDraw(gp);
101 101
102 size_t vertexStride = gp->getVertexStride(); 102 size_t vertexStride = gp->getVertexStride();
103 103
104 SkASSERT(vertexStride == sizeof(SkPoint) + (hasLocalCoords ? sizeof(SkPoint) : 0) 104 SkASSERT(vertexStride == sizeof(SkPoint) + (hasLocalCoords ? sizeof(SkPoint) : 0)
105 + sizeof(GrColor)); 105 + sizeof(GrColor));
106 106
107 int instanceCount = fGeoData.count(); 107 int instanceCount = fGeoData.count();
108 108
109 const GrVertexBuffer* vertexBuffer; 109 const GrVertexBuffer* vertexBuffer;
110 int firstVertex; 110 int firstVertex;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 *(GrColor*)((intptr_t)verts + colorOffset) = args.fColors[j]; 149 *(GrColor*)((intptr_t)verts + colorOffset) = args.fColors[j];
150 } 150 }
151 if (hasLocalCoords) { 151 if (hasLocalCoords) {
152 *(SkPoint*)((intptr_t)verts + texOffset) = args.fLocalCoords[j]; 152 *(SkPoint*)((intptr_t)verts + texOffset) = args.fLocalCoords[j];
153 } 153 }
154 verts = (void*)((intptr_t)verts + vertexStride); 154 verts = (void*)((intptr_t)verts + vertexStride);
155 vertexOffset++; 155 vertexOffset++;
156 } 156 }
157 } 157 }
158 158
159 GrVertices vertices; 159 GrMesh mesh;
160 if (indices) { 160 if (indices) {
161 vertices.initIndexed(this->primitiveType(), vertexBuffer, indexBuffer, f irstVertex, 161 mesh.initIndexed(this->primitiveType(), vertexBuffer, indexBuffer, first Vertex,
162 firstIndex, fVertexCount, fIndexCount); 162 firstIndex, fVertexCount, fIndexCount);
163 163
164 } else { 164 } else {
165 vertices.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexC ount); 165 mesh.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexCount );
166 } 166 }
167 target->draw(vertices); 167 target->draw(mesh);
168 } 168 }
169 169
170 bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { 170 bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
171 GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>(); 171 GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>();
172 172
173 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(), 173 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(),
174 that->bounds(), caps)) { 174 that->bounds(), caps)) {
175 return false; 175 return false;
176 } 176 }
177 177
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 geometry.fColor = GrRandomColor(random); 317 geometry.fColor = GrRandomColor(random);
318 return GrDrawVerticesBatch::Create(geometry, type, viewMatrix, 318 return GrDrawVerticesBatch::Create(geometry, type, viewMatrix,
319 positions.begin(), vertexCount, 319 positions.begin(), vertexCount,
320 indices.begin(), hasIndices ? vertexCount : 0, 320 indices.begin(), hasIndices ? vertexCount : 0,
321 colors.begin(), 321 colors.begin(),
322 texCoords.begin(), 322 texCoords.begin(),
323 bounds); 323 bounds);
324 } 324 }
325 325
326 #endif 326 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawPathBatch.cpp ('k') | src/gpu/batches/GrNinePatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698