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

Side by Side Diff: src/gpu/batches/GrAAStrokeRectBatch.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
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 "GrAAStrokeRectBatch.h" 8 #include "GrAAStrokeRectBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 SkAutoTUnref<const GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlp haForCoverage, 187 SkAutoTUnref<const GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlp haForCoverage,
188 this->viewM atrix(), 188 this->viewM atrix(),
189 this->usesL ocalCoords(), 189 this->usesL ocalCoords(),
190 this->cover ageIgnored())); 190 this->cover ageIgnored()));
191 if (!gp) { 191 if (!gp) {
192 SkDebugf("Couldn't create GrGeometryProcessor\n"); 192 SkDebugf("Couldn't create GrGeometryProcessor\n");
193 return; 193 return;
194 } 194 }
195 195
196 target->initDraw(gp, this->pipeline()); 196 target->initDraw(gp);
197 197
198 size_t vertexStride = gp->getVertexStride(); 198 size_t vertexStride = gp->getVertexStride();
199 199
200 SkASSERT(canTweakAlphaForCoverage ? 200 SkASSERT(canTweakAlphaForCoverage ?
201 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) : 201 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
202 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCovera geAttr)); 202 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCovera geAttr));
203 int innerVertexNum = 4; 203 int innerVertexNum = 4;
204 int outerVertexNum = this->miterStroke() ? 4 : 8; 204 int outerVertexNum = this->miterStroke() ? 4 : 8;
205 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; 205 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2;
206 int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexC nt; 206 int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexC nt;
207 int instanceCount = fGeoData.count(); 207 int instanceCount = fGeoData.count();
208 208
209 const SkAutoTUnref<const GrIndexBuffer> indexBuffer( 209 const SkAutoTUnref<const GrIndexBuffer> indexBuffer(
210 GetIndexBuffer(target->resourceProvider(), this->miterStroke())); 210 GetIndexBuffer(target->resourceProvider(), this->miterStroke()));
211 InstancedHelper helper; 211 InstancedHelper helper;
212 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStrid e, 212 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStrid e,
213 indexBuffer, verticesPerInstance, indicesPerIn stance, 213 indexBuffer, verticesPerInstance, indicesPerIns tance,
214 instanceCount); 214 instanceCount);
215 if (!vertices || !indexBuffer) { 215 if (!vertices || !indexBuffer) {
216 SkDebugf("Could not allocate vertices\n"); 216 SkDebugf("Could not allocate vertices\n");
217 return; 217 return;
218 } 218 }
219 219
220 for (int i = 0; i < instanceCount; i++) { 220 for (int i = 0; i < instanceCount; i++) {
221 const Geometry& args = fGeoData[i]; 221 const Geometry& args = fGeoData[i];
222 this->generateAAStrokeRectGeometry(vertices, 222 this->generateAAStrokeRectGeometry(vertices,
223 i * verticesPerInstance * vertexStrid e, 223 i * verticesPerInstance * vertexStrid e,
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 SkRect inside = outside; 655 SkRect inside = outside;
656 inside.inset(strokeWidth, strokeWidth); 656 inside.inset(strokeWidth, strokeWidth);
657 657
658 GrColor color = GrRandomColor(random); 658 GrColor color = GrRandomColor(random);
659 659
660 return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outsid e, outsideAssist, 660 return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outsid e, outsideAssist,
661 inside, miterStroke, inside.isFinite() && inside.isEmpty()); 661 inside, miterStroke, inside.isFinite() && inside.isEmpty());
662 } 662 }
663 663
664 #endif 664 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAtlasTextBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698