diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAAConvexPathRenderer.cpp | 38 | ||||
-rw-r--r-- | src/gpu/GrAAHairLinePathRenderer.cpp | 24 | ||||
-rw-r--r-- | src/gpu/GrAALinearizingConvexPathRenderer.cpp | 38 | ||||
-rw-r--r-- | src/gpu/GrAARectRenderer.cpp | 50 | ||||
-rw-r--r-- | src/gpu/GrDefaultGeoProcFactory.cpp | 34 | ||||
-rw-r--r-- | src/gpu/GrDefaultGeoProcFactory.h | 11 | ||||
-rw-r--r-- | src/gpu/GrDefaultPathRenderer.cpp | 21 | ||||
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 35 | ||||
-rw-r--r-- | src/gpu/GrRectBatch.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrTessellatingPathRenderer.cpp | 23 | ||||
-rw-r--r-- | src/gpu/effects/GrDashingEffect.cpp | 46 |
11 files changed, 168 insertions, 154 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 344b11921c..0024d3b83d 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -718,16 +718,24 @@ static void extract_verts(const GrAAConvexTessellator& tess, } static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, - const SkMatrix& localMatrix, + const SkMatrix& viewMatrix, bool usesLocalCoords, bool coverageIgnored) { - uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; - if (!tweakAlphaForCoverage) { - flags |= GrDefaultGeoProcFactory::kCoverage_GPType; + using namespace GrDefaultGeoProcFactory; + + Color color(Color::kAttribute_Type); + Coverage::Type coverageType; + if (coverageIgnored) { + coverageType = Coverage::kNone_Type; + } else if (tweakAlphaForCoverage) { + coverageType = Coverage::kSolid_Type; + } else { + coverageType = Coverage::kAttribute_Type; } - - return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, - SkMatrix::I(), localMatrix); + Coverage coverage(coverageType); + LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); } class AAConvexPathBatch : public GrBatch { @@ -771,18 +779,16 @@ public: void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); - SkMatrix invert; - if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { - SkDebugf("Could not invert viewmatrix\n"); + // Setup GrGeometryProcessor + SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage, + this->viewMatrix(), + this->usesLocalCoords(), + this->coverageIgnored())); + if (!gp) { + SkDebugf("Could not create GrGeometryProcessor\n"); return; } - // Setup GrGeometryProcessor - SkAutoTUnref<const GrGeometryProcessor> gp( - create_fill_gp(canTweakAlphaForCoverage, invert, - this->usesLocalCoords(), - this->coverageIgnored())); - batchTarget->initDraw(gp, pipeline); size_t vertexStride = gp->getVertexStride(); diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index bbaf8db200..7a2c7a6fa3 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -807,18 +807,18 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel toSrc = &invert; } - // Setup geometry processors for worst case - uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType | - GrDefaultGeoProcFactory::kCoverage_GPType; - - SkAutoTUnref<const GrGeometryProcessor> lineGP( - GrDefaultGeoProcFactory::Create(gpFlags, - this->color(), - this->usesLocalCoords(), - this->coverageIgnored(), - *geometryProcessorViewM, - *geometryProcessorLocalM, - this->coverage())); + SkAutoTUnref<const GrGeometryProcessor> lineGP; + { + using namespace GrDefaultGeoProcFactory; + + Color color(this->color()); + Coverage coverage(Coverage::kAttribute_Type); + LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + localCoords.fMatrix = geometryProcessorLocalM; + lineGP.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords, + *geometryProcessorViewM)); + } SkAutoTUnref<const GrGeometryProcessor> quadGP( GrQuadEffect::Create(this->color(), diff --git a/src/gpu/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/GrAALinearizingConvexPathRenderer.cpp index 69f9d1cca1..a1aed35f59 100644 --- a/src/gpu/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/GrAALinearizingConvexPathRenderer.cpp @@ -93,16 +93,24 @@ static void extract_verts(const GrAAConvexTessellator& tess, } static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, - const SkMatrix& localMatrix, + const SkMatrix& viewMatrix, bool usesLocalCoords, bool coverageIgnored) { - uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; - if (!tweakAlphaForCoverage) { - flags |= GrDefaultGeoProcFactory::kCoverage_GPType; + using namespace GrDefaultGeoProcFactory; + + Color color(Color::kAttribute_Type); + Coverage::Type coverageType; + if (coverageIgnored) { + coverageType = Coverage::kNone_Type; + } else if (tweakAlphaForCoverage) { + coverageType = Coverage::kSolid_Type; + } else { + coverageType = Coverage::kAttribute_Type; } - - return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, - SkMatrix::I(), localMatrix); + Coverage coverage(coverageType); + LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); } class AAFlatteningConvexPathBatch : public GrBatch { @@ -178,18 +186,16 @@ public: void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); - SkMatrix invert; - if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { - SkDebugf("Could not invert viewmatrix\n"); + // Setup GrGeometryProcessor + SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage, + this->viewMatrix(), + this->usesLocalCoords(), + this->coverageIgnored())); + if (!gp) { + SkDebugf("Couldn't create a GrGeometryProcessor\n"); return; } - // Setup GrGeometryProcessor - SkAutoTUnref<const GrGeometryProcessor> gp( - create_fill_gp(canTweakAlphaForCoverage, invert, - this->usesLocalCoords(), - this->coverageIgnored())); - batchTarget->initDraw(gp, pipeline); size_t vertexStride = gp->getVertexStride(); diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index ffee841464..7710bf71c2 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -32,20 +32,24 @@ static void set_inset_fan(SkPoint* pts, size_t stride, } static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage, - const SkMatrix& localMatrix, + const SkMatrix& viewMatrix, bool usesLocalCoords, bool coverageIgnored) { - uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; - const GrGeometryProcessor* gp; - if (tweakAlphaForCoverage) { - gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, - SkMatrix::I(), localMatrix); + using namespace GrDefaultGeoProcFactory; + + Color color(Color::kAttribute_Type); + Coverage::Type coverageType; + if (coverageIgnored) { + coverageType = Coverage::kNone_Type; + } else if (tweakAlphaForCoverage) { + coverageType = Coverage::kSolid_Type; } else { - flags |= GrDefaultGeoProcFactory::kCoverage_GPType; - gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, - SkMatrix::I(), localMatrix); + coverageType = Coverage::kAttribute_Type; } - return gp; + Coverage coverage(coverageType); + LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); } GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); @@ -92,16 +96,14 @@ public: void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); - SkMatrix localMatrix; - if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { - SkDebugf("Cannot invert\n"); - return; - } - SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, - localMatrix, + this->viewMatrix(), this->usesLocalCoords(), this->coverageIgnored())); + if (!gp) { + SkDebugf("Couldn't create GrGeometryProcessor\n"); + return; + } batchTarget->initDraw(gp, pipeline); @@ -444,18 +446,14 @@ public: void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); - // Local matrix is ignored if we don't have local coords. If we have localcoords we only - // batch with identical view matrices - SkMatrix localMatrix; - if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { - SkDebugf("Cannot invert\n"); - return; - } - SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, - localMatrix, + this->viewMatrix(), this->usesLocalCoords(), this->coverageIgnored())); + if (!gp) { + SkDebugf("Couldn't create GrGeometryProcessor\n"); + return; + } batchTarget->initDraw(gp, pipeline); diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index 68fcd05576..639a593220 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -258,22 +258,6 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) { GrRandomCoverage(d->fRandom)); } -const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags, - GrColor color, - bool localCoordsWillBeRead, - bool coverageWillBeIgnored, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - uint8_t coverage) { - return DefaultGeoProc::Create(gpTypeFlags, - color, - viewMatrix, - localMatrix, - localCoordsWillBeRead, - coverageWillBeIgnored, - coverage); -} - const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color, const Coverage& coverage, const LocalCoords& localCoords, @@ -302,17 +286,19 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace( const Coverage& coverage, const LocalCoords& localCoords, const SkMatrix& viewMatrix) { - SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType); SkMatrix invert = SkMatrix::I(); - if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) { - SkDebugf("Could not invert\n"); - return NULL; - } + if (LocalCoords::kUnused_Type != localCoords.fType) { + SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType); + if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) { + SkDebugf("Could not invert\n"); + return NULL; + } - if (localCoords.hasLocalMatrix()) { - invert.preConcat(*localCoords.fMatrix); + if (localCoords.hasLocalMatrix()) { + invert.preConcat(*localCoords.fMatrix); + } } LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); - return Create(color, coverage, inverted); + return Create(color, coverage, inverted, SkMatrix::I()); } diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h index bdefd4a920..cd886a20e2 100644 --- a/src/gpu/GrDefaultGeoProcFactory.h +++ b/src/gpu/GrDefaultGeoProcFactory.h @@ -127,7 +127,7 @@ namespace GrDefaultGeoProcFactory { const GrGeometryProcessor* Create(const Color&, const Coverage&, const LocalCoords&, - const SkMatrix& viewMatrix = SkMatrix::I()); + const SkMatrix& viewMatrix); /* * Use this factory to create a GrGeometryProcessor that expects a device space vertex position @@ -139,15 +139,6 @@ namespace GrDefaultGeoProcFactory { const LocalCoords&, const SkMatrix& viewMatrix); - // TODO deprecate this - const GrGeometryProcessor* Create(uint32_t gpTypeFlags, - GrColor, - bool localCoordsWillBeRead, - bool coverageWillBeIgnored, - const SkMatrix& viewMatrix = SkMatrix::I(), - const SkMatrix& localMatrix = SkMatrix::I(), - uint8_t coverage = 0xff); - inline size_t DefaultVertexStride() { return sizeof(PositionAttr); } }; diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp index 9258bfb1d8..fe38f1f3cb 100644 --- a/src/gpu/GrDefaultPathRenderer.cpp +++ b/src/gpu/GrDefaultPathRenderer.cpp @@ -250,14 +250,19 @@ public: } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { - SkAutoTUnref<const GrGeometryProcessor> gp( - GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, - this->color(), - this->usesLocalCoords(), - this->coverageIgnored(), - this->viewMatrix(), - SkMatrix::I(), - this->coverage())); + SkAutoTUnref<const GrGeometryProcessor> gp; + { + using namespace GrDefaultGeoProcFactory; + Color color(this->color()); + Coverage coverage(this->coverage()); + if (this->coverageIgnored()) { + coverage.fType = Coverage::kNone_Type; + } + LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords, + this->viewMatrix())); + } size_t vertexStride = gp->getVertexStride(); SkASSERT(vertexStride == sizeof(SkPoint)); diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 5a496d2517..1a7734d0f8 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -288,13 +288,17 @@ public: } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { - SkAutoTUnref<const GrGeometryProcessor> gp( - GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, - this->color(), - this->usesLocalCoords(), - this->coverageIgnored(), - this->viewMatrix(), - SkMatrix::I())); + SkAutoTUnref<const GrGeometryProcessor> gp; + { + using namespace GrDefaultGeoProcFactory; + Color color(this->color()); + Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : + Coverage::kNone_Type); + LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords, + this->viewMatrix())); + } batchTarget->initDraw(gp, pipeline); @@ -560,23 +564,26 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords, GrColor color, const SkMatrix& viewMatrix, bool coverageIgnored) { + using namespace GrDefaultGeoProcFactory; *texOffset = -1; *colorOffset = -1; - uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; + Color gpColor(color); + if (hasColors) { + gpColor.fType = Color::kAttribute_Type; + } + + Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_Type); + LocalCoords localCoords(hasLocalCoords ? LocalCoords::kHasExplicit_Type : + LocalCoords::kUsePosition_Type); if (hasLocalCoords && hasColors) { *colorOffset = sizeof(SkPoint); *texOffset = sizeof(SkPoint) + sizeof(GrColor); - flags |= GrDefaultGeoProcFactory::kColor_GPType | - GrDefaultGeoProcFactory::kLocalCoord_GPType; } else if (hasLocalCoords) { *texOffset = sizeof(SkPoint); - flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType; } else if (hasColors) { *colorOffset = sizeof(SkPoint); - flags |= GrDefaultGeoProcFactory::kColor_GPType; } - return GrDefaultGeoProcFactory::Create(flags, color, hasLocalCoords, coverageIgnored, - viewMatrix, SkMatrix::I()); + return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix); } class DrawVerticesBatch : public GrBatch { diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp index efb45de8e1..60f0800a9b 100644 --- a/src/gpu/GrRectBatch.cpp +++ b/src/gpu/GrRectBatch.cpp @@ -183,7 +183,7 @@ private: // generate vertex local coords if (this->hasLocalRect()) { LocalCoords localCoords(LocalCoords::kHasExplicit_Type); - return GrDefaultGeoProcFactory::Create(color, coverage, localCoords); + return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()); } else { LocalCoords localCoords(LocalCoords::kUsePosition_Type, this->hasLocalMatrix() ? &this->localMatrix() : NULL); diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp index 6abfc4538f..d0c7d3dd2c 100644 --- a/src/gpu/GrTessellatingPathRenderer.cpp +++ b/src/gpu/GrTessellatingPathRenderer.cpp @@ -1404,11 +1404,24 @@ public: } LOG("got %d pts, %d contours\n", maxPts, contourCnt); - uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; - SkAutoTUnref<const GrGeometryProcessor> gp( - GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.readsLocalCoords(), - !fPipelineInfo.readsCoverage(), fViewMatrix, - SkMatrix::I())); + SkAutoTUnref<const GrGeometryProcessor> gp; + { + using namespace GrDefaultGeoProcFactory; + + Color color(fColor); + LocalCoords localCoords(fPipelineInfo.readsLocalCoords() ? + LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + Coverage::Type coverageType; + if (fPipelineInfo.readsCoverage()) { + coverageType = Coverage::kSolid_Type; + } else { + coverageType = Coverage::kNone_Type; + } + Coverage coverage(coverageType); + gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords, + fViewMatrix)); + } batchTarget->initDraw(gp, pipeline); SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt)); diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index 550823aacb..afb09b9539 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -300,30 +300,28 @@ public: void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { int instanceCount = fGeoData.count(); - - SkMatrix invert; - if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { - SkDebugf("Failed to invert\n"); - return; - } - SkPaint::Cap cap = this->cap(); - - SkAutoTUnref<const GrGeometryProcessor> gp; - bool isRoundCap = SkPaint::kRound_Cap == cap; DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap; + + SkAutoTUnref<const GrGeometryProcessor> gp; if (this->fullDash()) { - gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, invert, + gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(), this->usesLocalCoords())); } else { // Set up the vertex data for the line and start/end dashes - gp.reset(GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, - this->color(), - this->usesLocalCoords(), - this->coverageIgnored(), - SkMatrix::I(), - invert)); + using namespace GrDefaultGeoProcFactory; + Color color(this->color()); + Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type : + Coverage::kSolid_Type); + LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type : + LocalCoords::kUnused_Type); + gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->viewMatrix())); + } + + if (!gp) { + SkDebugf("Could not create GrGeometryProcessor\n"); + return; } batchTarget->initDraw(gp, pipeline); @@ -1209,15 +1207,19 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) { static GrGeometryProcessor* create_dash_gp(GrColor color, DashAAMode dashAAMode, DashCap cap, - const SkMatrix& localMatrix, + const SkMatrix& viewMatrix, bool usesLocalCoords) { + SkMatrix invert; + if (usesLocalCoords && !viewMatrix.invert(&invert)) { + SkDebugf("Failed to invert\n"); + return NULL; + } + switch (cap) { case kRound_DashCap: - return DashingCircleEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords); + return DashingCircleEffect::Create(color, dashAAMode, invert, usesLocalCoords); case kNonRound_DashCap: - return DashingLineEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords); - default: - SkFAIL("Unexpected dashed cap."); + return DashingLineEffect::Create(color, dashAAMode, invert, usesLocalCoords); } return NULL; } |