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

Side by Side Diff: src/gpu/batches/GrNonAAStrokeRectBatch.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/GrNinePatch.cpp ('k') | src/gpu/batches/GrPLSPathRenderer.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 "GrNonAAStrokeRectBatch.h" 8 #include "GrNonAAStrokeRectBatch.h"
9 9
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 using namespace GrDefaultGeoProcFactory; 110 using namespace GrDefaultGeoProcFactory;
111 Color color(this->color()); 111 Color color(this->color());
112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : 112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type :
113 Coverage::kNone_Type); 113 Coverage::kNone_Type);
114 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type : 114 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type :
115 LocalCoords::kUnus ed_Type); 115 LocalCoords::kUnus ed_Type);
116 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s, 116 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord s,
117 this->viewMatrix())); 117 this->viewMatrix()));
118 } 118 }
119 119
120 target->initDraw(gp, this->pipeline()); 120 target->initDraw(gp);
121 121
122 size_t vertexStride = gp->getVertexStride(); 122 size_t vertexStride = gp->getVertexStride();
123 123
124 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); 124 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr));
125 125
126 const Geometry& args = fGeoData[0]; 126 const Geometry& args = fGeoData[0];
127 127
128 int vertexCount = kVertsPerHairlineRect; 128 int vertexCount = kVertsPerHairlineRect;
129 if (args.fStrokeWidth > 0) { 129 if (args.fStrokeWidth > 0) {
130 vertexCount = kVertsPerStrokeRect; 130 vertexCount = kVertsPerStrokeRect;
131 } 131 }
132 132
133 const GrVertexBuffer* vertexBuffer; 133 const GrVertexBuffer* vertexBuffer;
134 int firstVertex; 134 int firstVertex;
135 135
136 void* verts = target->makeVertexSpace(vertexStride, vertexCount, &vertex Buffer, 136 void* verts = target->makeVertexSpace(vertexStride, vertexCount, &vertex Buffer,
137 &firstVertex); 137 &firstVertex);
138 138
139 if (!verts) { 139 if (!verts) {
140 SkDebugf("Could not allocate vertices\n"); 140 SkDebugf("Could not allocate vertices\n");
141 return; 141 return;
142 } 142 }
143 143
144 SkPoint* vertex = reinterpret_cast<SkPoint*>(verts); 144 SkPoint* vertex = reinterpret_cast<SkPoint*>(verts);
145 145
146 GrPrimitiveType primType; 146 GrPrimitiveType primType;
147 if (args.fStrokeWidth > 0) {; 147 if (args.fStrokeWidth > 0) {
148 primType = kTriangleStrip_GrPrimitiveType; 148 primType = kTriangleStrip_GrPrimitiveType;
149 init_stroke_rect_strip(vertex, args.fRect, args.fStrokeWidth); 149 init_stroke_rect_strip(vertex, args.fRect, args.fStrokeWidth);
150 } else { 150 } else {
151 // hairline 151 // hairline
152 primType = kLineStrip_GrPrimitiveType; 152 primType = kLineStrip_GrPrimitiveType;
153 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); 153 vertex[0].set(args.fRect.fLeft, args.fRect.fTop);
154 vertex[1].set(args.fRect.fRight, args.fRect.fTop); 154 vertex[1].set(args.fRect.fRight, args.fRect.fTop);
155 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); 155 vertex[2].set(args.fRect.fRight, args.fRect.fBottom);
156 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); 156 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom);
157 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); 157 vertex[4].set(args.fRect.fLeft, args.fRect.fTop);
158 } 158 }
159 159
160 GrVertices vertices; 160 GrMesh mesh;
161 vertices.init(primType, vertexBuffer, firstVertex, vertexCount); 161 mesh.init(primType, vertexBuffer, firstVertex, vertexCount);
162 target->draw(vertices); 162 target->draw(mesh);
163 } 163 }
164 164
165 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 165 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
166 // Handle any color overrides 166 // Handle any color overrides
167 if (!overrides.readsColor()) { 167 if (!overrides.readsColor()) {
168 fGeoData[0].fColor = GrColor_ILLEGAL; 168 fGeoData[0].fColor = GrColor_ILLEGAL;
169 } 169 }
170 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 170 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
171 171
172 // setup batch properties 172 // setup batch properties
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) { 244 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) {
245 SkMatrix viewMatrix = GrTest::TestMatrix(random); 245 SkMatrix viewMatrix = GrTest::TestMatrix(random);
246 GrColor color = GrRandomColor(random); 246 GrColor color = GrRandomColor(random);
247 SkRect rect = GrTest::TestRect(random); 247 SkRect rect = GrTest::TestRect(random);
248 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f; 248 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f;
249 249
250 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool()); 250 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool());
251 } 251 }
252 252
253 #endif 253 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNinePatch.cpp ('k') | src/gpu/batches/GrPLSPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698