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

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

Issue 1831133004: Revert of Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 static const int kMiterIndexCnt = 3 * 24; 118 static const int kMiterIndexCnt = 3 * 24;
119 static const int kMiterVertexCnt = 16; 119 static const int kMiterVertexCnt = 16;
120 static const int kNumMiterRectsInIndexBuffer = 256; 120 static const int kNumMiterRectsInIndexBuffer = 256;
121 121
122 static const int kBevelIndexCnt = 48 + 36 + 24; 122 static const int kBevelIndexCnt = 48 + 36 + 24;
123 static const int kBevelVertexCnt = 24; 123 static const int kBevelVertexCnt = 24;
124 static const int kNumBevelRectsInIndexBuffer = 256; 124 static const int kNumBevelRectsInIndexBuffer = 256;
125 125
126 static const GrBuffer* GetIndexBuffer(GrResourceProvider* resourceProvider, bool miterStroke); 126 static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* resourceProvi der,
127 bool miterStroke);
127 128
128 GrColor color() const { return fBatch.fColor; } 129 GrColor color() const { return fBatch.fColor; }
129 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } 130 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
130 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; } 131 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; }
131 bool colorIgnored() const { return fBatch.fColorIgnored; } 132 bool colorIgnored() const { return fBatch.fColorIgnored; }
132 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } 133 bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
133 const Geometry& geometry() const { return fGeoData[0]; } 134 const Geometry& geometry() const { return fGeoData[0]; }
134 const SkMatrix& viewMatrix() const { return fViewMatrix; } 135 const SkMatrix& viewMatrix() const { return fViewMatrix; }
135 bool miterStroke() const { return fMiterStroke; } 136 bool miterStroke() const { return fMiterStroke; }
136 137
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 199
199 SkASSERT(canTweakAlphaForCoverage ? 200 SkASSERT(canTweakAlphaForCoverage ?
200 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) : 201 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
201 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCovera geAttr)); 202 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCovera geAttr));
202 int innerVertexNum = 4; 203 int innerVertexNum = 4;
203 int outerVertexNum = this->miterStroke() ? 4 : 8; 204 int outerVertexNum = this->miterStroke() ? 4 : 8;
204 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; 205 int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2;
205 int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexC nt; 206 int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexC nt;
206 int instanceCount = fGeoData.count(); 207 int instanceCount = fGeoData.count();
207 208
208 const SkAutoTUnref<const GrBuffer> indexBuffer( 209 const SkAutoTUnref<const GrIndexBuffer> indexBuffer(
209 GetIndexBuffer(target->resourceProvider(), this->miterStroke())); 210 GetIndexBuffer(target->resourceProvider(), this->miterStroke()));
210 InstancedHelper helper; 211 InstancedHelper helper;
211 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStrid e, 212 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStrid e,
212 indexBuffer, verticesPerInstance, indicesPerIns tance, 213 indexBuffer, verticesPerInstance, indicesPerIns tance,
213 instanceCount); 214 instanceCount);
214 if (!vertices || !indexBuffer) { 215 if (!vertices || !indexBuffer) {
215 SkDebugf("Could not allocate vertices\n"); 216 SkDebugf("Could not allocate vertices\n");
216 return; 217 return;
217 } 218 }
218 219
219 for (int i = 0; i < instanceCount; i++) { 220 for (int i = 0; i < instanceCount; i++) {
220 const Geometry& args = fGeoData[i]; 221 const Geometry& args = fGeoData[i];
221 this->generateAAStrokeRectGeometry(vertices, 222 this->generateAAStrokeRectGeometry(vertices,
222 i * verticesPerInstance * vertexStrid e, 223 i * verticesPerInstance * vertexStrid e,
223 vertexStride, 224 vertexStride,
224 outerVertexNum, 225 outerVertexNum,
225 innerVertexNum, 226 innerVertexNum,
226 args.fColor, 227 args.fColor,
227 args.fDevOutside, 228 args.fDevOutside,
228 args.fDevOutsideAssist, 229 args.fDevOutsideAssist,
229 args.fDevInside, 230 args.fDevInside,
230 fMiterStroke, 231 fMiterStroke,
231 args.fDegenerate, 232 args.fDegenerate,
232 canTweakAlphaForCoverage); 233 canTweakAlphaForCoverage);
233 } 234 }
234 helper.recordDraw(target); 235 helper.recordDraw(target);
235 } 236 }
236 237
237 const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourcePr ovider, 238 const GrIndexBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resou rceProvider,
238 bool miterStroke) { 239 bool miterStroke) {
239 240
240 if (miterStroke) { 241 if (miterStroke) {
241 static const uint16_t gMiterIndices[] = { 242 static const uint16_t gMiterIndices[] = {
242 0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0, 243 0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0,
243 1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0, 244 1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0,
244 2 + 0, 3 + 0, 7 + 0, 7 + 0, 6 + 0, 2 + 0, 245 2 + 0, 3 + 0, 7 + 0, 7 + 0, 6 + 0, 2 + 0,
245 3 + 0, 0 + 0, 4 + 0, 4 + 0, 7 + 0, 3 + 0, 246 3 + 0, 0 + 0, 4 + 0, 4 + 0, 7 + 0, 3 + 0,
246 247
247 0 + 4, 1 + 4, 5 + 4, 5 + 4, 4 + 4, 0 + 4, 248 0 + 4, 1 + 4, 5 + 4, 5 + 4, 4 + 4, 0 + 4,
248 1 + 4, 2 + 4, 6 + 4, 6 + 4, 5 + 4, 1 + 4, 249 1 + 4, 2 + 4, 6 + 4, 6 + 4, 5 + 4, 1 + 4,
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 SkRect inside = outside; 655 SkRect inside = outside;
655 inside.inset(strokeWidth, strokeWidth); 656 inside.inset(strokeWidth, strokeWidth);
656 657
657 GrColor color = GrRandomColor(random); 658 GrColor color = GrRandomColor(random);
658 659
659 return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outsid e, outsideAssist, 660 return GrAAStrokeRectBatch::Create(color, GrTest::TestMatrix(random), outsid e, outsideAssist,
660 inside, miterStroke, inside.isFinite() && inside.isEmpty()); 661 inside, miterStroke, inside.isFinite() && inside.isEmpty());
661 } 662 }
662 663
663 #endif 664 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAtlasTextBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698