| OLD | NEW |
| 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 Loading... |
| 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 | 683 bool isStencilDisabled = pipelineBuilder->getStencil().isDisabled(); |
| 684 bool isStencilBufferMSAA = pipelineBuilder->getRenderTarget()->isStencilBuff
erMultisampled(); |
| 684 | 685 |
| 685 GrPathRendererChain::DrawType type = | 686 GrPathRendererChain::DrawType type = |
| 686 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : | 687 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType |
| 687 GrPathRendererChain::kColor_DrawType; | 688 : 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 |
| 693 // Try a 1st time without stroking the path and without allowing the SW rend
erer | 694 // Try a 1st time without stroking the path and without allowing the SW rend
erer |
| 694 GrPathRenderer* pr = fDrawingManager->getContext()->getPathRenderer(*pipelin
eBuilder, | 695 GrPathRenderer* pr = fDrawingManager->getContext()->getPathRenderer(viewMatr
ix, *pathPtr, |
| 695 viewMatr
ix, *pathPtr, | |
| 696 *strokeI
nfoPtr, false, | 696 *strokeI
nfoPtr, false, |
| 697 type); | 697 type, is
StencilDisabled, |
| 698 isStenci
lBufferMSAA); |
| 698 | 699 |
| 699 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false); | 700 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false); |
| 700 if (nullptr == pr && strokeInfo.isDashed()) { | 701 if (nullptr == pr && strokeInfo.isDashed()) { |
| 701 // It didn't work above, so try again with dashed stroke converted to a
dashless stroke. | 702 // 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)) { | 703 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa
thPtr)) { |
| 703 return; | 704 return; |
| 704 } | 705 } |
| 705 pathPtr = tmpPath.get(); | 706 pathPtr = tmpPath.get(); |
| 706 if (pathPtr->isEmpty()) { | 707 if (pathPtr->isEmpty()) { |
| 707 return; | 708 return; |
| 708 } | 709 } |
| 709 strokeInfoPtr = &dashlessStrokeInfo; | 710 strokeInfoPtr = &dashlessStrokeInfo; |
| 710 pr = fDrawingManager->getContext()->getPathRenderer(*pipelineBuilder, vi
ewMatrix, | 711 pr = fDrawingManager->getContext()->getPathRenderer(viewMatrix, *pathPtr
, *strokeInfoPtr, |
| 711 *pathPtr, *strokeInf
oPtr, | 712 false, type, isStenc
ilDisabled, |
| 712 false, type); | 713 isStencilBufferMSAA)
; |
| 713 } | 714 } |
| 714 | 715 |
| 715 if (nullptr == pr) { | 716 if (nullptr == pr) { |
| 716 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa
trix, nullptr) && | 717 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa
trix, nullptr) && |
| 717 !strokeInfoPtr->isFillStyle()) { | 718 !strokeInfoPtr->isFillStyle()) { |
| 718 // It didn't work above, so try again with stroke converted to a fil
l. | 719 // It didn't work above, so try again with stroke converted to a fil
l. |
| 719 if (!tmpPath.isValid()) { | 720 if (!tmpPath.isValid()) { |
| 720 tmpPath.init(); | 721 tmpPath.init(); |
| 721 } | 722 } |
| 722 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale())
); | 723 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale())
); |
| 723 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) { | 724 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) { |
| 724 return; | 725 return; |
| 725 } | 726 } |
| 726 pathPtr = tmpPath.get(); | 727 pathPtr = tmpPath.get(); |
| 727 if (pathPtr->isEmpty()) { | 728 if (pathPtr->isEmpty()) { |
| 728 return; | 729 return; |
| 729 } | 730 } |
| 730 dashlessStrokeInfo.setFillStyle(); | 731 dashlessStrokeInfo.setFillStyle(); |
| 731 strokeInfoPtr = &dashlessStrokeInfo; | 732 strokeInfoPtr = &dashlessStrokeInfo; |
| 732 } | 733 } |
| 733 | 734 |
| 734 // This time, allow SW renderer | 735 // This time, allow SW renderer |
| 735 pr = fDrawingManager->getContext()->getPathRenderer(*pipelineBuilder, vi
ewMatrix, | 736 pr = fDrawingManager->getContext()->getPathRenderer(viewMatrix, *pathPtr
, *strokeInfoPtr, |
| 736 *pathPtr, *strokeInf
oPtr, | 737 true, type, isStenci
lDisabled, |
| 737 true, type); | 738 isStencilBufferMSAA)
; |
| 738 } | 739 } |
| 739 | 740 |
| 740 if (nullptr == pr) { | 741 if (nullptr == pr) { |
| 741 #ifdef SK_DEBUG | 742 #ifdef SK_DEBUG |
| 742 SkDebugf("Unable to find path renderer compatible with path.\n"); | 743 SkDebugf("Unable to find path renderer compatible with path.\n"); |
| 743 #endif | 744 #endif |
| 744 return; | 745 return; |
| 745 } | 746 } |
| 746 | 747 |
| 747 GrPathRenderer::DrawPathArgs args; | 748 GrPathRenderer::DrawPathArgs args; |
| 748 args.fTarget = this->getDrawTarget(); | 749 args.fTarget = this->getDrawTarget(); |
| 749 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); | 750 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); |
| 750 args.fPipelineBuilder = pipelineBuilder; | 751 args.fPipelineBuilder = pipelineBuilder; |
| 751 args.fColor = color; | 752 args.fColor = color; |
| 752 args.fViewMatrix = &viewMatrix; | 753 args.fViewMatrix = &viewMatrix; |
| 753 args.fPath = pathPtr; | 754 args.fPath = pathPtr; |
| 754 args.fStroke = strokeInfoPtr; | 755 args.fStroke = strokeInfoPtr; |
| 755 args.fAntiAlias = useCoverageAA; | 756 args.fAntiAlias = useCoverageAA; |
| 756 pr->drawPath(args); | 757 pr->drawPath(args); |
| 757 } | 758 } |
| 758 | 759 |
| 759 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 760 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
| 760 RETURN_IF_ABANDONED | 761 RETURN_IF_ABANDONED |
| 761 SkDEBUGCODE(this->validate();) | 762 SkDEBUGCODE(this->validate();) |
| 762 | 763 |
| 763 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 764 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
| 764 } | 765 } |
| OLD | NEW |