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

Side by Side Diff: src/gpu/batches/GrAALinearizingConvexPathRenderer.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/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAALinearizingConvexPathRenderer.h" 9 #include "GrAALinearizingConvexPathRenderer.h"
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks(); 158 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks();
159 fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage(); 159 fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage();
160 } 160 }
161 161
162 void draw(GrVertexBatch::Target* target, const GrPipeline* pipeline, int ver texCount, 162 void draw(GrVertexBatch::Target* target, const GrPipeline* pipeline, int ver texCount,
163 size_t vertexStride, void* vertices, int indexCount, uint16_t* ind ices) const { 163 size_t vertexStride, void* vertices, int indexCount, uint16_t* ind ices) const {
164 if (vertexCount == 0 || indexCount == 0) { 164 if (vertexCount == 0 || indexCount == 0) {
165 return; 165 return;
166 } 166 }
167 const GrVertexBuffer* vertexBuffer; 167 const GrVertexBuffer* vertexBuffer;
168 GrVertices info; 168 GrMesh mesh;
169 int firstVertex; 169 int firstVertex;
170 void* verts = target->makeVertexSpace(vertexStride, vertexCount, &vertex Buffer, 170 void* verts = target->makeVertexSpace(vertexStride, vertexCount, &vertex Buffer,
171 &firstVertex); 171 &firstVertex);
172 if (!verts) { 172 if (!verts) {
173 SkDebugf("Could not allocate vertices\n"); 173 SkDebugf("Could not allocate vertices\n");
174 return; 174 return;
175 } 175 }
176 memcpy(verts, vertices, vertexCount * vertexStride); 176 memcpy(verts, vertices, vertexCount * vertexStride);
177 177
178 const GrIndexBuffer* indexBuffer; 178 const GrIndexBuffer* indexBuffer;
179 int firstIndex; 179 int firstIndex;
180 uint16_t* idxs = target->makeIndexSpace(indexCount, &indexBuffer, &first Index); 180 uint16_t* idxs = target->makeIndexSpace(indexCount, &indexBuffer, &first Index);
181 if (!idxs) { 181 if (!idxs) {
182 SkDebugf("Could not allocate indices\n"); 182 SkDebugf("Could not allocate indices\n");
183 return; 183 return;
184 } 184 }
185 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); 185 memcpy(idxs, indices, indexCount * sizeof(uint16_t));
186 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, 186 mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex,
187 firstIndex, vertexCount, indexCount); 187 firstIndex, vertexCount, indexCount);
188 target->draw(info); 188 target->draw(mesh);
189 } 189 }
190 190
191 void onPrepareDraws(Target* target) const override { 191 void onPrepareDraws(Target* target) const override {
192 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 192 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
193 193
194 // Setup GrGeometryProcessor 194 // Setup GrGeometryProcessor
195 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage, 195 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage,
196 this->viewMatr ix(), 196 this->viewMatr ix(),
197 this->usesLoca lCoords(), 197 this->usesLoca lCoords(),
198 this->coverage Ignored())); 198 this->coverage Ignored()));
199 if (!gp) { 199 if (!gp) {
200 SkDebugf("Couldn't create a GrGeometryProcessor\n"); 200 SkDebugf("Couldn't create a GrGeometryProcessor\n");
201 return; 201 return;
202 } 202 }
203 203
204 target->initDraw(gp, this->pipeline()); 204 target->initDraw(gp);
205 205
206 size_t vertexStride = gp->getVertexStride(); 206 size_t vertexStride = gp->getVertexStride();
207 207
208 SkASSERT(canTweakAlphaForCoverage ? 208 SkASSERT(canTweakAlphaForCoverage ?
209 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 209 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
210 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 210 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
211 211
212 int instanceCount = fGeoData.count(); 212 int instanceCount = fGeoData.count();
213 213
214 int vertexCount = 0; 214 int vertexCount = 0;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 348 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
349 AAFlatteningConvexPathBatch::Geometry geometry; 349 AAFlatteningConvexPathBatch::Geometry geometry;
350 geometry.fColor = GrRandomColor(random); 350 geometry.fColor = GrRandomColor(random);
351 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 351 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
352 geometry.fPath = GrTest::TestPathConvex(random); 352 geometry.fPath = GrTest::TestPathConvex(random);
353 353
354 return AAFlatteningConvexPathBatch::Create(geometry); 354 return AAFlatteningConvexPathBatch::Create(geometry);
355 } 355 }
356 356
357 #endif 357 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698