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

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: feedback inc 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
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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor) ) = 714 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor) ) =
715 tess.coverage(i); 715 tess.coverage(i);
716 } 716 }
717 } 717 }
718 718
719 for (int i = 0; i < tess.numIndices(); ++i) { 719 for (int i = 0; i < tess.numIndices(); ++i) {
720 idxs[i] = tess.index(i); 720 idxs[i] = tess.index(i);
721 } 721 }
722 } 722 }
723 723
724 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
725 const SkMatrix& localMatrix,
726 bool usesLocalCoords,
727 bool coverageIgnored) {
728 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
729 if (!tweakAlphaForCoverage) {
730 flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
731 }
732
733 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords , coverageIgnored,
734 SkMatrix::I(), localMatrix);
735 }
736
737 class AAConvexPathBatch : public GrBatch { 724 class AAConvexPathBatch : public GrBatch {
738 public: 725 public:
739 struct Geometry { 726 struct Geometry {
740 GrColor fColor; 727 GrColor fColor;
741 SkMatrix fViewMatrix; 728 SkMatrix fViewMatrix;
742 SkPath fPath; 729 SkPath fPath;
743 }; 730 };
744 731
745 static GrBatch* Create(const Geometry& geometry) { 732 static GrBatch* Create(const Geometry& geometry) {
746 return SkNEW_ARGS(AAConvexPathBatch, (geometry)); 733 return SkNEW_ARGS(AAConvexPathBatch, (geometry));
(...skipping 20 matching lines...) Expand all
767 fBatch.fColorIgnored = !init.readsColor(); 754 fBatch.fColorIgnored = !init.readsColor();
768 fBatch.fColor = fGeoData[0].fColor; 755 fBatch.fColor = fGeoData[0].fColor;
769 fBatch.fUsesLocalCoords = init.readsLocalCoords(); 756 fBatch.fUsesLocalCoords = init.readsLocalCoords();
770 fBatch.fCoverageIgnored = !init.readsCoverage(); 757 fBatch.fCoverageIgnored = !init.readsCoverage();
771 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks(); 758 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks();
772 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); 759 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
773 } 760 }
774 761
775 void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { 762 void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) {
776 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); 763 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
777 764 SkAutoTUnref<const GrGeometryProcessor> gp(
778 SkMatrix invert; 765 GrDefaultGeoProcFactory::CreateForDeviceSpaceAlphaTweakIfPossibl e(
779 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 766 this->viewMatrix(), this->usesLocalCoords(), this->cover ageIgnored(),
780 SkDebugf("Could not invert viewmatrix\n"); 767 canTweakAlphaForCoverage));
768 if (!gp) {
769 SkDebugf("Could not create GrGeometryProcessor\n");
781 return; 770 return;
782 } 771 }
783 772
784 // Setup GrGeometryProcessor
785 SkAutoTUnref<const GrGeometryProcessor> gp(
786 create_fill_gp(canTweakAlphaForC overage, invert,
787 this->usesLocalCo ords(),
788 this->coverageIgn ored()));
789
790 batchTarget->initDraw(gp, pipeline); 773 batchTarget->initDraw(gp, pipeline);
791 774
792 size_t vertexStride = gp->getVertexStride(); 775 size_t vertexStride = gp->getVertexStride();
793 776
794 SkASSERT(canTweakAlphaForCoverage ? 777 SkASSERT(canTweakAlphaForCoverage ?
795 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : 778 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) :
796 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); 779 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr));
797 780
798 GrAAConvexTessellator tess; 781 GrAAConvexTessellator tess;
799 782
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 BATCH_TEST_DEFINE(AAConvexPathBatch) { 1001 BATCH_TEST_DEFINE(AAConvexPathBatch) {
1019 AAConvexPathBatch::Geometry geometry; 1002 AAConvexPathBatch::Geometry geometry;
1020 geometry.fColor = GrRandomColor(random); 1003 geometry.fColor = GrRandomColor(random);
1021 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1004 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1022 geometry.fPath = GrTest::TestPathConvex(random); 1005 geometry.fPath = GrTest::TestPathConvex(random);
1023 1006
1024 return AAConvexPathBatch::Create(geometry); 1007 return AAConvexPathBatch::Create(geometry);
1025 } 1008 }
1026 1009
1027 #endif 1010 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698