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

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

Issue 1261083003: Use new API everywhere for GrDefaultGeoProcFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@lccleanup2
Patch Set: tweaks Created 5 years, 4 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 | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrAAHairLinePathRenderer.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 2012 Google Inc. 3 * Copyright 2012 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 "GrAAConvexPathRenderer.h" 9 #include "GrAAConvexPathRenderer.h"
10 10
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 tess.coverage(i); 711 tess.coverage(i);
712 } 712 }
713 } 713 }
714 714
715 for (int i = 0; i < tess.numIndices(); ++i) { 715 for (int i = 0; i < tess.numIndices(); ++i) {
716 idxs[i] = tess.index(i); 716 idxs[i] = tess.index(i);
717 } 717 }
718 } 718 }
719 719
720 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, 720 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
721 const SkMatrix& localMatrix, 721 const SkMatrix& viewMatrix,
722 bool usesLocalCoords, 722 bool usesLocalCoords,
723 bool coverageIgnored) { 723 bool coverageIgnored) {
724 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; 724 using namespace GrDefaultGeoProcFactory;
725 if (!tweakAlphaForCoverage) { 725
726 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; 726 Color color(Color::kAttribute_Type);
727 Coverage::Type coverageType;
728 // TODO remove coverage if coverage is ignored
729 /*if (coverageIgnored) {
730 coverageType = Coverage::kNone_Type;
731 } else*/ if (tweakAlphaForCoverage) {
732 coverageType = Coverage::kSolid_Type;
733 } else {
734 coverageType = Coverage::kAttribute_Type;
727 } 735 }
728 736 Coverage coverage(coverageType);
729 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords , coverageIgnored, 737 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
730 SkMatrix::I(), localMatrix); 738 LocalCoords::kUnused_Type);
739 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
731 } 740 }
732 741
733 class AAConvexPathBatch : public GrBatch { 742 class AAConvexPathBatch : public GrBatch {
734 public: 743 public:
735 struct Geometry { 744 struct Geometry {
736 GrColor fColor; 745 GrColor fColor;
737 SkMatrix fViewMatrix; 746 SkMatrix fViewMatrix;
738 SkPath fPath; 747 SkPath fPath;
739 }; 748 };
740 749
(...skipping 23 matching lines...) Expand all
764 fBatch.fColor = fGeoData[0].fColor; 773 fBatch.fColor = fGeoData[0].fColor;
765 fBatch.fUsesLocalCoords = init.readsLocalCoords(); 774 fBatch.fUsesLocalCoords = init.readsLocalCoords();
766 fBatch.fCoverageIgnored = !init.readsCoverage(); 775 fBatch.fCoverageIgnored = !init.readsCoverage();
767 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks(); 776 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks();
768 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); 777 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
769 } 778 }
770 779
771 void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { 780 void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) {
772 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 781 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
773 782
774 SkMatrix invert; 783 // Setup GrGeometryProcessor
775 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 784 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage,
776 SkDebugf("Could not invert viewmatrix\n"); 785 this->viewMatr ix(),
786 this->usesLoca lCoords(),
787 this->coverage Ignored()));
788 if (!gp) {
789 SkDebugf("Could not create GrGeometryProcessor\n");
777 return; 790 return;
778 } 791 }
779 792
780 // Setup GrGeometryProcessor
781 SkAutoTUnref<const GrGeometryProcessor> gp(
782 create_fill_gp(canTweakAlphaForC overage, invert,
783 this->usesLocalCo ords(),
784 this->coverageIgn ored()));
785
786 batchTarget->initDraw(gp, pipeline); 793 batchTarget->initDraw(gp, pipeline);
787 794
788 size_t vertexStride = gp->getVertexStride(); 795 size_t vertexStride = gp->getVertexStride();
789 796
790 SkASSERT(canTweakAlphaForCoverage ? 797 SkASSERT(canTweakAlphaForCoverage ?
791 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 798 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
792 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 799 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
793 800
794 GrAAConvexTessellator tess; 801 GrAAConvexTessellator tess;
795 802
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 BATCH_TEST_DEFINE(AAConvexPathBatch) { 1015 BATCH_TEST_DEFINE(AAConvexPathBatch) {
1009 AAConvexPathBatch::Geometry geometry; 1016 AAConvexPathBatch::Geometry geometry;
1010 geometry.fColor = GrRandomColor(random); 1017 geometry.fColor = GrRandomColor(random);
1011 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1018 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1012 geometry.fPath = GrTest::TestPathConvex(random); 1019 geometry.fPath = GrTest::TestPathConvex(random);
1013 1020
1014 return AAConvexPathBatch::Create(geometry); 1021 return AAConvexPathBatch::Create(geometry);
1015 } 1022 }
1016 1023
1017 #endif 1024 #endif
OLDNEW
« no previous file with comments | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698