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

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

Issue 1420043002: Narrow the distribution of GrDrawTarget a bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrPathRendererChain.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 /* 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 if (!GrOvalRenderer::DrawRRect(this->getDrawTarget(), 454 if (!GrOvalRenderer::DrawRRect(this->getDrawTarget(),
455 pipelineBuilder, 455 pipelineBuilder,
456 color, 456 color,
457 viewMatrix, 457 viewMatrix,
458 paint.isAntiAlias(), 458 paint.isAntiAlias(),
459 rrect, 459 rrect,
460 strokeInfo)) { 460 strokeInfo)) {
461 SkPath path; 461 SkPath path;
462 path.setIsVolatile(true); 462 path.setIsVolatile(true);
463 path.addRRect(rrect); 463 path.addRRect(rrect);
464 this->internalDrawPath(this->getDrawTarget(), &pipelineBuilder, viewMatr ix, color, 464 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
465 paint.isAntiAlias(), path, strokeInfo); 465 paint.isAntiAlias(), path, strokeInfo);
466 } 466 }
467 } 467 }
468 468
469 /////////////////////////////////////////////////////////////////////////////// 469 ///////////////////////////////////////////////////////////////////////////////
470 470
471 void GrDrawContext::drawDRRect(const GrClip& clip, 471 void GrDrawContext::drawDRRect(const GrClip& clip,
472 const GrPaint& paint, 472 const GrPaint& paint,
473 const SkMatrix& viewMatrix, 473 const SkMatrix& viewMatrix,
474 const SkRRect& outer, 474 const SkRRect& outer,
(...skipping 16 matching lines...) Expand all
491 paint.isAntiAlias(), 491 paint.isAntiAlias(),
492 outer, 492 outer,
493 inner)) { 493 inner)) {
494 SkPath path; 494 SkPath path;
495 path.setIsVolatile(true); 495 path.setIsVolatile(true);
496 path.addRRect(inner); 496 path.addRRect(inner);
497 path.addRRect(outer); 497 path.addRRect(outer);
498 path.setFillType(SkPath::kEvenOdd_FillType); 498 path.setFillType(SkPath::kEvenOdd_FillType);
499 499
500 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle); 500 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle);
501 this->internalDrawPath(this->getDrawTarget(), &pipelineBuilder, viewMatr ix, color, 501 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
502 paint.isAntiAlias(), path, fillRec); 502 paint.isAntiAlias(), path, fillRec);
503 } 503 }
504 } 504 }
505 505
506 /////////////////////////////////////////////////////////////////////////////// 506 ///////////////////////////////////////////////////////////////////////////////
507 507
508 void GrDrawContext::drawOval(const GrClip& clip, 508 void GrDrawContext::drawOval(const GrClip& clip,
509 const GrPaint& paint, 509 const GrPaint& paint,
510 const SkMatrix& viewMatrix, 510 const SkMatrix& viewMatrix,
511 const SkRect& oval, 511 const SkRect& oval,
(...skipping 21 matching lines...) Expand all
533 if (!GrOvalRenderer::DrawOval(this->getDrawTarget(), 533 if (!GrOvalRenderer::DrawOval(this->getDrawTarget(),
534 pipelineBuilder, 534 pipelineBuilder,
535 color, 535 color,
536 viewMatrix, 536 viewMatrix,
537 paint.isAntiAlias(), 537 paint.isAntiAlias(),
538 oval, 538 oval,
539 strokeInfo)) { 539 strokeInfo)) {
540 SkPath path; 540 SkPath path;
541 path.setIsVolatile(true); 541 path.setIsVolatile(true);
542 path.addOval(oval); 542 path.addOval(oval);
543 this->internalDrawPath(this->getDrawTarget(), &pipelineBuilder, viewMatr ix, color, 543 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
544 paint.isAntiAlias(), path, strokeInfo); 544 paint.isAntiAlias(), path, strokeInfo);
545 } 545 }
546 } 546 }
547 547
548 // Can 'path' be drawn as a pair of filled nested rectangles? 548 // Can 'path' be drawn as a pair of filled nested rectangles?
549 static bool is_nested_rects(const SkMatrix& viewMatrix, 549 static bool is_nested_rects(const SkMatrix& viewMatrix,
550 const SkPath& path, 550 const SkPath& path,
551 const SkStrokeRec& stroke, 551 const SkStrokeRec& stroke,
552 SkRect rects[2]) { 552 SkRect rects[2]) {
553 SkASSERT(stroke.isFillStyle()); 553 SkASSERT(stroke.isFillStyle());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 pipelineBuilder, 654 pipelineBuilder,
655 color, 655 color,
656 viewMatrix, 656 viewMatrix,
657 paint.isAntiAlias(), 657 paint.isAntiAlias(),
658 ovalRect, 658 ovalRect,
659 strokeInfo)) { 659 strokeInfo)) {
660 return; 660 return;
661 } 661 }
662 } 662 }
663 } 663 }
664 this->internalDrawPath(this->getDrawTarget(), &pipelineBuilder, viewMatrix, color, 664 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
665 paint.isAntiAlias(), path, strokeInfo); 665 paint.isAntiAlias(), path, strokeInfo);
666 } 666 }
667 667
668 void GrDrawContext::internalDrawPath(GrDrawTarget* target, 668 void GrDrawContext::internalDrawPath(GrPipelineBuilder* pipelineBuilder,
669 GrPipelineBuilder* pipelineBuilder,
670 const SkMatrix& viewMatrix, 669 const SkMatrix& viewMatrix,
671 GrColor color, 670 GrColor color,
672 bool useAA, 671 bool useAA,
673 const SkPath& path, 672 const SkPath& path,
674 const GrStrokeInfo& strokeInfo) { 673 const GrStrokeInfo& strokeInfo) {
675 RETURN_IF_ABANDONED 674 RETURN_IF_ABANDONED
676 SkASSERT(!path.isEmpty()); 675 SkASSERT(!path.isEmpty());
677 676
678 // 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
679 // 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
680 // 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
681 // 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.
682 bool useCoverageAA = useAA && 681 bool useCoverageAA = useAA &&
683 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled(); 682 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled();
684 683
685 684
686 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;
689 688
690 const SkPath* pathPtr = &path; 689 const SkPath* pathPtr = &path;
691 SkTLazy<SkPath> tmpPath; 690 SkTLazy<SkPath> tmpPath;
692 const GrStrokeInfo* strokeInfoPtr = &strokeInfo; 691 const GrStrokeInfo* strokeInfoPtr = &strokeInfo;
693 692
694 // 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
695 GrPathRenderer* pr = fDrawingManager->getContext()->getPathRenderer(target, pipelineBuilder, 694 GrPathRenderer* pr = fDrawingManager->getContext()->getPathRenderer(pipeline Builder,
696 viewMatr ix, *pathPtr, 695 viewMatr ix, *pathPtr,
697 *strokeI nfoPtr, false, 696 *strokeI nfoPtr, false,
698 type); 697 type);
699 698
700 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false); 699 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false);
701 if (nullptr == pr && strokeInfo.isDashed()) { 700 if (nullptr == pr && strokeInfo.isDashed()) {
702 // 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.
703 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) { 702 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) {
704 return; 703 return;
705 } 704 }
706 pathPtr = tmpPath.get(); 705 pathPtr = tmpPath.get();
707 if (pathPtr->isEmpty()) { 706 if (pathPtr->isEmpty()) {
708 return; 707 return;
709 } 708 }
710 strokeInfoPtr = &dashlessStrokeInfo; 709 strokeInfoPtr = &dashlessStrokeInfo;
711 pr = fDrawingManager->getContext()->getPathRenderer(target, pipelineBuil der, viewMatrix, 710 pr = fDrawingManager->getContext()->getPathRenderer(pipelineBuilder, vie wMatrix,
712 *pathPtr, *strokeInf oPtr, 711 *pathPtr, *strokeInf oPtr,
713 false, type); 712 false, type);
714 } 713 }
715 714
716 if (nullptr == pr) { 715 if (nullptr == pr) {
717 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) && 716 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) &&
718 !strokeInfoPtr->isFillStyle()) { 717 !strokeInfoPtr->isFillStyle()) {
719 // 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.
720 if (!tmpPath.isValid()) { 719 if (!tmpPath.isValid()) {
721 tmpPath.init(); 720 tmpPath.init();
722 } 721 }
723 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) ); 722 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) );
724 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) { 723 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) {
725 return; 724 return;
726 } 725 }
727 pathPtr = tmpPath.get(); 726 pathPtr = tmpPath.get();
728 if (pathPtr->isEmpty()) { 727 if (pathPtr->isEmpty()) {
729 return; 728 return;
730 } 729 }
731 dashlessStrokeInfo.setFillStyle(); 730 dashlessStrokeInfo.setFillStyle();
732 strokeInfoPtr = &dashlessStrokeInfo; 731 strokeInfoPtr = &dashlessStrokeInfo;
733 } 732 }
734 733
735 // This time, allow SW renderer 734 // This time, allow SW renderer
736 pr = fDrawingManager->getContext()->getPathRenderer(target, pipelineBuil der, viewMatrix, 735 pr = fDrawingManager->getContext()->getPathRenderer(pipelineBuilder, vie wMatrix,
737 *pathPtr, *strokeInf oPtr, 736 *pathPtr, *strokeInf oPtr,
738 true, type); 737 true, type);
739 } 738 }
740 739
741 if (nullptr == pr) { 740 if (nullptr == pr) {
742 #ifdef SK_DEBUG 741 #ifdef SK_DEBUG
743 SkDebugf("Unable to find path renderer compatible with path.\n"); 742 SkDebugf("Unable to find path renderer compatible with path.\n");
744 #endif 743 #endif
745 return; 744 return;
746 } 745 }
747 746
748 GrPathRenderer::DrawPathArgs args; 747 GrPathRenderer::DrawPathArgs args;
749 args.fTarget = target; 748 args.fTarget = this->getDrawTarget();
750 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); 749 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider();
751 args.fPipelineBuilder = pipelineBuilder; 750 args.fPipelineBuilder = pipelineBuilder;
752 args.fColor = color; 751 args.fColor = color;
753 args.fViewMatrix = &viewMatrix; 752 args.fViewMatrix = &viewMatrix;
754 args.fPath = pathPtr; 753 args.fPath = pathPtr;
755 args.fStroke = strokeInfoPtr; 754 args.fStroke = strokeInfoPtr;
756 args.fAntiAlias = useCoverageAA; 755 args.fAntiAlias = useCoverageAA;
757 pr->drawPath(args); 756 pr->drawPath(args);
758 } 757 }
759 758
760 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 759 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
761 RETURN_IF_ABANDONED 760 RETURN_IF_ABANDONED
762 SkDEBUGCODE(this->validate();) 761 SkDEBUGCODE(this->validate();)
763 762
764 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 763 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
765 } 764 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrPathRendererChain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698