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

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

Issue 1407883004: Remove GrPipelineBuilder from getPathRenderer call (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Hide GrContext::drawingManager entry point Created 5 years, 1 month 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/GrContext.cpp ('k') | src/gpu/GrDrawingManager.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 "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 const GrStrokeInfo& strokeInfo) { 673 const GrStrokeInfo& strokeInfo) {
674 RETURN_IF_ABANDONED 674 RETURN_IF_ABANDONED
675 SkASSERT(!path.isEmpty()); 675 SkASSERT(!path.isEmpty());
676 676
677 // An Assumption here is that path renderer would use some form of tweaking 677 // An Assumption here is that path renderer would use some form of tweaking
678 // the src color (either the input alpha or in the frag shader) to implement 678 // the src color (either the input alpha or in the frag shader) to implement
679 // aa. If we have some future driver-mojo path AA that can do the right 679 // aa. If we have some future driver-mojo path AA that can do the right
680 // thing WRT to the blend then we'll need some query on the PR. 680 // thing WRT to the blend then we'll need some query on the PR.
681 bool useCoverageAA = useAA && 681 bool useCoverageAA = useAA &&
682 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled(); 682 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled();
683 bool isStencilDisabled = pipelineBuilder->getStencil().isDisabled();
684 bool isStencilBufferMSAA = pipelineBuilder->getRenderTarget()->isStencilBuff erMultisampled();
683 685
684 686 const GrPathRendererChain::DrawType type =
685 GrPathRendererChain::DrawType type = 687 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType
686 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : 688 : GrPathRendererChain::kColor_DrawType;
687 GrPathRendererChain::kColor_DrawType;
688 689
689 const SkPath* pathPtr = &path; 690 const SkPath* pathPtr = &path;
690 SkTLazy<SkPath> tmpPath; 691 SkTLazy<SkPath> tmpPath;
691 const GrStrokeInfo* strokeInfoPtr = &strokeInfo; 692 const GrStrokeInfo* strokeInfoPtr = &strokeInfo;
692 693
694 GrPathRenderer::CanDrawPathArgs canDrawArgs;
695 canDrawArgs.fShaderCaps = fDrawingManager->getContext()->caps()->shaderCaps( );
696 canDrawArgs.fViewMatrix = &viewMatrix;
697 canDrawArgs.fPath = pathPtr;
698 canDrawArgs.fStroke = strokeInfoPtr;
699 canDrawArgs.fAntiAlias = useCoverageAA;
700 canDrawArgs.fIsStencilDisabled = isStencilDisabled;
701 canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA;
702
693 // Try a 1st time without stroking the path and without allowing the SW rend erer 703 // Try a 1st time without stroking the path and without allowing the SW rend erer
694 GrPathRenderer* pr = fDrawingManager->getContext()->getPathRenderer(*pipelin eBuilder, 704 GrPathRenderer* pr = fDrawingManager->getPathRenderer(canDrawArgs, false, ty pe);
695 viewMatr ix, *pathPtr,
696 *strokeI nfoPtr, false,
697 type);
698 705
699 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false); 706 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false);
700 if (nullptr == pr && strokeInfo.isDashed()) { 707 if (nullptr == pr && strokeInfo.isDashed()) {
701 // It didn't work above, so try again with dashed stroke converted to a dashless stroke. 708 // It didn't work above, so try again with dashed stroke converted to a dashless stroke.
702 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) { 709 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) {
703 return; 710 return;
704 } 711 }
705 pathPtr = tmpPath.get(); 712 pathPtr = tmpPath.get();
706 if (pathPtr->isEmpty()) { 713 if (pathPtr->isEmpty()) {
707 return; 714 return;
708 } 715 }
709 strokeInfoPtr = &dashlessStrokeInfo; 716 strokeInfoPtr = &dashlessStrokeInfo;
710 pr = fDrawingManager->getContext()->getPathRenderer(*pipelineBuilder, vi ewMatrix, 717
711 *pathPtr, *strokeInf oPtr, 718 canDrawArgs.fPath = pathPtr;
712 false, type); 719 canDrawArgs.fStroke = strokeInfoPtr;
720
721 pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type);
713 } 722 }
714 723
715 if (nullptr == pr) { 724 if (nullptr == pr) {
716 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) && 725 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) &&
717 !strokeInfoPtr->isFillStyle()) { 726 !strokeInfoPtr->isFillStyle()) {
718 // It didn't work above, so try again with stroke converted to a fil l. 727 // It didn't work above, so try again with stroke converted to a fil l.
719 if (!tmpPath.isValid()) { 728 if (!tmpPath.isValid()) {
720 tmpPath.init(); 729 tmpPath.init();
721 } 730 }
722 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) ); 731 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) );
723 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) { 732 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) {
724 return; 733 return;
725 } 734 }
726 pathPtr = tmpPath.get(); 735 pathPtr = tmpPath.get();
727 if (pathPtr->isEmpty()) { 736 if (pathPtr->isEmpty()) {
728 return; 737 return;
729 } 738 }
730 dashlessStrokeInfo.setFillStyle(); 739 dashlessStrokeInfo.setFillStyle();
731 strokeInfoPtr = &dashlessStrokeInfo; 740 strokeInfoPtr = &dashlessStrokeInfo;
732 } 741 }
733 742
743 canDrawArgs.fPath = pathPtr;
744 canDrawArgs.fStroke = strokeInfoPtr;
745
734 // This time, allow SW renderer 746 // This time, allow SW renderer
735 pr = fDrawingManager->getContext()->getPathRenderer(*pipelineBuilder, vi ewMatrix, 747 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type);
736 *pathPtr, *strokeInf oPtr,
737 true, type);
738 } 748 }
739 749
740 if (nullptr == pr) { 750 if (nullptr == pr) {
741 #ifdef SK_DEBUG 751 #ifdef SK_DEBUG
742 SkDebugf("Unable to find path renderer compatible with path.\n"); 752 SkDebugf("Unable to find path renderer compatible with path.\n");
743 #endif 753 #endif
744 return; 754 return;
745 } 755 }
746 756
747 GrPathRenderer::DrawPathArgs args; 757 GrPathRenderer::DrawPathArgs args;
748 args.fTarget = this->getDrawTarget(); 758 args.fTarget = this->getDrawTarget();
749 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); 759 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider();
750 args.fPipelineBuilder = pipelineBuilder; 760 args.fPipelineBuilder = pipelineBuilder;
751 args.fColor = color; 761 args.fColor = color;
752 args.fViewMatrix = &viewMatrix; 762 args.fViewMatrix = &viewMatrix;
753 args.fPath = pathPtr; 763 args.fPath = pathPtr;
754 args.fStroke = strokeInfoPtr; 764 args.fStroke = strokeInfoPtr;
755 args.fAntiAlias = useCoverageAA; 765 args.fAntiAlias = useCoverageAA;
756 pr->drawPath(args); 766 pr->drawPath(args);
757 } 767 }
758 768
759 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 769 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
760 RETURN_IF_ABANDONED 770 RETURN_IF_ABANDONED
761 SkDEBUGCODE(this->validate();) 771 SkDEBUGCODE(this->validate();)
762 772
763 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 773 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
764 } 774 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawingManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698