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