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

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

Issue 2110903002: Hide more GrBatch Geometry structs. (Closed) Base URL: https://chromium.googlesource.com/skia.git@aabloat
Patch Set: Created 4 years, 5 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 2014 Google Inc. 2 * Copyright 2014 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 "GrAADistanceFieldPathRenderer.h" 8 #include "GrAADistanceFieldPathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 static const SkScalar kAntiAliasPad = 1.0f; 121 static const SkScalar kAntiAliasPad = 1.0f;
122 122
123 class AADistanceFieldPathBatch : public GrVertexBatch { 123 class AADistanceFieldPathBatch : public GrVertexBatch {
124 public: 124 public:
125 DEFINE_BATCH_CLASS_ID 125 DEFINE_BATCH_CLASS_ID
126 126
127 typedef GrAADistanceFieldPathRenderer::ShapeData ShapeData; 127 typedef GrAADistanceFieldPathRenderer::ShapeData ShapeData;
128 typedef SkTDynamicHash<ShapeData, ShapeData::Key> ShapeCache; 128 typedef SkTDynamicHash<ShapeData, ShapeData::Key> ShapeCache;
129 typedef GrAADistanceFieldPathRenderer::ShapeDataList ShapeDataList; 129 typedef GrAADistanceFieldPathRenderer::ShapeDataList ShapeDataList;
130 130
131 struct Geometry { 131 AADistanceFieldPathBatch(GrColor color,
132 GrShape fShape; 132 const GrShape& shape,
133 GrColor fColor; 133 bool antiAlias,
134 bool fAntiAlias; 134 const SkMatrix& viewMatrix,
135 }; 135 GrBatchAtlas* atlas,
136 ShapeCache* shapeCache, ShapeDataList* shapeList,
137 bool gammaCorrect)
138 : INHERITED(ClassID()) {
139 SkASSERT(shape.hasUnstyledKey());
140 fBatch.fViewMatrix = viewMatrix;
141 fGeoData.emplace_back(Geometry{color, shape, antiAlias});
142 SkASSERT(fGeoData[0].fShape.hasUnstyledKey());
136 143
137 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat rix, 144 fAtlas = atlas;
138 GrBatchAtlas* atlas, ShapeCache* shapeCache, 145 fShapeCache = shapeCache;
139 ShapeDataList* shapeList, bool gammaCorrect) { 146 fShapeList = shapeList;
140 return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, shapeCa che, shapeList, 147 fGammaCorrect = gammaCorrect;
141 gammaCorrect); 148
149 // Compute bounds
150 fBounds = shape.bounds();
151 viewMatrix.mapRect(&fBounds);
142 } 152 }
143 153
144 const char* name() const override { return "AADistanceFieldPathBatch"; } 154 const char* name() const override { return "AADistanceFieldPathBatch"; }
145 155
146 void computePipelineOptimizations(GrInitInvariantOutput* color, 156 void computePipelineOptimizations(GrInitInvariantOutput* color,
147 GrInitInvariantOutput* coverage, 157 GrInitInvariantOutput* coverage,
148 GrBatchToXPOverrides* overrides) const ove rride { 158 GrBatchToXPOverrides* overrides) const ove rride {
149 color->setKnownFourComponents(fGeoData[0].fColor); 159 color->setKnownFourComponents(fGeoData[0].fColor);
150 coverage->setUnknownSingleComponent(); 160 coverage->setUnknownSingleComponent();
151 } 161 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 vertexStride, 281 vertexStride,
272 this->viewMatrix(), 282 this->viewMatrix(),
273 args.fShape, 283 args.fShape,
274 shapeData); 284 shapeData);
275 flushInfo.fInstancesToFlush++; 285 flushInfo.fInstancesToFlush++;
276 } 286 }
277 287
278 this->flush(target, &flushInfo); 288 this->flush(target, &flushInfo);
279 } 289 }
280 290
281 AADistanceFieldPathBatch(const Geometry& geometry,
282 const SkMatrix& viewMatrix,
283 GrBatchAtlas* atlas,
284 ShapeCache* shapeCache, ShapeDataList* shapeList,
285 bool gammaCorrect)
286 : INHERITED(ClassID()) {
287 SkASSERT(geometry.fShape.hasUnstyledKey());
288 fBatch.fViewMatrix = viewMatrix;
289 fGeoData.push_back(geometry);
290 SkASSERT(fGeoData[0].fShape.hasUnstyledKey());
291
292 fAtlas = atlas;
293 fShapeCache = shapeCache;
294 fShapeList = shapeList;
295 fGammaCorrect = gammaCorrect;
296
297 // Compute bounds
298 fBounds = geometry.fShape.bounds();
299 viewMatrix.mapRect(&fBounds);
300 }
301
302 bool addPathToAtlas(GrVertexBatch::Target* target, 291 bool addPathToAtlas(GrVertexBatch::Target* target,
303 FlushInfo* flushInfo, 292 FlushInfo* flushInfo,
304 GrBatchAtlas* atlas, 293 GrBatchAtlas* atlas,
305 ShapeData* shapeData, 294 ShapeData* shapeData,
306 const GrShape& shape, 295 const GrShape& shape,
307 bool antiAlias, 296 bool antiAlias,
308 uint32_t dimension, 297 uint32_t dimension,
309 SkScalar scale) const { 298 SkScalar scale) const {
310 const SkRect& bounds = shape.bounds(); 299 const SkRect& bounds = shape.bounds();
311 300
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return true; 489 return true;
501 } 490 }
502 491
503 struct BatchTracker { 492 struct BatchTracker {
504 SkMatrix fViewMatrix; 493 SkMatrix fViewMatrix;
505 bool fUsesLocalCoords; 494 bool fUsesLocalCoords;
506 bool fColorIgnored; 495 bool fColorIgnored;
507 bool fCoverageIgnored; 496 bool fCoverageIgnored;
508 }; 497 };
509 498
499 struct Geometry {
500 GrColor fColor;
501 GrShape fShape;
502 bool fAntiAlias;
503 };
504
510 BatchTracker fBatch; 505 BatchTracker fBatch;
511 SkSTArray<1, Geometry> fGeoData; 506 SkSTArray<1, Geometry> fGeoData;
512 GrBatchAtlas* fAtlas; 507 GrBatchAtlas* fAtlas;
513 ShapeCache* fShapeCache; 508 ShapeCache* fShapeCache;
514 ShapeDataList* fShapeList; 509 ShapeDataList* fShapeList;
515 bool fGammaCorrect; 510 bool fGammaCorrect;
516 511
517 typedef GrVertexBatch INHERITED; 512 typedef GrVertexBatch INHERITED;
518 }; 513 };
519 514
(...skipping 10 matching lines...) Expand all
530 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig, 525 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig,
531 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT, 526 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT,
532 NUM_PLOTS_X, NUM_PLOTS_Y, 527 NUM_PLOTS_X, NUM_PLOTS_Y,
533 &GrAADistanceFieldPathRende rer::HandleEviction, 528 &GrAADistanceFieldPathRende rer::HandleEviction,
534 (void*)this); 529 (void*)this);
535 if (!fAtlas) { 530 if (!fAtlas) {
536 return false; 531 return false;
537 } 532 }
538 } 533 }
539 534
540 AADistanceFieldPathBatch::Geometry geometry; 535 SkAutoTUnref<GrDrawBatch> batch(new AADistanceFieldPathBatch(args.fColor, *a rgs.fShape,
541 geometry.fShape = *args.fShape; 536 args.fAntiAlias , *args.fViewMatrix,
542 geometry.fColor = args.fColor; 537 fAtlas, &fShape Cache, &fShapeList,
543 geometry.fAntiAlias = args.fAntiAlias; 538 args.fGammaCorr ect));
544
545 SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry,
546 *args.fView Matrix, fAtlas,
547 &fShapeCach e, &fShapeList,
548 args.fGamma Correct));
549 539
550 GrPipelineBuilder pipelineBuilder(*args.fPaint); 540 GrPipelineBuilder pipelineBuilder(*args.fPaint);
551 pipelineBuilder.setUserStencil(args.fUserStencilSettings); 541 pipelineBuilder.setUserStencil(args.fUserStencilSettings);
552 542
553 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); 543 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
554 544
555 return true; 545 return true;
556 } 546 }
557 547
558 //////////////////////////////////////////////////////////////////////////////// /////////////////// 548 //////////////////////////////////////////////////////////////////////////////// ///////////////////
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT, 602 ATLAS_TEXTURE_WIDTH, ATLAS_ TEXTURE_HEIGHT,
613 NUM_PLOTS_X, NUM_PLOTS_Y, 603 NUM_PLOTS_X, NUM_PLOTS_Y,
614 &PathTestStruct::HandleEvic tion, 604 &PathTestStruct::HandleEvic tion,
615 (void*)&gTestStruct); 605 (void*)&gTestStruct);
616 } 606 }
617 607
618 SkMatrix viewMatrix = GrTest::TestMatrix(random); 608 SkMatrix viewMatrix = GrTest::TestMatrix(random);
619 GrColor color = GrRandomColor(random); 609 GrColor color = GrRandomColor(random);
620 bool gammaCorrect = random->nextBool(); 610 bool gammaCorrect = random->nextBool();
621 611
622 AADistanceFieldPathBatch::Geometry geometry;
623 // This path renderer only allows fill styles. 612 // This path renderer only allows fill styles.
624 GrShape shape(GrTest::TestPath(random), GrStyle::SimpleFill()); 613 GrShape shape(GrTest::TestPath(random), GrStyle::SimpleFill());
625 geometry.fShape = shape; 614 bool antiAlias = random->nextBool();
626 geometry.fColor = color;
627 geometry.fAntiAlias = random->nextBool();
628 615
629 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, 616 return new AADistanceFieldPathBatch(color,
630 gTestStruct.fAtlas, 617 shape,
631 &gTestStruct.fShapeCache, 618 antiAlias,
632 &gTestStruct.fShapeList, 619 viewMatrix,
633 gammaCorrect); 620 gTestStruct.fAtlas,
621 &gTestStruct.fShapeCache,
622 &gTestStruct.fShapeList,
623 gammaCorrect);
634 } 624 }
635 625
636 #endif 626 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698