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/GrMSAAPathRenderer.cpp

Issue 2006643005: Start on replacing path+style with shape in patherenderer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebase after breaking out more Created 4 years, 6 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/GrMSAAPathRenderer.h ('k') | src/gpu/batches/GrPLSPathRenderer.cpp » ('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 2016 Google Inc. 2 * Copyright 2016 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 "GrMSAAPathRenderer.h" 8 #include "GrMSAAPathRenderer.h"
9 9
10 #include "GrAuditTrail.h" 10 #include "GrAuditTrail.h"
(...skipping 13 matching lines...) Expand all
24 #include "glsl/GrGLSLUtil.h" 24 #include "glsl/GrGLSLUtil.h"
25 #include "gl/GrGLVaryingHandler.h" 25 #include "gl/GrGLVaryingHandler.h"
26 #include "batches/GrRectBatchFactory.h" 26 #include "batches/GrRectBatchFactory.h"
27 #include "batches/GrVertexBatch.h" 27 #include "batches/GrVertexBatch.h"
28 28
29 static const float kTolerance = 0.5f; 29 static const float kTolerance = 0.5f;
30 30
31 //////////////////////////////////////////////////////////////////////////////// 31 ////////////////////////////////////////////////////////////////////////////////
32 // Helpers for drawPath 32 // Helpers for drawPath
33 33
34 static inline bool single_pass_path(const SkPath& path) { 34 static inline bool single_pass_shape(const GrShape& shape) {
35 if (!path.isInverseFillType()) { 35 if (!shape.inverseFilled()) {
36 return path.isConvex(); 36 return shape.knownToBeConvex();
37 } 37 }
38 return false; 38 return false;
39 } 39 }
40 40
41 GrPathRenderer::StencilSupport 41 GrPathRenderer::StencilSupport GrMSAAPathRenderer::onGetStencilSupport(const GrS hape& shape) const {
42 GrMSAAPathRenderer::onGetStencilSupport(const SkPath& path) const { 42 if (single_pass_shape(shape)) {
43 if (single_pass_path(path)) {
44 return GrPathRenderer::kNoRestriction_StencilSupport; 43 return GrPathRenderer::kNoRestriction_StencilSupport;
45 } else { 44 } else {
46 return GrPathRenderer::kStencilOnly_StencilSupport; 45 return GrPathRenderer::kStencilOnly_StencilSupport;
47 } 46 }
48 } 47 }
49 48
50 struct MSAALineVertices { 49 struct MSAALineVertices {
51 struct Vertex { 50 struct Vertex {
52 SkPoint fPosition; 51 SkPoint fPosition;
53 SkColor fColor; 52 SkColor fColor;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 566
568 typedef GrVertexBatch INHERITED; 567 typedef GrVertexBatch INHERITED;
569 }; 568 };
570 569
571 bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, 570 bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext,
572 const GrPaint& paint, 571 const GrPaint& paint,
573 const GrUserStencilSettings* userStenc ilSettings, 572 const GrUserStencilSettings* userStenc ilSettings,
574 const GrClip& clip, 573 const GrClip& clip,
575 GrColor color, 574 GrColor color,
576 const SkMatrix& viewMatrix, 575 const SkMatrix& viewMatrix,
577 const SkPath& path, 576 const GrShape& shape,
578 bool stencilOnly) { 577 bool stencilOnly) {
578 SkASSERT(shape.style().isSimpleFill());
579 SkPath path;
580 shape.asPath(&path);
581
579 int passCount = 0; 582 int passCount = 0;
580 const GrUserStencilSettings* passes[3]; 583 const GrUserStencilSettings* passes[3];
581 GrPipelineBuilder::DrawFace drawFace[3]; 584 GrPipelineBuilder::DrawFace drawFace[3];
582 bool reverse = false; 585 bool reverse = false;
583 bool lastPassIsBounds; 586 bool lastPassIsBounds;
584 587
585 if (single_pass_path(path)) { 588 if (single_pass_shape(shape)) {
586 passCount = 1; 589 passCount = 1;
587 if (stencilOnly) { 590 if (stencilOnly) {
588 passes[0] = &gDirectToStencil; 591 passes[0] = &gDirectToStencil;
589 } else { 592 } else {
590 passes[0] = nullptr; 593 passes[0] = nullptr;
591 } 594 }
592 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; 595 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
593 lastPassIsBounds = false; 596 lastPassIsBounds = false;
594 } else { 597 } else {
595 switch (path.getFillType()) { 598 switch (path.getFillType()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 drawContext->drawBatch(pipelineBuilder, clip, batch); 705 drawContext->drawBatch(pipelineBuilder, clip, batch);
703 } 706 }
704 } 707 }
705 return true; 708 return true;
706 } 709 }
707 710
708 bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { 711 bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
709 // This path renderer does not support hairlines. We defer on anything that could be handled 712 // This path renderer does not support hairlines. We defer on anything that could be handled
710 // as a hairline by another path renderer. Also, arbitrary path effects coul d produce 713 // as a hairline by another path renderer. Also, arbitrary path effects coul d produce
711 // a hairline result. 714 // a hairline result.
712 return !IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullpt r) && 715 return !IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix , nullptr) &&
713 !args.fStyle->strokeRec().isHairlineStyle() && 716 !args.fShape->style().couldBeHairline() && !args.fAntiAlias;
714 !args.fStyle->hasNonDashPathEffect() && !args.fAntiAlias;
715 } 717 }
716 718
717 bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) { 719 bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
718 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 720 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
719 "GrMSAAPathRenderer::onDrawPath"); 721 "GrMSAAPathRenderer::onDrawPath");
720 SkPath tmpPath; 722 SkTLazy<GrShape> tmpShape;
721 const SkPath* path; 723 const GrShape* shape = args.fShape;
722 if (args.fStyle->applies()) { 724 if (shape->style().applies()) {
723 SkStrokeRec::InitStyle fill;
724 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); 725 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix);
725 if (!args.fStyle->applyToPath(&tmpPath, &fill, *args.fPath, styleScale)) { 726 tmpShape.init(args.fShape->applyStyle(GrStyle::Apply::kPathEffectAndStro keRec, styleScale));
726 return false; 727 shape = tmpShape.get();
727 }
728 // We don't accept styles that are hairlines or have path effects that c ould produce
729 // hairlines.
730 SkASSERT(SkStrokeRec::kFill_InitStyle == fill);
731 path = &tmpPath;
732 } else {
733 path = args.fPath;
734 } 728 }
735 return this->internalDrawPath(args.fDrawContext, 729 return this->internalDrawPath(args.fDrawContext,
736 *args.fPaint, 730 *args.fPaint,
737 args.fUserStencilSettings, 731 args.fUserStencilSettings,
738 *args.fClip, 732 *args.fClip,
739 args.fColor, 733 args.fColor,
740 *args.fViewMatrix, 734 *args.fViewMatrix,
741 *path, 735 *shape,
742 false); 736 false);
743 } 737 }
744 738
745 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { 739 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) {
746 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 740 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
747 "GrMSAAPathRenderer::onStencilPath"); 741 "GrMSAAPathRenderer::onStencilPath");
748 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); 742 SkASSERT(args.fShape->style().isSimpleFill());
749 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); 743 SkASSERT(!args.fShape->mayBeInverseFilledAfterStyling());
750 744
751 GrPaint paint; 745 GrPaint paint;
752 paint.setXPFactory(GrDisableColorXPFactory::Make()); 746 paint.setXPFactory(GrDisableColorXPFactory::Make());
753 paint.setAntiAlias(args.fIsAA); 747 paint.setAntiAlias(args.fIsAA);
754 748
755 this->internalDrawPath(args.fDrawContext, 749 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip,
756 paint, 750 GrColor_WHITE, *args.fViewMatrix, *args.fShape, true) ;
757 &GrUserStencilSettings::kUnused,
758 *args.fClip,
759 GrColor_WHITE,
760 *args.fViewMatrix,
761 *args.fPath,
762 true);
763 } 751 }
764 752
765 //////////////////////////////////////////////////////////////////////////////// /////////////////// 753 //////////////////////////////////////////////////////////////////////////////// ///////////////////
OLDNEW
« no previous file with comments | « src/gpu/batches/GrMSAAPathRenderer.h ('k') | src/gpu/batches/GrPLSPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698