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

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

Issue 1293583002: Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicated fields in GrVertexBatch Created 5 years, 4 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/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrAtlasTextContext.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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 coverageType = Coverage::kSolid_Type; 107 coverageType = Coverage::kSolid_Type;
108 } else { 108 } else {
109 coverageType = Coverage::kAttribute_Type; 109 coverageType = Coverage::kAttribute_Type;
110 } 110 }
111 Coverage coverage(coverageType); 111 Coverage coverage(coverageType);
112 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : 112 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
113 LocalCoords::kUnused_Type); 113 LocalCoords::kUnused_Type);
114 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); 114 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
115 } 115 }
116 116
117 class AAFlatteningConvexPathBatch : public GrBatch { 117 class AAFlatteningConvexPathBatch : public GrVertexBatch {
118 public: 118 public:
119 struct Geometry { 119 struct Geometry {
120 GrColor fColor; 120 GrColor fColor;
121 SkMatrix fViewMatrix; 121 SkMatrix fViewMatrix;
122 SkPath fPath; 122 SkPath fPath;
123 SkScalar fStrokeWidth; 123 SkScalar fStrokeWidth;
124 SkPaint::Join fJoin; 124 SkPaint::Join fJoin;
125 SkScalar fMiterLimit; 125 SkScalar fMiterLimit;
126 }; 126 };
127 127
128 static GrBatch* Create(const Geometry& geometry) { 128 static GrDrawBatch* Create(const Geometry& geometry) {
129 return SkNEW_ARGS(AAFlatteningConvexPathBatch, (geometry)); 129 return SkNEW_ARGS(AAFlatteningConvexPathBatch, (geometry));
130 } 130 }
131 131
132 const char* name() const override { return "AAConvexBatch"; } 132 const char* name() const override { return "AAConvexBatch"; }
133 133
134 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 134 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
135 // When this is called on a batch, there is only one geometry bundle 135 // When this is called on a batch, there is only one geometry bundle
136 out->setKnownFourComponents(fGeoData[0].fColor); 136 out->setKnownFourComponents(fGeoData[0].fColor);
137 } 137 }
138 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 138 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 AAFlatteningConvexPathBatch(const Geometry& geometry) { 258 AAFlatteningConvexPathBatch(const Geometry& geometry) {
259 this->initClassID<AAFlatteningConvexPathBatch>(); 259 this->initClassID<AAFlatteningConvexPathBatch>();
260 fGeoData.push_back(geometry); 260 fGeoData.push_back(geometry);
261 261
262 // compute bounds 262 // compute bounds
263 fBounds = geometry.fPath.getBounds(); 263 fBounds = geometry.fPath.getBounds();
264 geometry.fViewMatrix.mapRect(&fBounds); 264 geometry.fViewMatrix.mapRect(&fBounds);
265 } 265 }
266 266
267 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 267 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
268 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipel ine(), t->bounds(), 268 AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch> ();
269 caps)) { 269 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
270 that->bounds(), caps)) {
270 return false; 271 return false;
271 } 272 }
272 273
273 AAFlatteningConvexPathBatch* that = t->cast<AAFlatteningConvexPathBatch> ();
274
275 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); 274 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
276 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi ewMatrix())) { 275 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi ewMatrix())) {
277 return false; 276 return false;
278 } 277 }
279 278
280 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to 279 // In the event of two batches, one who can tweak, one who cannot, we ju st fall back to
281 // not tweaking 280 // not tweaking
282 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) { 281 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage() ) {
283 fBatch.fCanTweakAlphaForCoverage = false; 282 fBatch.fCanTweakAlphaForCoverage = false;
284 } 283 }
(...skipping 29 matching lines...) Expand all
314 } 313 }
315 AAFlatteningConvexPathBatch::Geometry geometry; 314 AAFlatteningConvexPathBatch::Geometry geometry;
316 geometry.fColor = args.fColor; 315 geometry.fColor = args.fColor;
317 geometry.fViewMatrix = *args.fViewMatrix; 316 geometry.fViewMatrix = *args.fViewMatrix;
318 geometry.fPath = *args.fPath; 317 geometry.fPath = *args.fPath;
319 geometry.fStrokeWidth = args.fStroke->isFillStyle() ? -1.0f : args.fStroke-> getWidth(); 318 geometry.fStrokeWidth = args.fStroke->isFillStyle() ? -1.0f : args.fStroke-> getWidth();
320 geometry.fJoin = args.fStroke->isFillStyle() ? SkPaint::Join::kMiter_Join : 319 geometry.fJoin = args.fStroke->isFillStyle() ? SkPaint::Join::kMiter_Join :
321 args.fStroke->getJoin(); 320 args.fStroke->getJoin();
322 geometry.fMiterLimit = args.fStroke->getMiter(); 321 geometry.fMiterLimit = args.fStroke->getMiter();
323 322
324 SkAutoTUnref<GrBatch> batch(AAFlatteningConvexPathBatch::Create(geometry)); 323 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry ));
325 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); 324 args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
326 325
327 return true; 326 return true;
328 } 327 }
329 328
330 //////////////////////////////////////////////////////////////////////////////// /////////////////// 329 //////////////////////////////////////////////////////////////////////////////// ///////////////////
331 330
332 #ifdef GR_TEST_UTILS 331 #ifdef GR_TEST_UTILS
333 332
334 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 333 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
335 AAFlatteningConvexPathBatch::Geometry geometry; 334 AAFlatteningConvexPathBatch::Geometry geometry;
336 geometry.fColor = GrRandomColor(random); 335 geometry.fColor = GrRandomColor(random);
337 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 336 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
338 geometry.fPath = GrTest::TestPathConvex(random); 337 geometry.fPath = GrTest::TestPathConvex(random);
339 338
340 return AAFlatteningConvexPathBatch::Create(geometry); 339 return AAFlatteningConvexPathBatch::Create(geometry);
341 } 340 }
342 341
343 #endif 342 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrAtlasTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698