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

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

Issue 1344373005: Reland of add a ClassID function to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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.h » ('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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 coverageType = Coverage::kAttribute_Type; 112 coverageType = Coverage::kAttribute_Type;
113 } 113 }
114 Coverage coverage(coverageType); 114 Coverage coverage(coverageType);
115 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : 115 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
116 LocalCoords::kUnused_Type); 116 LocalCoords::kUnused_Type);
117 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); 117 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
118 } 118 }
119 119
120 class AAFlatteningConvexPathBatch : public GrVertexBatch { 120 class AAFlatteningConvexPathBatch : public GrVertexBatch {
121 public: 121 public:
122 DEFINE_BATCH_CLASS_ID
123
122 struct Geometry { 124 struct Geometry {
123 GrColor fColor; 125 GrColor fColor;
124 SkMatrix fViewMatrix; 126 SkMatrix fViewMatrix;
125 SkPath fPath; 127 SkPath fPath;
126 SkScalar fStrokeWidth; 128 SkScalar fStrokeWidth;
127 SkPaint::Join fJoin; 129 SkPaint::Join fJoin;
128 SkScalar fMiterLimit; 130 SkScalar fMiterLimit;
129 }; 131 };
130 132
131 static GrDrawBatch* Create(const Geometry& geometry) { 133 static GrDrawBatch* Create(const Geometry& geometry) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 indexCount += currentIndices; 253 indexCount += currentIndices;
252 } 254 }
253 draw(target, this->pipeline(), vertexCount, vertexStride, vertices, inde xCount, 255 draw(target, this->pipeline(), vertexCount, vertexStride, vertices, inde xCount,
254 indices); 256 indices);
255 sk_free(vertices); 257 sk_free(vertices);
256 sk_free(indices); 258 sk_free(indices);
257 } 259 }
258 260
259 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 261 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
260 262
261 AAFlatteningConvexPathBatch(const Geometry& geometry) { 263 AAFlatteningConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
262 this->initClassID<AAFlatteningConvexPathBatch>();
263 fGeoData.push_back(geometry); 264 fGeoData.push_back(geometry);
264 265
265 // compute bounds 266 // compute bounds
266 fBounds = geometry.fPath.getBounds(); 267 fBounds = geometry.fPath.getBounds();
267 geometry.fViewMatrix.mapRect(&fBounds); 268 geometry.fViewMatrix.mapRect(&fBounds);
268 } 269 }
269 270
270 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 271 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
271 AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch> (); 272 AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch> ();
272 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 273 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
(...skipping 28 matching lines...) Expand all
301 GrColor fColor; 302 GrColor fColor;
302 bool fUsesLocalCoords; 303 bool fUsesLocalCoords;
303 bool fColorIgnored; 304 bool fColorIgnored;
304 bool fCoverageIgnored; 305 bool fCoverageIgnored;
305 bool fLinesOnly; 306 bool fLinesOnly;
306 bool fCanTweakAlphaForCoverage; 307 bool fCanTweakAlphaForCoverage;
307 }; 308 };
308 309
309 BatchTracker fBatch; 310 BatchTracker fBatch;
310 SkSTArray<1, Geometry, true> fGeoData; 311 SkSTArray<1, Geometry, true> fGeoData;
312
313 typedef GrVertexBatch INHERITED;
311 }; 314 };
312 315
313 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { 316 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
314 if (args.fPath->isEmpty()) { 317 if (args.fPath->isEmpty()) {
315 return true; 318 return true;
316 } 319 }
317 AAFlatteningConvexPathBatch::Geometry geometry; 320 AAFlatteningConvexPathBatch::Geometry geometry;
318 geometry.fColor = args.fColor; 321 geometry.fColor = args.fColor;
319 geometry.fViewMatrix = *args.fViewMatrix; 322 geometry.fViewMatrix = *args.fViewMatrix;
320 geometry.fPath = *args.fPath; 323 geometry.fPath = *args.fPath;
(...skipping 15 matching lines...) Expand all
336 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 339 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
337 AAFlatteningConvexPathBatch::Geometry geometry; 340 AAFlatteningConvexPathBatch::Geometry geometry;
338 geometry.fColor = GrRandomColor(random); 341 geometry.fColor = GrRandomColor(random);
339 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 342 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
340 geometry.fPath = GrTest::TestPathConvex(random); 343 geometry.fPath = GrTest::TestPathConvex(random);
341 344
342 return AAFlatteningConvexPathBatch::Create(geometry); 345 return AAFlatteningConvexPathBatch::Create(geometry);
343 } 346 }
344 347
345 #endif 348 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698