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

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

Issue 1967513002: Revert of Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Created 4 years, 7 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 "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 11 matching lines...) Expand all
22 #include "glsl/GrGLSLUtil.h" 22 #include "glsl/GrGLSLUtil.h"
23 #include "gl/GrGLVaryingHandler.h" 23 #include "gl/GrGLVaryingHandler.h"
24 #include "batches/GrRectBatchFactory.h" 24 #include "batches/GrRectBatchFactory.h"
25 #include "batches/GrVertexBatch.h" 25 #include "batches/GrVertexBatch.h"
26 26
27 static const float kTolerance = 0.5f; 27 static const float kTolerance = 0.5f;
28 28
29 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
30 // Helpers for drawPath 30 // Helpers for drawPath
31 31
32 static inline bool single_pass_path(const SkPath& path) { 32 static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok e) {
33 if (!path.isInverseFillType()) { 33 if (!path.isInverseFillType()) {
34 return path.isConvex(); 34 return path.isConvex();
35 } 35 }
36 return false; 36 return false;
37 } 37 }
38 38
39 GrPathRenderer::StencilSupport 39 GrPathRenderer::StencilSupport
40 GrMSAAPathRenderer::onGetStencilSupport(const SkPath& path) const { 40 GrMSAAPathRenderer::onGetStencilSupport(const SkPath& path) const {
41 if (single_pass_path(path)) { 41 if (single_pass_path(path, SkStrokeRec(SkStrokeRec::kFill_InitStyle))) {
42 return GrPathRenderer::kNoRestriction_StencilSupport; 42 return GrPathRenderer::kNoRestriction_StencilSupport;
43 } else { 43 } else {
44 return GrPathRenderer::kStencilOnly_StencilSupport; 44 return GrPathRenderer::kStencilOnly_StencilSupport;
45 } 45 }
46 } 46 }
47 47
48 struct MSAALineVertices { 48 struct MSAALineVertices {
49 struct Vertex { 49 struct Vertex {
50 SkPoint fPosition; 50 SkPoint fPosition;
51 SkColor fColor; 51 SkColor fColor;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 bool fIsIndexed; 564 bool fIsIndexed;
565 565
566 typedef GrVertexBatch INHERITED; 566 typedef GrVertexBatch INHERITED;
567 }; 567 };
568 568
569 bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target, 569 bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target,
570 GrPipelineBuilder* pipelineBuilder, 570 GrPipelineBuilder* pipelineBuilder,
571 GrColor color, 571 GrColor color,
572 const SkMatrix& viewMatrix, 572 const SkMatrix& viewMatrix,
573 const SkPath& path, 573 const SkPath& path,
574 const GrStrokeInfo& origStroke,
574 bool stencilOnly) { 575 bool stencilOnly) {
576 SkTCopyOnFirstWrite<GrStrokeInfo> stroke(origStroke);
575 577
576 const GrXPFactory* xpFactory = pipelineBuilder->getXPFactory(); 578 const GrXPFactory* xpFactory = pipelineBuilder->getXPFactory();
577 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkSafeRef(xpFactory)); 579 SkAutoTUnref<const GrXPFactory> backupXPFactory(SkSafeRef(xpFactory));
578 // face culling doesn't make sense here 580 // face culling doesn't make sense here
579 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace() ); 581 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == pipelineBuilder->getDrawFace() );
580 582
581 int passCount = 0; 583 int passCount = 0;
582 const GrStencilSettings* passes[3]; 584 const GrStencilSettings* passes[3];
583 GrPipelineBuilder::DrawFace drawFace[3]; 585 GrPipelineBuilder::DrawFace drawFace[3];
584 bool reverse = false; 586 bool reverse = false;
585 bool lastPassIsBounds; 587 bool lastPassIsBounds;
586 588
587 if (single_pass_path(path)) { 589 if (single_pass_path(path, *stroke)) {
588 passCount = 1; 590 passCount = 1;
589 if (stencilOnly) { 591 if (stencilOnly) {
590 passes[0] = &gDirectToStencil; 592 passes[0] = &gDirectToStencil;
591 } else { 593 } else {
592 passes[0] = nullptr; 594 passes[0] = nullptr;
593 } 595 }
594 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace; 596 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
595 lastPassIsBounds = false; 597 lastPassIsBounds = false;
596 } else { 598 } else {
597 switch (path.getFillType()) { 599 switch (path.getFillType()) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 696 }
695 else { 697 else {
696 return false; 698 return false;
697 } 699 }
698 } 700 }
699 } 701 }
700 return true; 702 return true;
701 } 703 }
702 704
703 bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { 705 bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
704 // This path renderer does not support hairlines. We defer on anything that could be handled 706 return !IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, nullp tr) &&
705 // as a hairline by another path renderer. Also, arbitrary path effects coul d produce 707 !args.fAntiAlias;
706 // a hairline result.
707 return !IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullpt r) &&
708 !args.fStyle->hasNonDashPathEffect() && !args.fAntiAlias;
709 } 708 }
710 709
711 bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) { 710 bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
712 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrMSAAPathRenderer ::onDrawPath"); 711 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrMSAAPathRenderer ::onDrawPath");
713 SkPath tmpPath; 712 SkPath path;
714 const SkPath* path; 713 GrStrokeInfo stroke(*args.fStroke);
715 if (args.fStyle->applies()) { 714 if (stroke.isDashed()) {
716 SkStrokeRec::InitStyle fill; 715 if (!stroke.applyDashToPath(&path, &stroke, *args.fPath)) {
717 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix);
718 if (!args.fStyle->applyToPath(&tmpPath, &fill, *args.fPath, styleScale)) {
719 return false; 716 return false;
720 } 717 }
721 // We don't accept styles that are hairlines or have path effects that c ould produce
722 // hairlines.
723 SkASSERT(SkStrokeRec::kFill_InitStyle == fill);
724 path = &tmpPath;
725 } else { 718 } else {
726 path = args.fPath; 719 path = *args.fPath;
720 }
721 if (!stroke.isFillStyle()) {
722 stroke.setResScale(SkScalarAbs(args.fViewMatrix->getMaxScale()));
723 if (!stroke.applyToPath(&path, path)) {
724 return false;
725 }
726 stroke.setFillStyle();
727 } 727 }
728 return this->internalDrawPath(args.fTarget, 728 return this->internalDrawPath(args.fTarget,
729 args.fPipelineBuilder, 729 args.fPipelineBuilder,
730 args.fColor, 730 args.fColor,
731 *args.fViewMatrix, 731 *args.fViewMatrix,
732 *path, 732 path,
733 stroke,
733 false); 734 false);
734 } 735 }
735 736
736 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { 737 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) {
737 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrMSAAPathRenderer: :onStencilPath"); 738 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),"GrMSAAPathRenderer: :onStencilPath");
738 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); 739 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType());
739 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); 740 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
740 this->internalDrawPath(args.fTarget, args.fPipelineBuilder, GrColor_WHITE, * args.fViewMatrix, 741 this->internalDrawPath(args.fTarget, args.fPipelineBuilder, GrColor_WHITE, * args.fViewMatrix,
741 *args.fPath, true); 742 *args.fPath, GrStrokeInfo::FillInfo(), true);
742 } 743 }
743 744
744 //////////////////////////////////////////////////////////////////////////////// /////////////////// 745 //////////////////////////////////////////////////////////////////////////////// ///////////////////
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