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

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

Issue 2126083002: Remove fColor from PathRenderer DrawPathArgs struct (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unnecessary GrPaint::setColor calls 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
« no previous file with comments | « src/gpu/batches/GrDefaultPathRenderer.h ('k') | src/gpu/batches/GrMSAAPathRenderer.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" 8 #include "GrDefaultPathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 BatchTracker fBatch; 413 BatchTracker fBatch;
414 SkSTArray<1, Geometry, true> fGeoData; 414 SkSTArray<1, Geometry, true> fGeoData;
415 415
416 typedef GrVertexBatch INHERITED; 416 typedef GrVertexBatch INHERITED;
417 }; 417 };
418 418
419 bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext, 419 bool GrDefaultPathRenderer::internalDrawPath(GrDrawContext* drawContext,
420 const GrPaint& paint, 420 const GrPaint& paint,
421 const GrUserStencilSettings* userSt encilSettings, 421 const GrUserStencilSettings* userSt encilSettings,
422 const GrClip& clip, 422 const GrClip& clip,
423 GrColor color,
424 const SkMatrix& viewMatrix, 423 const SkMatrix& viewMatrix,
425 const GrShape& shape, 424 const GrShape& shape,
426 bool stencilOnly) { 425 bool stencilOnly) {
427 SkPath path; 426 SkPath path;
428 shape.asPath(&path); 427 shape.asPath(&path);
429 428
430 SkScalar hairlineCoverage; 429 SkScalar hairlineCoverage;
431 uint8_t newCoverage = 0xff; 430 uint8_t newCoverage = 0xff;
432 bool isHairline = false; 431 bool isHairline = false;
433 if (IsStrokeHairlineOrEquivalent(shape.style(), viewMatrix, &hairlineCoverag e)) { 432 if (IsStrokeHairlineOrEquivalent(shape.style(), viewMatrix, &hairlineCoverag e)) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 if (!viewMatrix.invert(&localMatrix)) { 549 if (!viewMatrix.invert(&localMatrix)) {
551 return false; 550 return false;
552 } 551 }
553 } 552 }
554 } else { 553 } else {
555 bounds = path.getBounds(); 554 bounds = path.getBounds();
556 } 555 }
557 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S kMatrix::I() : 556 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S kMatrix::I() :
558 v iewMatrix; 557 v iewMatrix;
559 SkAutoTUnref<GrDrawBatch> batch( 558 SkAutoTUnref<GrDrawBatch> batch(
560 GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nu llptr, 559 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr,
561 &localMatrix)); 560 &localMatrix));
562 561
563 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int)); 562 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int));
564 pipelineBuilder.setDrawFace(drawFace[p]); 563 pipelineBuilder.setDrawFace(drawFace[p]);
565 if (passes[p]) { 564 if (passes[p]) {
566 pipelineBuilder.setUserStencil(passes[p]); 565 pipelineBuilder.setUserStencil(passes[p]);
567 } else { 566 } else {
568 pipelineBuilder.setUserStencil(userStencilSettings); 567 pipelineBuilder.setUserStencil(userStencilSettings);
569 } 568 }
570 569
571 drawContext->drawBatch(pipelineBuilder, clip, batch); 570 drawContext->drawBatch(pipelineBuilder, clip, batch);
572 } else { 571 } else {
573 SkAutoTUnref<GrDrawBatch> batch(new DefaultPathBatch(color, path, sr cSpaceTol, 572 SkAutoTUnref<GrDrawBatch> batch(new DefaultPathBatch(paint.getColor( ), path,
573 srcSpaceTol,
574 newCoverage, vi ewMatrix, 574 newCoverage, vi ewMatrix,
575 isHairline, dev Bounds)); 575 isHairline, dev Bounds));
576 576
577 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int)); 577 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int));
578 pipelineBuilder.setDrawFace(drawFace[p]); 578 pipelineBuilder.setDrawFace(drawFace[p]);
579 if (passes[p]) { 579 if (passes[p]) {
580 pipelineBuilder.setUserStencil(passes[p]); 580 pipelineBuilder.setUserStencil(passes[p]);
581 } else { 581 } else {
582 pipelineBuilder.setUserStencil(userStencilSettings); 582 pipelineBuilder.setUserStencil(userStencilSettings);
583 } 583 }
(...skipping 14 matching lines...) Expand all
598 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix , nullptr)); 598 IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix , nullptr));
599 } 599 }
600 600
601 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { 601 bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) {
602 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 602 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
603 "GrDefaultPathRenderer::onDrawPath"); 603 "GrDefaultPathRenderer::onDrawPath");
604 return this->internalDrawPath(args.fDrawContext, 604 return this->internalDrawPath(args.fDrawContext,
605 *args.fPaint, 605 *args.fPaint,
606 args.fUserStencilSettings, 606 args.fUserStencilSettings,
607 *args.fClip, 607 *args.fClip,
608 args.fColor,
609 *args.fViewMatrix, 608 *args.fViewMatrix,
610 *args.fShape, 609 *args.fShape,
611 false); 610 false);
612 } 611 }
613 612
614 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { 613 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
615 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 614 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
616 "GrDefaultPathRenderer::onStencilPath"); 615 "GrDefaultPathRenderer::onStencilPath");
617 SkASSERT(!args.fShape->inverseFilled()); 616 SkASSERT(!args.fShape->inverseFilled());
618 617
619 GrPaint paint; 618 GrPaint paint;
620 paint.setXPFactory(GrDisableColorXPFactory::Make()); 619 paint.setXPFactory(GrDisableColorXPFactory::Make());
621 paint.setAntiAlias(args.fIsAA); 620 paint.setAntiAlias(args.fIsAA);
622 621
623 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip, 622 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip,
624 GrColor_WHITE, *args.fViewMatrix, *args.fShape, true) ; 623 *args.fViewMatrix, *args.fShape, true);
625 } 624 }
626 625
627 //////////////////////////////////////////////////////////////////////////////// /////////////////// 626 //////////////////////////////////////////////////////////////////////////////// ///////////////////
628 627
629 #ifdef GR_TEST_UTILS 628 #ifdef GR_TEST_UTILS
630 629
631 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) { 630 DRAW_BATCH_TEST_DEFINE(DefaultPathBatch) {
632 GrColor color = GrRandomColor(random); 631 GrColor color = GrRandomColor(random);
633 SkMatrix viewMatrix = GrTest::TestMatrix(random); 632 SkMatrix viewMatrix = GrTest::TestMatrix(random);
634 633
635 // For now just hairlines because the other types of draws require two batch es. 634 // For now just hairlines because the other types of draws require two batch es.
636 // TODO we should figure out a way to combine the stencil and cover steps in to one batch 635 // TODO we should figure out a way to combine the stencil and cover steps in to one batch
637 GrStyle style(SkStrokeRec::kHairline_InitStyle); 636 GrStyle style(SkStrokeRec::kHairline_InitStyle);
638 SkPath path = GrTest::TestPath(random); 637 SkPath path = GrTest::TestPath(random);
639 638
640 // Compute srcSpaceTol 639 // Compute srcSpaceTol
641 SkRect bounds = path.getBounds(); 640 SkRect bounds = path.getBounds();
642 SkScalar tol = GrPathUtils::kDefaultTolerance; 641 SkScalar tol = GrPathUtils::kDefaultTolerance;
643 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou nds); 642 SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, bou nds);
644 643
645 viewMatrix.mapRect(&bounds); 644 viewMatrix.mapRect(&bounds);
646 uint8_t coverage = GrRandomCoverage(random); 645 uint8_t coverage = GrRandomCoverage(random);
647 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix, true, bounds); 646 return new DefaultPathBatch(color, path, srcSpaceTol, coverage, viewMatrix, true, bounds);
648 } 647 }
649 648
650 #endif 649 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDefaultPathRenderer.h ('k') | src/gpu/batches/GrMSAAPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698