diff options
author | Brian Salomon <bsalomon@google.com> | 2017-04-03 10:38:00 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-03 15:13:48 +0000 |
commit | d3ccb0a37f0e62c84fdcd6a77b7b15476b04db7a (patch) | |
tree | a050c5624e60eee8193f4aa015269ad3bf14e329 | |
parent | dffe9827b18444d1426859d9035f9f0087201f44 (diff) |
Move pipeline handling out of GrMeshDrawOp.
The monolithic GrPipeline is moved to a subclass GrLegacyDrawMeshOp.
The pipeline used to record a GrMesh draw in a GrMeshDrawOp must now be passed rather than implicitly using the op's pipeline.
Change-Id: I50d77e4dcc8d91a523fa7566ce43a9a291174706
Reviewed-on: https://skia-review.googlesource.com/11002
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
66 files changed, 686 insertions, 656 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index 523ccd31f8..c67018d2af 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -30,9 +30,10 @@ public: const char* name() const override { return "BezierCubicOrConicTestOp"; } - static std::unique_ptr<GrMeshDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, - GrColor color, const SkMatrix& klm, SkScalar sign) { - return std::unique_ptr<GrMeshDrawOp>( + static std::unique_ptr<GrLegacyMeshDrawOp> Make(sk_sp<GrGeometryProcessor> gp, + const SkRect& rect, GrColor color, + const SkMatrix& klm, SkScalar sign) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new BezierCubicOrConicTestOp(gp, rect, color, klm, sign)); } @@ -66,7 +67,7 @@ private: SkScalar pt3[3] = {verts[v].fPosition.x(), verts[v].fPosition.y(), 1.f}; fKLM.mapHomogeneousPoints(verts[v].fKLM, pt3, 1); } - helper.recordDraw(target, fGeometryProcessor.get()); + helper.recordDraw(target, fGeometryProcessor.get(), this->pipeline()); } SkMatrix fKLM; @@ -197,10 +198,10 @@ protected: sign = -1.0f; } - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = BezierCubicOrConicTestOp::Make(gp, bounds, color, klm, sign); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } ++col; @@ -330,10 +331,10 @@ protected: GrPaint grPaint; grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = BezierCubicOrConicTestOp::Make(gp, bounds, color, klm, 1.f); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } ++col; @@ -396,10 +397,10 @@ public: DEFINE_OP_CLASS_ID const char* name() const override { return "BezierQuadTestOp"; } - static std::unique_ptr<GrMeshDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, - GrColor color, - const GrPathUtils::QuadUVMatrix& devToUV) { - return std::unique_ptr<GrMeshDrawOp>(new BezierQuadTestOp(gp, rect, color, devToUV)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(sk_sp<GrGeometryProcessor> gp, + const SkRect& rect, GrColor color, + const GrPathUtils::QuadUVMatrix& devToUV) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new BezierQuadTestOp(gp, rect, color, devToUV)); } private: @@ -426,7 +427,7 @@ private: verts[0].fPosition.setRectFan(fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, sizeof(Vertex)); fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); - helper.recordDraw(target, fGeometryProcessor.get()); + helper.recordDraw(target, fGeometryProcessor.get(), this->pipeline()); } GrPathUtils::QuadUVMatrix fDevToUV; @@ -548,10 +549,10 @@ protected: GrPathUtils::QuadUVMatrix DevToUV(pts); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = BezierQuadTestOp::Make(gp, bounds, color, DevToUV); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } ++col; diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp index 0520776474..786e1775c1 100644 --- a/gm/bigrrectaaeffect.cpp +++ b/gm/bigrrectaaeffect.cpp @@ -87,9 +87,9 @@ protected: SkRect bounds = testBounds; bounds.offset(SkIntToScalar(x), SkIntToScalar(y)); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( 0xff000000, SkMatrix::I(), bounds, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } canvas->restore(); diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp index 9f30bed4eb..a595a07d38 100644 --- a/gm/constcolorprocessor.cpp +++ b/gm/constcolorprocessor.cpp @@ -110,9 +110,9 @@ protected: grPaint.addColorFragmentProcessor(std::move(fp)); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( grPaint.getColor(), viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); // Draw labels for the input to the processor and the processor to the right of diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp index 0ce7ba71ab..8ace4d0b3d 100644 --- a/gm/convexpolyeffect.cpp +++ b/gm/convexpolyeffect.cpp @@ -46,8 +46,8 @@ public: const char* name() const override { return "PolyBoundsOp"; } - static std::unique_ptr<GrMeshDrawOp> Make(const SkRect& rect, GrColor color) { - return std::unique_ptr<GrMeshDrawOp>(new PolyBoundsOp(rect, color)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(const SkRect& rect, GrColor color) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new PolyBoundsOp(rect, color)); } private: @@ -71,7 +71,7 @@ private: fRect.toQuad(verts); - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } SkRect fRect; @@ -183,9 +183,10 @@ protected: grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); grPaint.addCoverageFragmentProcessor(std::move(fp)); - std::unique_ptr<GrMeshDrawOp> op = PolyBoundsOp::Make(p.getBounds(), 0xff000000); + std::unique_ptr<GrLegacyMeshDrawOp> op = + PolyBoundsOp::Make(p.getBounds(), 0xff000000); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); x += SkScalarCeilToScalar(path->getBounds().width() + kDX); @@ -223,9 +224,9 @@ protected: grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); grPaint.addCoverageFragmentProcessor(std::move(fp)); - std::unique_ptr<GrMeshDrawOp> op = PolyBoundsOp::Make(rect, 0xff000000); + std::unique_ptr<GrLegacyMeshDrawOp> op = PolyBoundsOp::Make(rect, 0xff000000); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); x += SkScalarCeilToScalar(rect.width() + kDX); diff --git a/gm/etc1.cpp b/gm/etc1.cpp index 26e6051852..369a62c330 100644 --- a/gm/etc1.cpp +++ b/gm/etc1.cpp @@ -99,10 +99,10 @@ protected: SkRect rect = SkRect::MakeXYWH(kPad, kPad, kTexWidth, kTexHeight); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( GrColor_WHITE, SkMatrix::I(), rect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp(std::move(grPaint), GrAAType::kNone, - std::move(op)); + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( + std::move(grPaint), GrAAType::kNone, std::move(op)); } private: diff --git a/gm/rrects.cpp b/gm/rrects.cpp index ac66d521cb..8219681b14 100644 --- a/gm/rrects.cpp +++ b/gm/rrects.cpp @@ -115,9 +115,9 @@ protected: SkRect bounds = rrect.getBounds(); bounds.outset(2.f, 2.f); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( 0xff000000, SkMatrix::I(), bounds, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } else { drew = false; diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index 88bcc57c9a..6a296f4d1f 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -134,9 +134,9 @@ protected: const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); grPaint.addColorFragmentProcessor(std::move(fp)); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); x += renderRect.width() + kTestPad; } diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index fda0565559..87d76cb2ac 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -132,9 +132,9 @@ protected: grPaint.addColorFragmentProcessor(std::move(fp)); SkMatrix viewMatrix; viewMatrix.setTranslate(x, y); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } x += renderRect.width() + kTestPad; @@ -257,9 +257,9 @@ protected: SkMatrix viewMatrix; viewMatrix.setTranslate(x, y); grPaint.addColorFragmentProcessor(fp); - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); } } diff --git a/src/gpu/GrDrawOpTest.cpp b/src/gpu/GrDrawOpTest.cpp index 6e63f5d0e1..1e88c219f5 100644 --- a/src/gpu/GrDrawOpTest.cpp +++ b/src/gpu/GrDrawOpTest.cpp @@ -13,7 +13,7 @@ #if GR_TEST_UTILS #define DRAW_OP_TEST_EXTERN(Op) \ - extern std::unique_ptr<GrMeshDrawOp> Op##__Test(SkRandom*, GrContext* context); + extern std::unique_ptr<GrLegacyMeshDrawOp> Op##__Test(SkRandom*, GrContext* context); #define DRAW_OP_TEST_ENTRY(Op) Op##__Test @@ -37,8 +37,9 @@ DRAW_OP_TEST_EXTERN(TesselatingPathOp); DRAW_OP_TEST_EXTERN(TextBlobOp); DRAW_OP_TEST_EXTERN(VerticesOp); -std::unique_ptr<GrMeshDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) { - using MakeTestDrawOpFn = std::unique_ptr<GrMeshDrawOp>(SkRandom* random, GrContext* context); +std::unique_ptr<GrLegacyMeshDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) { + using MakeTestDrawOpFn = + std::unique_ptr<GrLegacyMeshDrawOp>(SkRandom * random, GrContext * context); static constexpr MakeTestDrawOpFn* gFactories[] = { DRAW_OP_TEST_ENTRY(AAConvexPathOp), DRAW_OP_TEST_ENTRY(AAFillRectOp), diff --git a/src/gpu/GrDrawOpTest.h b/src/gpu/GrDrawOpTest.h index 43bd21a59e..376022999b 100644 --- a/src/gpu/GrDrawOpTest.h +++ b/src/gpu/GrDrawOpTest.h @@ -14,19 +14,19 @@ #if GR_TEST_UTILS class GrContext; -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkRandom; /** This function returns a randomly configured GrDrawOp for testing purposes. */ -std::unique_ptr<GrMeshDrawOp> GrRandomDrawOp(SkRandom*, GrContext*); +std::unique_ptr<GrLegacyMeshDrawOp> GrRandomDrawOp(SkRandom*, GrContext*); /** GrDrawOp subclasses should define test factory functions using this macro. */ #define DRAW_OP_TEST_DEFINE(Op) \ - std::unique_ptr<GrMeshDrawOp> Op##__Test(SkRandom* random, GrContext* context) + std::unique_ptr<GrLegacyMeshDrawOp> Op##__Test(SkRandom* random, GrContext* context) /** This macro may be used if the test factory function must be made a friend of a class. */ #define DRAW_OP_TEST_FRIEND(Op) \ - friend std::unique_ptr<GrMeshDrawOp> Op##__Test(SkRandom* random, GrContext* context); + friend std::unique_ptr<GrLegacyMeshDrawOp> Op##__Test(SkRandom* random, GrContext* context); #endif #endif diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h index d7ed4e0b47..4ba87feebf 100644 --- a/src/gpu/GrOpFlushState.h +++ b/src/gpu/GrOpFlushState.h @@ -194,7 +194,7 @@ class GrMeshDrawOp::Target : public GrDrawOp::Target { public: Target(GrOpFlushState* state, GrMeshDrawOp* op) : INHERITED(state, op) {} - void draw(const GrGeometryProcessor* gp, const GrMesh& mesh); + void draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline, const GrMesh& mesh); void* makeVertexSpace(size_t vertexSize, int vertexCount, const GrBuffer** buffer, int* startVertex) { diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 82d938e4c3..2917dcbe27 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -74,8 +74,8 @@ void GrPipeline::init(const InitArgs& args) { fXferProcessor.reset(xferProcessor.get()); } - // This is for the legacy GrPipeline creation in GrMeshDrawOp where analysis does not eliminate - // fragment processors from GrProcessorSet. + // This is for the legacy GrPipeline creation in GrLegacyMeshDrawOp where analysis does not + // eliminate fragment processors from GrProcessorSet. int colorFPsToEliminate = 0; if (args.fAnalysis) { GrColor overrideColor = GrColor_ILLEGAL; diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 75d82d6f7d..91cd16456c 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -59,7 +59,7 @@ public: const GrProcessorSet* fProcessors = nullptr; GrProcessorAnalysisColor fInputColor; GrProcessorAnalysisCoverage fInputCoverage = GrProcessorAnalysisCoverage::kNone; - // This is only used for GrMeshDrawOp's legacy pipeline creation system. + // This is only used for GrLegacyMeshDrawOp's pipeline creation system. const GrProcessorSet::Analysis* fAnalysis = nullptr; const GrUserStencilSettings* fUserStencil = &GrUserStencilSettings::kUnused; const GrAppliedClip* fAppliedClip = nullptr; diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 3061074a08..e225bc9e5e 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -509,14 +509,14 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip, if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { SkRect devBoundRect; viewMatrix.mapRect(&devBoundRect, croppedRect); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrRectOpFactory::MakeAAFill(paint, viewMatrix, rect, croppedRect, devBoundRect); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); if (ss) { pipelineBuilder.setUserStencil(ss); } - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return true; } } @@ -617,7 +617,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip, } bool snapToPixelCenters = false; - std::unique_ptr<GrMeshDrawOp> op; + std::unique_ptr<GrLegacyMeshDrawOp> op; GrColor color = paint.getColor(); GrAAType aaType = this->decideAAType(aa); @@ -639,7 +639,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip, if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); pipelineBuilder.setSnapVerticesToPixelCenters(snapToPixelCenters); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } } @@ -811,10 +811,10 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip, } if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { - std::unique_ptr<GrMeshDrawOp> op = GrAAFillRectOp::MakeWithLocalRect( + std::unique_ptr<GrLegacyMeshDrawOp> op = GrAAFillRectOp::MakeWithLocalRect( paint.getColor(), viewMatrix, croppedRect, croppedLocalRect); GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } @@ -867,10 +867,10 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip, } if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrAAFillRectOp::Make(paint.getColor(), viewMatrix, localMatrix, croppedRect); GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } @@ -913,14 +913,14 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip, return; } - std::unique_ptr<GrMeshDrawOp> op = GrDrawVerticesOp::Make( + std::unique_ptr<GrLegacyMeshDrawOp> op = GrDrawVerticesOp::Make( paint.getColor(), primitiveType, viewMatrix, positions, vertexCount, indices, indexCount, colors, texCoords, bounds, colorArrayType); if (!op) { return; } GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } void GrRenderTargetContext::drawVertices(const GrClip& clip, @@ -935,13 +935,13 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip, AutoCheckFlush acf(this->drawingManager()); SkASSERT(vertices); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrDrawVerticesOp::Make(paint.getColor(), std::move(vertices), viewMatrix); if (!op) { return; } GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } /////////////////////////////////////////////////////////////////////////////// @@ -960,10 +960,10 @@ void GrRenderTargetContext::drawAtlas(const GrClip& clip, AutoCheckFlush acf(this->drawingManager()); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrDrawAtlasOp::Make(paint.getColor(), viewMatrix, spriteCount, xform, texRect, colors); GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } /////////////////////////////////////////////////////////////////////////////// @@ -1014,7 +1014,7 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip, GrAAType aaType = this->decideAAType(aa); if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeRRectOp(paint.getColor(), paint.usesDistanceVectorField(), viewMatrix, @@ -1023,7 +1023,7 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip, shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, *clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, *clip, std::move(op)); return; } } @@ -1057,11 +1057,11 @@ void GrRenderTargetContext::drawShadowRRect(const GrClip& clip, // TODO: add instancing support? const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - std::unique_ptr<GrMeshDrawOp> op = GrShadowRRectOp::Make(paint.getColor(), viewMatrix, rrect, - blurRadius, stroke, shaderCaps); + std::unique_ptr<GrLegacyMeshDrawOp> op = GrShadowRRectOp::Make( + paint.getColor(), viewMatrix, rrect, blurRadius, stroke, shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } } @@ -1200,9 +1200,9 @@ void GrRenderTargetContext::drawRegion(const GrClip& clip, return this->drawPath(clip, std::move(paint), aa, viewMatrix, path, style); } - std::unique_ptr<GrMeshDrawOp> op = GrRegionOp::Make(paint.getColor(), viewMatrix, region); + std::unique_ptr<GrLegacyMeshDrawOp> op = GrRegionOp::Make(paint.getColor(), viewMatrix, region); GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } void GrRenderTargetContext::drawOval(const GrClip& clip, @@ -1239,11 +1239,11 @@ void GrRenderTargetContext::drawOval(const GrClip& clip, GrAAType aaType = this->decideAAType(aa); if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeOvalOp(paint.getColor(), viewMatrix, oval, stroke, shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } } @@ -1273,17 +1273,17 @@ void GrRenderTargetContext::drawArc(const GrClip& clip, GrAAType aaType = this->decideAAType(aa); if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - std::unique_ptr<GrMeshDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(), - viewMatrix, - oval, - startAngle, - sweepAngle, - useCenter, - style, - shaderCaps); + std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(), + viewMatrix, + oval, + startAngle, + sweepAngle, + useCenter, + style, + shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } } @@ -1307,11 +1307,11 @@ void GrRenderTargetContext::drawImageLattice(const GrClip& clip, AutoCheckFlush acf(this->drawingManager()); - std::unique_ptr<GrMeshDrawOp> op = GrLatticeOp::MakeNonAA( + std::unique_ptr<GrLegacyMeshDrawOp> op = GrLatticeOp::MakeNonAA( paint.getColor(), viewMatrix, imageWidth, imageHeight, std::move(iter), dst); GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } void GrRenderTargetContext::prepareForExternalIO() { @@ -1333,13 +1333,13 @@ void GrRenderTargetContext::drawNonAAFilledRect(const GrClip& clip, GrAAType hwOrNoneAAType) { SkASSERT(GrAAType::kCoverage != hwOrNoneAAType); SkASSERT(hwOrNoneAAType == GrAAType::kNone || this->isStencilBufferMultisampled()); - std::unique_ptr<GrMeshDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, - rect, localRect, localMatrix); + std::unique_ptr<GrLegacyMeshDrawOp> op = GrRectOpFactory::MakeNonAAFill( + paint.getColor(), viewMatrix, rect, localRect, localMatrix); GrPipelineBuilder pipelineBuilder(std::move(paint), hwOrNoneAAType); if (ss) { pipelineBuilder.setUserStencil(ss); } - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } // Can 'path' be drawn as a pair of filled nested rectangles? @@ -1415,11 +1415,11 @@ void GrRenderTargetContext::drawPath(const GrClip& clip, SkRect rects[2]; if (fills_as_nested_rects(viewMatrix, path, rects)) { - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = GrRectOpFactory::MakeAAFillNestedRects(paint.getColor(), viewMatrix, rects); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } return; } @@ -1429,11 +1429,11 @@ void GrRenderTargetContext::drawPath(const GrClip& clip, if (isOval && !path.isInverseFillType()) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); - std::unique_ptr<GrMeshDrawOp> op = GrOvalOpFactory::MakeOvalOp( + std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeOvalOp( paint.getColor(), viewMatrix, ovalRect, style.strokeRec(), shaderCaps); if (op) { GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); - this->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + this->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); return; } } @@ -1676,15 +1676,15 @@ uint32_t GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<Gr return this->getOpList()->addOp(std::move(op), this, std::move(appliedClip), dstTexture); } -uint32_t GrRenderTargetContext::addMeshDrawOp(const GrPipelineBuilder& pipelineBuilder, - const GrClip& clip, - std::unique_ptr<GrMeshDrawOp> op) { +uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(const GrPipelineBuilder& pipelineBuilder, + const GrClip& clip, + std::unique_ptr<GrLegacyMeshDrawOp> op) { ASSERT_SINGLE_OWNER if (this->drawingManager()->wasAbandoned()) { return SK_InvalidUniqueID; } SkDEBUGCODE(this->validate();) - GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::addMeshDrawOp"); + GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::addLegacyMeshDrawOp"); // Setup clip SkRect bounds; diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index ed4493edd8..edec4de3ef 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -22,7 +22,7 @@ class GrClip; class GrDrawingManager; class GrDrawOp; class GrFixedClip; -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class GrPipelineBuilder; class GrRenderTarget; class GrRenderTargetContextPriv; @@ -466,7 +466,8 @@ private: // the op list. They return the id of the opList to which the op was added, or 0, if it was // dropped (e.g., due to clipping). uint32_t addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>); - uint32_t addMeshDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrMeshDrawOp>); + uint32_t addLegacyMeshDrawOp(const GrPipelineBuilder&, const GrClip&, + std::unique_ptr<GrLegacyMeshDrawOp>); // Makes a copy of the dst if it is necessary for the draw and returns the texture that should // be used by GrXferProcessor to access the destination color. If the texture is nullptr then diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h index dcde6088d5..e889317de4 100644 --- a/src/gpu/GrRenderTargetContextPriv.h +++ b/src/gpu/GrRenderTargetContextPriv.h @@ -102,9 +102,10 @@ public: return fRenderTargetContext->fRenderTargetProxy->uniqueID(); } - uint32_t testingOnly_addMeshDrawOp(GrPaint&&, GrAAType, std::unique_ptr<GrMeshDrawOp>, - const GrUserStencilSettings* = nullptr, - bool snapToCenters = false); + uint32_t testingOnly_addLegacyMeshDrawOp(GrPaint&&, GrAAType, + std::unique_ptr<GrLegacyMeshDrawOp>, + const GrUserStencilSettings* = nullptr, + bool snapToCenters = false); bool refsWrappedObjects() const { return fRenderTargetContext->fRenderTargetProxy->refsWrappedObjects(); diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 647496d6f1..fb06ab4ca1 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -173,12 +173,12 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy, SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX), SkIntToScalar(-textureOriginInDeviceSpace.fY)); maskMatrix.preConcat(viewMatrix); - std::unique_ptr<GrMeshDrawOp> op = GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op = GrRectOpFactory::MakeNonAAFill( paint.getColor(), SkMatrix::I(), dstRect, nullptr, &invert); paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make( resourceProvider, std::move(proxy), nullptr, maskMatrix, GrSamplerParams::kNone_FilterMode)); GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); pipelineBuilder.setUserStencil(&userStencilSettings); - renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + renderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 0228937255..25004e192b 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -76,12 +76,12 @@ void GrSoftwarePathRenderer::DrawNonAARect(GrRenderTargetContext* renderTargetCo const SkMatrix& viewMatrix, const SkRect& rect, const SkMatrix& localMatrix) { - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, - rect, nullptr, &localMatrix)); + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + paint.getColor(), viewMatrix, rect, nullptr, &localMatrix)); GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); pipelineBuilder.setUserStencil(&userStencilSettings); - renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + renderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } void GrSoftwarePathRenderer::DrawAroundInvPath(GrRenderTargetContext* renderTargetContext, diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 3b0fd692f5..5c52fef7d3 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -722,12 +722,12 @@ static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage, viewMatrix); } -class AAConvexPathOp final : public GrMeshDrawOp { +class AAConvexPathOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkPath& path) { - return std::unique_ptr<GrMeshDrawOp>(new AAConvexPathOp(color, viewMatrix, path)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkPath& path) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new AAConvexPathOp(color, viewMatrix, path)); } const char* name() const override { return "AAConvexPathOp"; } @@ -817,7 +817,7 @@ private: vertexBuffer, indexBuffer, firstVertex, firstIndex, tess.numPts(), tess.numIndices()); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } } @@ -905,7 +905,7 @@ private: const Draw& draw = draws[j]; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, draw.fVertexCnt, draw.fIndexCnt); - target->draw(quadProcessor.get(), mesh); + target->draw(quadProcessor.get(), this->pipeline(), mesh); firstVertex += draw.fVertexCnt; firstIndex += draw.fIndexCnt; } @@ -961,7 +961,7 @@ private: SkSTArray<1, PathData, true> fPaths; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { @@ -973,13 +973,13 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { SkPath path; args.fShape->asPath(&path); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = AAConvexPathOp::Make(args.fPaint.getColor(), *args.fViewMatrix, path); GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); return true; diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp index b48ec0e7fe..15fb645abc 100644 --- a/src/gpu/ops/GrAAFillRectOp.cpp +++ b/src/gpu/ops/GrAAFillRectOp.cpp @@ -153,7 +153,7 @@ static void generate_aa_fill_rect_geometry(intptr_t verts, } } -class AAFillRectOp final: public GrMeshDrawOp { +class AAFillRectOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -257,7 +257,7 @@ private: localMatrix); info = this->next(info); } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -338,41 +338,41 @@ private: SkSTArray<4 * sizeof(RectWithLocalMatrixInfo), uint8_t, true> fRectData; int fRectCnt; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; namespace GrAAFillRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& devRect) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& devRect) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new AAFillRectOp(color, viewMatrix, rect, devRect, nullptr)); } -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect, + const SkRect& devRect) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new AAFillRectOp(color, viewMatrix, rect, devRect, &localMatrix)); } -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect) { +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect) { SkRect devRect; viewMatrix.mapRect(&devRect, rect); return Make(color, viewMatrix, localMatrix, rect, devRect); } -std::unique_ptr<GrMeshDrawOp> MakeWithLocalRect(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& localRect) { +std::unique_ptr<GrLegacyMeshDrawOp> MakeWithLocalRect(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& localRect) { SkRect devRect; viewMatrix.mapRect(&devRect, rect); SkMatrix localMatrix; diff --git a/src/gpu/ops/GrAAFillRectOp.h b/src/gpu/ops/GrAAFillRectOp.h index c047eed1c9..7d977164fc 100644 --- a/src/gpu/ops/GrAAFillRectOp.h +++ b/src/gpu/ops/GrAAFillRectOp.h @@ -11,31 +11,31 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkMatrix; struct SkRect; namespace GrAAFillRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& devRect); - -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect); - -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect); - -std::unique_ptr<GrMeshDrawOp> MakeWithLocalRect(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& localRect); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& devRect); + +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect); + +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect, + const SkRect& devRect); + +std::unique_ptr<GrLegacyMeshDrawOp> MakeWithLocalRect(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& localRect); }; #endif diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index 9e1ac83c02..c789aa8347 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -668,22 +668,22 @@ bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver return true; } -class AAHairlineOp final : public GrMeshDrawOp { +class AAHairlineOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkPath& path, - const GrStyle& style, - const SkIRect& devClipBounds) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkPath& path, + const GrStyle& style, + const SkIRect& devClipBounds) { SkScalar hairlineCoverage; uint8_t newCoverage = 0xff; if (GrPathRenderer::IsStrokeHairlineOrEquivalent(style, viewMatrix, &hairlineCoverage)) { newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); } - return std::unique_ptr<GrMeshDrawOp>( + return std::unique_ptr<GrLegacyMeshDrawOp>( new AAHairlineOp(color, newCoverage, viewMatrix, path, devClipBounds)); } @@ -783,7 +783,7 @@ private: SkSTArray<1, PathData, true> fPaths; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; void AAHairlineOp::onPrepareDraws(Target* target) const { @@ -864,7 +864,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) const { mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIndexBuffer.get(), firstVertex, kLineSegNumVertices, kIdxsPerLineSeg, lineCount, kLineSegsNumInIdxBuffer); - target->draw(lineGP.get(), mesh); + target->draw(lineGP.get(), this->pipeline(), mesh); } if (quadCount || conicCount) { @@ -921,7 +921,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) const { mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer.get(), firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount, kQuadsNumInIdxBuffer); - target->draw(quadGP.get(), mesh); + target->draw(quadGP.get(), this->pipeline(), mesh); firstVertex += quadCount * kQuadNumVertices; } @@ -930,7 +930,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) const { mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer.get(), firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount, kQuadsNumInIdxBuffer); - target->draw(conicGP.get(), mesh); + target->draw(conicGP.get(), this->pipeline(), mesh); } } } @@ -946,11 +946,11 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { &devClipBounds); SkPath path; args.fShape->asPath(&path); - std::unique_ptr<GrMeshDrawOp> op = AAHairlineOp::Make( + std::unique_ptr<GrLegacyMeshDrawOp> op = AAHairlineOp::Make( args.fPaint.getColor(), *args.fViewMatrix, path, args.fShape->style(), devClipBounds); GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); return true; } diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index b1f1f98f03..8768c1e362 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -117,17 +117,17 @@ static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage, viewMatrix); } -class AAFlatteningConvexPathOp final : public GrMeshDrawOp { +class AAFlatteningConvexPathOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkPath& path, - SkScalar strokeWidth, - SkStrokeRec::Style style, - SkPaint::Join join, - SkScalar miterLimit) { - return std::unique_ptr<GrMeshDrawOp>(new AAFlatteningConvexPathOp( + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkPath& path, + SkScalar strokeWidth, + SkStrokeRec::Style style, + SkPaint::Join join, + SkScalar miterLimit) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new AAFlatteningConvexPathOp( color, viewMatrix, path, strokeWidth, style, join, miterLimit)); } @@ -184,7 +184,7 @@ private: fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage(); } - void draw(GrMeshDrawOp::Target* target, const GrGeometryProcessor* gp, int vertexCount, + void draw(GrLegacyMeshDrawOp::Target* target, const GrGeometryProcessor* gp, int vertexCount, size_t vertexStride, void* vertices, int indexCount, uint16_t* indices) const { if (vertexCount == 0 || indexCount == 0) { return; @@ -210,7 +210,7 @@ private: memcpy(idxs, indices, indexCount * sizeof(uint16_t)); mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, vertexCount, indexCount); - target->draw(gp, mesh); + target->draw(gp, this->pipeline(), mesh); } void onPrepareDraws(Target* target) const override { @@ -318,7 +318,7 @@ private: bool fCanTweakAlphaForCoverage; SkSTArray<1, PathData, true> fPaths; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { @@ -336,14 +336,14 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { SkPaint::Join join = fill ? SkPaint::Join::kMiter_Join : stroke.getJoin(); SkScalar miterLimit = stroke.getMiter(); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = AAFlatteningConvexPathOp::Make(args.fPaint.getColor(), *args.fViewMatrix, path, strokeWidth, stroke.getStyle(), join, miterLimit); GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); return true; } diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp index ce0cef61bf..8b47f5e30f 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrAAStrokeRectOp.cpp @@ -110,7 +110,7 @@ static sk_sp<GrGeometryProcessor> create_stroke_rect_gp(bool tweakAlphaForCovera viewMatrix); } -class AAStrokeRectOp final : public GrMeshDrawOp { +class AAStrokeRectOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -125,8 +125,8 @@ public: fMiterStroke = true; } - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkRect& rect, const SkStrokeRec& stroke) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& rect, const SkStrokeRec& stroke) { bool isMiter; if (!allowed_stroke(stroke, &isMiter)) { return nullptr; @@ -148,7 +148,7 @@ public: op->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kNo); } op->fViewMatrix = viewMatrix; - return std::unique_ptr<GrMeshDrawOp>(op); + return std::unique_ptr<GrLegacyMeshDrawOp>(op); } const char* name() const override { return "AAStrokeRect"; } @@ -227,7 +227,7 @@ private: SkMatrix fViewMatrix; bool fMiterStroke; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; void AAStrokeRectOp::applyPipelineOptimizations(const PipelineOptimizations& optimizations) { @@ -286,7 +286,7 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) const { info.fDegenerate, canTweakAlphaForCoverage); } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } const GrBuffer* AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider, @@ -571,18 +571,18 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(void* vertices, namespace GrAAStrokeRectOp { -std::unique_ptr<GrMeshDrawOp> MakeFillBetweenRects(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& devOutside, - const SkRect& devInside) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> MakeFillBetweenRects(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& devOutside, + const SkRect& devInside) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new AAStrokeRectOp(color, viewMatrix, devOutside, devInside)); } -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke) { +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke) { return AAStrokeRectOp::Make(color, viewMatrix, rect, stroke); } } diff --git a/src/gpu/ops/GrAAStrokeRectOp.h b/src/gpu/ops/GrAAStrokeRectOp.h index 4dfbe642d0..074f8e00e9 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.h +++ b/src/gpu/ops/GrAAStrokeRectOp.h @@ -11,22 +11,22 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkMatrix; struct SkRect; class SkStrokeRec; namespace GrAAStrokeRectOp { -std::unique_ptr<GrMeshDrawOp> MakeFillBetweenRects(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& devOutside, - const SkRect& devInside); +std::unique_ptr<GrLegacyMeshDrawOp> MakeFillBetweenRects(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& devOutside, + const SkRect& devInside); -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke); } #endif diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp index 85da29c4e1..6a9daf305a 100644 --- a/src/gpu/ops/GrAnalyticRectOp.cpp +++ b/src/gpu/ops/GrAnalyticRectOp.cpp @@ -230,7 +230,7 @@ sk_sp<GrGeometryProcessor> RectGeometryProcessor::TestCreate(GrProcessorTestData /////////////////////////////////////////////////////////////////////////////// -class AnalyticRectOp final : public GrMeshDrawOp { +class AnalyticRectOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -344,7 +344,7 @@ private: verts += kVerticesPerQuad; } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -375,15 +375,15 @@ private: SkMatrix fViewMatrixIfUsingLocalCoords; SkSTArray<1, Geometry, true> fGeoData; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; -std::unique_ptr<GrMeshDrawOp> GrAnalyticRectOp::Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& bounds) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> GrAnalyticRectOp::Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& croppedRect, + const SkRect& bounds) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds)); } @@ -395,7 +395,7 @@ DRAW_OP_TEST_DEFINE(AnalyticRectOp) { SkRect rect = GrTest::TestSquare(random); SkRect croppedRect = GrTest::TestSquare(random); SkRect bounds = GrTest::TestSquare(random); - return std::unique_ptr<GrMeshDrawOp>( + return std::unique_ptr<GrLegacyMeshDrawOp>( new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds)); } diff --git a/src/gpu/ops/GrAnalyticRectOp.h b/src/gpu/ops/GrAnalyticRectOp.h index 4331794ebf..9907de0e63 100644 --- a/src/gpu/ops/GrAnalyticRectOp.h +++ b/src/gpu/ops/GrAnalyticRectOp.h @@ -11,7 +11,7 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkMatrix; struct SkRect; @@ -27,11 +27,11 @@ struct SkRect; */ class GrAnalyticRectOp { public: - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& bounds); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& croppedRect, + const SkRect& bounds); }; #endif // GrAnalyticRectOp_DEFINED diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index bf2745bda8..64710e7d8d 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -145,14 +145,14 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) const { this->flush(target, &flushInfo); } -void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const { +void GrAtlasTextOp::flush(GrLegacyMeshDrawOp::Target* target, FlushInfo* flushInfo) const { GrMesh mesh; int maxGlyphsPerDraw = static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6); mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer.get(), flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset, kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush, maxGlyphsPerDraw); - target->draw(flushInfo->fGeometryProcessor.get(), mesh); + target->draw(flushInfo->fGeometryProcessor.get(), this->pipeline(), mesh); flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; flushInfo->fGlyphsToFlush = 0; } diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 452cfbd5a0..8b65fb9aff 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -13,7 +13,7 @@ #include "text/GrAtlasTextContext.h" #include "text/GrDistanceFieldAdjustTable.h" -class GrAtlasTextOp final : public GrMeshDrawOp { +class GrAtlasTextOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -138,7 +138,7 @@ private: return kLCDCoverageMask_MaskType == fMaskType || kLCDDistanceField_MaskType == fMaskType; } - inline void flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const; + inline void flush(GrLegacyMeshDrawOp::Target* target, FlushInfo* flushInfo) const; GrColor color() const { return fColor; } const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } @@ -180,7 +180,7 @@ private: friend class GrBlobRegenHelper; // Needs to trigger flushes - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; /* @@ -189,7 +189,7 @@ private: */ class GrBlobRegenHelper { public: - GrBlobRegenHelper(const GrAtlasTextOp* op, GrMeshDrawOp::Target* target, + GrBlobRegenHelper(const GrAtlasTextOp* op, GrLegacyMeshDrawOp::Target* target, GrAtlasTextOp::FlushInfo* flushInfo) : fOp(op), fTarget(target), fFlushInfo(flushInfo) {} @@ -199,7 +199,7 @@ public: private: const GrAtlasTextOp* fOp; - GrMeshDrawOp::Target* fTarget; + GrLegacyMeshDrawOp::Target* fTarget; GrAtlasTextOp::FlushInfo* fFlushInfo; }; diff --git a/src/gpu/ops/GrDashLinePathRenderer.cpp b/src/gpu/ops/GrDashLinePathRenderer.cpp index 9f170ff69e..eda89069dd 100644 --- a/src/gpu/ops/GrDashLinePathRenderer.cpp +++ b/src/gpu/ops/GrDashLinePathRenderer.cpp @@ -46,7 +46,7 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { } SkPoint pts[2]; SkAssertResult(args.fShape->asLine(pts, nullptr)); - std::unique_ptr<GrMeshDrawOp> op = GrDashOp::MakeDashLineOp( + std::unique_ptr<GrLegacyMeshDrawOp> op = GrDashOp::MakeDashLineOp( args.fPaint.getColor(), *args.fViewMatrix, pts, aaMode, args.fShape->style()); if (!op) { return false; @@ -55,6 +55,6 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); return true; } diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 3e8c07e8cc..01ae34b98c 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -237,7 +237,7 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor, const SkMatrix& localMatrix, bool usesLocalCoords); -class DashOp final : public GrMeshDrawOp { +class DashOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID struct LineData { @@ -251,9 +251,11 @@ public: SkScalar fPerpendicularScale; }; - static std::unique_ptr<GrMeshDrawOp> Make(const LineData& geometry, GrColor color, - SkPaint::Cap cap, AAMode aaMode, bool fullDash) { - return std::unique_ptr<GrMeshDrawOp>(new DashOp(geometry, color, cap, aaMode, fullDash)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(const LineData& geometry, GrColor color, + SkPaint::Cap cap, AAMode aaMode, + bool fullDash) { + return std::unique_ptr<GrLegacyMeshDrawOp>( + new DashOp(geometry, color, cap, aaMode, fullDash)); } const char* name() const override { return "DashOp"; } @@ -625,7 +627,7 @@ private: rectIndex++; } SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount); - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -679,14 +681,14 @@ private: bool fFullDash; SkSTArray<1, LineData, true> fLines; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; -std::unique_ptr<GrMeshDrawOp> GrDashOp::MakeDashLineOp(GrColor color, - const SkMatrix& viewMatrix, - const SkPoint pts[2], - AAMode aaMode, - const GrStyle& style) { +std::unique_ptr<GrLegacyMeshDrawOp> GrDashOp::MakeDashLineOp(GrColor color, + const SkMatrix& viewMatrix, + const SkPoint pts[2], + AAMode aaMode, + const GrStyle& style) { SkASSERT(GrDashOp::CanDrawDashLine(pts, style, viewMatrix)); const SkScalar* intervals = style.dashIntervals(); SkScalar phase = style.dashPhase(); diff --git a/src/gpu/ops/GrDashOp.h b/src/gpu/ops/GrDashOp.h index 6ffd326609..d3e0b6f9b2 100644 --- a/src/gpu/ops/GrDashOp.h +++ b/src/gpu/ops/GrDashOp.h @@ -12,7 +12,7 @@ #include "GrTypesPriv.h" #include "SkPathEffect.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class GrStyle; namespace GrDashOp { @@ -23,8 +23,9 @@ enum class AAMode { }; static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1; -std::unique_ptr<GrMeshDrawOp> MakeDashLineOp(GrColor, const SkMatrix& viewMatrix, - const SkPoint pts[2], AAMode, const GrStyle& style); +std::unique_ptr<GrLegacyMeshDrawOp> MakeDashLineOp(GrColor, const SkMatrix& viewMatrix, + const SkPoint pts[2], AAMode, + const GrStyle& style); bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix); } diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index cf4cdbe937..73c1f10c4d 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -94,15 +94,16 @@ static inline void add_quad(SkPoint** vert, const SkPoint* base, const SkPoint p } } -class DefaultPathOp final : public GrMeshDrawOp { +class DefaultPathOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkPath& path, SkScalar tolerance, - uint8_t coverage, const SkMatrix& viewMatrix, - bool isHairline, const SkRect& devBounds) { - return std::unique_ptr<GrMeshDrawOp>(new DefaultPathOp(color, path, tolerance, coverage, - viewMatrix, isHairline, devBounds)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkPath& path, + SkScalar tolerance, uint8_t coverage, + const SkMatrix& viewMatrix, bool isHairline, + const SkRect& devBounds) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new DefaultPathOp( + color, path, tolerance, coverage, viewMatrix, isHairline, devBounds)); } const char* name() const override { return "DefaultPathOp"; } @@ -256,7 +257,7 @@ private: } else { mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset); } - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); // put back reserves target->putBackIndices((size_t)(maxIndices - indexOffset)); @@ -401,7 +402,7 @@ private: bool fIsHairline; SkSTArray<1, PathData, true> fPaths; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetContext, @@ -546,16 +547,16 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget } const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : viewMatrix; - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( paint.getColor(), viewM, bounds, nullptr, &localMatrix)); SkASSERT(GrDrawFace::kBoth == drawFace[p]); GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); pipelineBuilder.setDrawFace(drawFace[p]); pipelineBuilder.setUserStencil(passes[p]); - renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + renderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } else { - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = DefaultPathOp::Make(paint.getColor(), path, srcSpaceTol, newCoverage, viewMatrix, isHairline, devBounds); bool stencilPass = stencilOnly || passCount > 1; @@ -566,7 +567,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget GrPipelineBuilder pipelineBuilder(std::move(passPaint), aaType); pipelineBuilder.setDrawFace(drawFace[p]); pipelineBuilder.setUserStencil(passes[p]); - renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + renderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } } return true; diff --git a/src/gpu/ops/GrDrawAtlasOp.cpp b/src/gpu/ops/GrDrawAtlasOp.cpp index 36131e12c3..4b3d0d3e48 100644 --- a/src/gpu/ops/GrDrawAtlasOp.cpp +++ b/src/gpu/ops/GrDrawAtlasOp.cpp @@ -67,7 +67,7 @@ void GrDrawAtlasOp::onPrepareDraws(Target* target) const { memcpy(vertPtr, args.fVerts.begin(), allocSize); vertPtr += allocSize; } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } GrDrawAtlasOp::GrDrawAtlasOp(GrColor color, const SkMatrix& viewMatrix, int spriteCount, diff --git a/src/gpu/ops/GrDrawAtlasOp.h b/src/gpu/ops/GrDrawAtlasOp.h index 7d60974350..79a60988f0 100644 --- a/src/gpu/ops/GrDrawAtlasOp.h +++ b/src/gpu/ops/GrDrawAtlasOp.h @@ -12,14 +12,14 @@ #include "GrDefaultGeoProcFactory.h" #include "GrMeshDrawOp.h" -class GrDrawAtlasOp final : public GrMeshDrawOp { +class GrDrawAtlasOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - int spriteCount, const SkRSXform* xforms, - const SkRect* rects, const SkColor* colors) { - return std::unique_ptr<GrMeshDrawOp>( + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + int spriteCount, const SkRSXform* xforms, + const SkRect* rects, const SkColor* colors) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new GrDrawAtlasOp(color, viewMatrix, spriteCount, xforms, rects, colors)); } @@ -72,7 +72,7 @@ private: int fQuadCount; bool fHasColors; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; #endif diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index 1af49d2c12..71835dba9e 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -10,7 +10,7 @@ #include "GrOpFlushState.h" #include "SkGr.h" -std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make( +std::unique_ptr<GrLegacyMeshDrawOp> GrDrawVerticesOp::Make( GrColor color, GrPrimitiveType primitiveType, const SkMatrix& viewMatrix, const SkPoint* positions, int vertexCount, const uint16_t* indices, int indexCount, const uint32_t* colors, const SkPoint* localCoords, const SkRect& bounds, @@ -27,17 +27,18 @@ std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make( if (!vertices) { return nullptr; } - return std::unique_ptr<GrMeshDrawOp>(new GrDrawVerticesOp(std::move(vertices), primitiveType, - color, colorArrayType, viewMatrix)); + return std::unique_ptr<GrLegacyMeshDrawOp>(new GrDrawVerticesOp( + std::move(vertices), primitiveType, color, colorArrayType, viewMatrix)); } -std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make(GrColor color, sk_sp<SkVertices> vertices, - const SkMatrix& viewMatrix) { +std::unique_ptr<GrLegacyMeshDrawOp> GrDrawVerticesOp::Make(GrColor color, + sk_sp<SkVertices> vertices, + const SkMatrix& viewMatrix) { SkASSERT(vertices); GrPrimitiveType primType = SkVertexModeToGrPrimitiveType(vertices->mode()); - return std::unique_ptr<GrMeshDrawOp>(new GrDrawVerticesOp( - std::move(vertices), primType, color, GrRenderTargetContext::ColorArrayType::kSkColor, - viewMatrix)); + return std::unique_ptr<GrLegacyMeshDrawOp>( + new GrDrawVerticesOp(std::move(vertices), primType, color, + GrRenderTargetContext::ColorArrayType::kSkColor, viewMatrix)); } GrDrawVerticesOp::GrDrawVerticesOp(sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType, @@ -242,7 +243,7 @@ void GrDrawVerticesOp::onPrepareDraws(Target* target) const { } else { mesh.init(this->primitiveType(), vertexBuffer, firstVertex, fVertexCount); } - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h index 2c4d1c905b..4bd14afad3 100644 --- a/src/gpu/ops/GrDrawVerticesOp.h +++ b/src/gpu/ops/GrDrawVerticesOp.h @@ -21,7 +21,7 @@ class GrOpFlushState; class SkVertices; struct GrInitInvariantOutput; -class GrDrawVerticesOp final : public GrMeshDrawOp { +class GrDrawVerticesOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -38,12 +38,11 @@ public: * as local coords. 'colorArrayType' specifies whether the colors are premul GrColors or * unpremul SkColors. */ - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, GrPrimitiveType primitiveType, - const SkMatrix& viewMatrix, const SkPoint* positions, - int vertexCount, const uint16_t* indices, - int indexCount, const uint32_t* colors, - const SkPoint* localCoords, const SkRect& bounds, - GrRenderTargetContext::ColorArrayType colorArrayType); + static std::unique_ptr<GrLegacyMeshDrawOp> Make( + GrColor color, GrPrimitiveType primitiveType, const SkMatrix& viewMatrix, + const SkPoint* positions, int vertexCount, const uint16_t* indices, int indexCount, + const uint32_t* colors, const SkPoint* localCoords, const SkRect& bounds, + GrRenderTargetContext::ColorArrayType colorArrayType); /** * Draw a SkVertices. The GrColor param is used if the vertices lack per-vertex color or 'flags' @@ -51,8 +50,8 @@ public: * specified by SkCanvas::VerticesFlags. If the vertices lack local coords or 'flags' indicates * that they should be ignored then the vertex positions are used as local coords. */ - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, sk_sp<SkVertices>, - const SkMatrix& viewMatrix); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, sk_sp<SkVertices>, + const SkMatrix& viewMatrix); const char* name() const override { return "DrawVerticesOp"; } @@ -139,7 +138,7 @@ private: GrRenderTargetContext::ColorArrayType fColorArrayType; SkSTArray<1, Mesh, true> fMeshes; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; #endif diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp index 6dce60e987..4b8f5e3c73 100644 --- a/src/gpu/ops/GrLatticeOp.cpp +++ b/src/gpu/ops/GrLatticeOp.cpp @@ -21,7 +21,7 @@ static sk_sp<GrGeometryProcessor> create_gp() { LocalCoords::kHasExplicit_Type, SkMatrix::I()); } -class NonAALatticeOp final : public GrMeshDrawOp { +class NonAALatticeOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -133,7 +133,7 @@ private: positions, vertexStride, kVertsPerRect * patch.fIter->numRectsToDraw()); } } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -162,14 +162,15 @@ private: int fImageHeight; SkSTArray<1, Patch, true> fPatches; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; namespace GrLatticeOp { -std::unique_ptr<GrMeshDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, - int imageHeight, std::unique_ptr<SkLatticeIter> iter, - const SkRect& dst) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, + int imageWidth, int imageHeight, + std::unique_ptr<SkLatticeIter> iter, + const SkRect& dst) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new NonAALatticeOp(color, viewMatrix, imageWidth, imageHeight, std::move(iter), dst)); } }; diff --git a/src/gpu/ops/GrLatticeOp.h b/src/gpu/ops/GrLatticeOp.h index ef0f58a66b..65aa622894 100644 --- a/src/gpu/ops/GrLatticeOp.h +++ b/src/gpu/ops/GrLatticeOp.h @@ -11,15 +11,16 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkLatticeIter; class SkMatrix; struct SkRect; namespace GrLatticeOp { -std::unique_ptr<GrMeshDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, - int imageHeight, std::unique_ptr<SkLatticeIter> iter, - const SkRect& dst); +std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAA(GrColor color, const SkMatrix& viewMatrix, + int imageWidth, int imageHeight, + std::unique_ptr<SkLatticeIter> iter, + const SkRect& dst); }; #endif diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index 047fca6de2..227c540656 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -215,11 +215,12 @@ private: typedef GrGeometryProcessor INHERITED; }; -class MSAAPathOp final : public GrMeshDrawOp { +class MSAAPathOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkPath& path, - const SkMatrix& viewMatrix, const SkRect& devBounds) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkPath& path, + const SkMatrix& viewMatrix, + const SkRect& devBounds) { int contourCount; int maxLineVertices; int maxQuadVertices; @@ -231,7 +232,7 @@ public: return nullptr; } - return std::unique_ptr<GrMeshDrawOp>(new MSAAPathOp( + return std::unique_ptr<GrLegacyMeshDrawOp>(new MSAAPathOp( color, path, viewMatrix, devBounds, maxLineVertices, maxQuadVertices, isIndexed)); } @@ -420,7 +421,7 @@ private: lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex, lineVertexOffset); } - target->draw(lineGP.get(), lineMeshes); + target->draw(lineGP.get(), this->pipeline(), lineMeshes); } if (quadVertexOffset) { @@ -448,7 +449,7 @@ private: quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQuadVertex, quadVertexOffset); } - target->draw(quadGP.get(), quadMeshes); + target->draw(quadGP.get(), this->pipeline(), quadMeshes); } } @@ -568,7 +569,7 @@ private: int fMaxQuadVertices; bool fIsIndexed; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetContext, @@ -625,7 +626,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon SkASSERT(passes[0]); { // First pass - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = MSAAPathOp::Make(paint.getColor(), path, viewMatrix, devBounds); if (!op) { return false; @@ -639,7 +640,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon } GrPipelineBuilder pipelineBuilder(std::move(firstPassPaint), aaType); pipelineBuilder.setUserStencil(passes[0]); - renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + renderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } if (passes[1]) { @@ -662,13 +663,13 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon } const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() : viewMatrix; - std::unique_ptr<GrMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRectOpFactory::MakeNonAAFill( paint.getColor(), viewM, bounds, nullptr, &localMatrix)); GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); pipelineBuilder.setUserStencil(passes[1]); - renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + renderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } return true; } diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp index c3a191d07e..378524541b 100644 --- a/src/gpu/ops/GrMeshDrawOp.cpp +++ b/src/gpu/ops/GrMeshDrawOp.cpp @@ -43,9 +43,10 @@ void* GrMeshDrawOp::InstancedHelper::init(Target* target, GrPrimitiveType primTy return vertices; } -void GrMeshDrawOp::InstancedHelper::recordDraw(Target* target, const GrGeometryProcessor* gp) { +void GrMeshDrawOp::InstancedHelper::recordDraw(Target* target, const GrGeometryProcessor* gp, + const GrPipeline* pipeline) { SkASSERT(fMesh.instanceCount()); - target->draw(gp, fMesh); + target->draw(gp, pipeline, fMesh); } void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int quadsToDraw) { @@ -62,7 +63,6 @@ void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int qu void GrMeshDrawOp::onExecute(GrOpFlushState* state) { SkASSERT(!state->drawOpArgs().fAppliedClip); SkASSERT(!state->drawOpArgs().fDstTexture.texture()); - SkASSERT(state->drawOpArgs().fRenderTarget == this->pipeline()->getRenderTarget()); int currUploadIdx = 0; int currMeshIdx = 0; @@ -73,10 +73,11 @@ void GrMeshDrawOp::onExecute(GrOpFlushState* state) { while (currUploadIdx < fInlineUploads.count() && fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) { state->commandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload, - this->pipeline()->getRenderTarget()); + state->drawOpArgs().fRenderTarget); } const QueuedDraw& draw = fQueuedDraws[currDrawIdx]; - state->commandBuffer()->draw(*this->pipeline(), *draw.fGeometryProcessor.get(), + SkASSERT(draw.fPipeline->getRenderTarget() == state->drawOpArgs().fRenderTarget); + state->commandBuffer()->draw(*draw.fPipeline, *draw.fGeometryProcessor.get(), fMeshes.begin() + currMeshIdx, draw.fMeshCnt, this->bounds()); currMeshIdx += draw.fMeshCnt; state->flushToken(); @@ -89,23 +90,25 @@ void GrMeshDrawOp::onExecute(GrOpFlushState* state) { ////////////////////////////////////////////////////////////////////////////// -void GrMeshDrawOp::Target::draw(const GrGeometryProcessor* gp, const GrMesh& mesh) { +void GrMeshDrawOp::Target::draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline, + const GrMesh& mesh) { GrMeshDrawOp* op = this->meshDrawOp(); op->fMeshes.push_back(mesh); if (!op->fQueuedDraws.empty()) { - // If the last draw shares a geometry processor and there are no intervening uploads, - // add this mesh to it. - GrMeshDrawOp::QueuedDraw& lastDraw = op->fQueuedDraws.back(); - if (lastDraw.fGeometryProcessor == gp && + // If the last draw shares a geometry processor and pipeline and there are no intervening + // uploads, add this mesh to it. + GrLegacyMeshDrawOp::QueuedDraw& lastDraw = op->fQueuedDraws.back(); + if (lastDraw.fGeometryProcessor == gp && lastDraw.fPipeline == pipeline && (op->fInlineUploads.empty() || op->fInlineUploads.back().fUploadBeforeToken != this->nextDrawToken())) { ++lastDraw.fMeshCnt; return; } } - GrMeshDrawOp::QueuedDraw& draw = op->fQueuedDraws.push_back(); + GrLegacyMeshDrawOp::QueuedDraw& draw = op->fQueuedDraws.push_back(); GrDrawOpUploadToken token = this->state()->issueDrawToken(); draw.fGeometryProcessor.reset(gp); + draw.fPipeline = pipeline; draw.fMeshCnt = 1; if (op->fQueuedDraws.count() == 1) { op->fBaseDrawToken = token; diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h index a8da29a39f..8daa62b374 100644 --- a/src/gpu/ops/GrMeshDrawOp.h +++ b/src/gpu/ops/GrMeshDrawOp.h @@ -25,6 +25,77 @@ class GrMeshDrawOp : public GrDrawOp { public: class Target; +protected: + GrMeshDrawOp(uint32_t classID); + + /** Helper for rendering instances using an instanced index buffer. This class creates the space + for the vertices and flushes the draws to the GrMeshDrawOp::Target. */ + class InstancedHelper { + public: + InstancedHelper() {} + /** Returns the allocated storage for the vertices. The caller should populate the vertices + before calling recordDraws(). */ + void* init(Target*, GrPrimitiveType, size_t vertexStride, const GrBuffer*, + int verticesPerInstance, int indicesPerInstance, int instancesToDraw); + + /** Call after init() to issue draws to the GrMeshDrawOp::Target.*/ + void recordDraw(Target*, const GrGeometryProcessor*, const GrPipeline*); + + private: + GrMesh fMesh; + }; + + static const int kVerticesPerQuad = 4; + static const int kIndicesPerQuad = 6; + + /** A specialization of InstanceHelper for quad rendering. */ + class QuadHelper : private InstancedHelper { + public: + QuadHelper() : INHERITED() {} + /** Finds the cached quad index buffer and reserves vertex space. Returns nullptr on failure + and on success a pointer to the vertex data that the caller should populate before + calling recordDraws(). */ + void* init(Target*, size_t vertexStride, int quadsToDraw); + + using InstancedHelper::recordDraw; + + private: + typedef InstancedHelper INHERITED; + }; + +private: + void onPrepare(GrOpFlushState* state) final; + void onExecute(GrOpFlushState* state) final; + + virtual void onPrepareDraws(Target*) const = 0; + + // A set of contiguous draws that share a draw token and primitive processor. The draws all use + // the op's pipeline. The meshes for the draw are stored in the fMeshes array and each + // Queued draw uses fMeshCnt meshes from the fMeshes array. The reason for coallescing meshes + // that share a primitive processor into a QueuedDraw is that it allows the Gpu object to setup + // the shared state once and then issue draws for each mesh. + struct QueuedDraw { + int fMeshCnt = 0; + GrPendingProgramElement<const GrGeometryProcessor> fGeometryProcessor; + const GrPipeline* fPipeline; + }; + + // All draws in all the GrMeshDrawOps have implicit tokens based on the order they are enqueued + // globally across all ops. This is the offset of the first entry in fQueuedDraws. + // fQueuedDraws[i]'s token is fBaseDrawToken + i. + GrDrawOpUploadToken fBaseDrawToken; + SkSTArray<4, GrMesh> fMeshes; + SkSTArray<4, QueuedDraw, true> fQueuedDraws; + + typedef GrDrawOp INHERITED; +}; + +/** + * Many of our ops derive from this class which initializes a GrPipeline just before being recorded. + * We are migrating away from use of this class. + */ +class GrLegacyMeshDrawOp : public GrMeshDrawOp { +public: /** * Performs analysis of the fragment processors in GrProcessorSet and GrAppliedClip using the * initial color and coverage from this op's geometry processor. @@ -49,19 +120,19 @@ public: * the op is recorded. These methods are unnecessary as this information is in the pipeline. */ FixedFunctionFlags fixedFunctionFlags() const override { - SkFAIL("This should never be called for mesh draw ops."); + SkFAIL("This should never be called for legacy mesh draw ops."); return FixedFunctionFlags::kNone; } bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) override { - SkFAIL("Should never be called for mesh draw ops."); + SkFAIL("Should never be called for legacy mesh draw ops."); return false; } protected: - GrMeshDrawOp(uint32_t classID); + GrLegacyMeshDrawOp(uint32_t classID) : INHERITED(classID) {} /** - * This is a legacy class only used by GrMeshDrawOp and will be removed. It presents some - * aspects of GrProcessorSet::Analysis to GrMeshDrawOp subclasses. + * This is a legacy class only used by GrLegacyMeshDrawOp and will be removed. It presents some + * aspects of GrProcessorSet::Analysis to GrLegacyMeshDrawOp subclasses. */ class PipelineOptimizations { public: @@ -116,41 +187,6 @@ protected: GrColor fOverrideColor; }; - /** Helper for rendering instances using an instanced index index buffer. This class creates the - space for the vertices and flushes the draws to the GrMeshDrawOp::Target. */ - class InstancedHelper { - public: - InstancedHelper() {} - /** Returns the allocated storage for the vertices. The caller should populate the vertices - before calling recordDraws(). */ - void* init(Target*, GrPrimitiveType, size_t vertexStride, const GrBuffer*, - int verticesPerInstance, int indicesPerInstance, int instancesToDraw); - - /** Call after init() to issue draws to the GrMeshDrawOp::Target.*/ - void recordDraw(Target*, const GrGeometryProcessor*); - - private: - GrMesh fMesh; - }; - - static const int kVerticesPerQuad = 4; - static const int kIndicesPerQuad = 6; - - /** A specialization of InstanceHelper for quad rendering. */ - class QuadHelper : private InstancedHelper { - public: - QuadHelper() : INHERITED() {} - /** Finds the cached quad index buffer and reserves vertex space. Returns nullptr on failure - and on success a pointer to the vertex data that the caller should populate before - calling recordDraws(). */ - void* init(Target*, size_t vertexStride, int quadsToDraw); - - using InstancedHelper::recordDraw; - - private: - typedef InstancedHelper INHERITED; - }; - const GrPipeline* pipeline() const { SkASSERT(fPipeline.isInitialized()); return &fPipeline; @@ -170,30 +206,9 @@ private: */ virtual void applyPipelineOptimizations(const PipelineOptimizations&) = 0; - void onPrepare(GrOpFlushState* state) final; - void onExecute(GrOpFlushState* state) final; - - virtual void onPrepareDraws(Target*) const = 0; - - // A set of contiguous draws that share a draw token and primitive processor. The draws all use - // the op's pipeline. The meshes for the draw are stored in the fMeshes array and each - // Queued draw uses fMeshCnt meshes from the fMeshes array. The reason for coallescing meshes - // that share a primitive processor into a QueuedDraw is that it allows the Gpu object to setup - // the shared state once and then issue draws for each mesh. - struct QueuedDraw { - int fMeshCnt = 0; - GrPendingProgramElement<const GrGeometryProcessor> fGeometryProcessor; - }; - - // All draws in all the GrMeshDrawOps have implicit tokens based on the order they are enqueued - // globally across all ops. This is the offset of the first entry in fQueuedDraws. - // fQueuedDraws[i]'s token is fBaseDrawToken + i. - GrDrawOpUploadToken fBaseDrawToken; GrPipeline fPipeline; - SkSTArray<4, GrMesh> fMeshes; - SkSTArray<4, QueuedDraw, true> fQueuedDraws; - typedef GrDrawOp INHERITED; + typedef GrMeshDrawOp INHERITED; }; #endif diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp index c5227945b3..99cb2bd9df 100644 --- a/src/gpu/ops/GrNonAAFillRectOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectOp.cpp @@ -67,7 +67,7 @@ static void tesselate(intptr_t vertices, } } -class NonAAFillRectOp final : public GrMeshDrawOp { +class NonAAFillRectOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -148,7 +148,7 @@ private: tesselate(verts, vertexStride, fRects[i].fColor, &fRects[i].fViewMatrix, fRects[i].fRect, &fRects[i].fLocalQuad); } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -172,17 +172,17 @@ private: SkSTArray<1, RectInfo, true> fRects; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; namespace GrNonAAFillRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new NonAAFillRectOp(color, viewMatrix, rect, localRect, localMatrix)); } }; diff --git a/src/gpu/ops/GrNonAAFillRectOp.h b/src/gpu/ops/GrNonAAFillRectOp.h index 046a95594b..8972281847 100644 --- a/src/gpu/ops/GrNonAAFillRectOp.h +++ b/src/gpu/ops/GrNonAAFillRectOp.h @@ -11,23 +11,23 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkMatrix; struct SkRect; namespace GrNonAAFillRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix); -std::unique_ptr<GrMeshDrawOp> MakeWithPerspective(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix); +std::unique_ptr<GrLegacyMeshDrawOp> MakeWithPerspective(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix); }; #endif diff --git a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp index a7c445c170..fef515421f 100644 --- a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp @@ -89,7 +89,7 @@ static void tesselate(intptr_t vertices, } // We handle perspective in the local matrix or viewmatrix with special ops. -class NonAAFillRectPerspectiveOp final : public GrMeshDrawOp { +class NonAAFillRectPerspectiveOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -178,7 +178,7 @@ private: tesselate(verts, vertexStride, info.fColor, nullptr, info.fRect, nullptr); } } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -216,17 +216,17 @@ private: SkMatrix fLocalMatrix; SkMatrix fViewMatrix; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; namespace GrNonAAFillRectOp { -std::unique_ptr<GrMeshDrawOp> MakeWithPerspective(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { - return std::unique_ptr<GrMeshDrawOp>( +std::unique_ptr<GrLegacyMeshDrawOp> MakeWithPerspective(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new NonAAFillRectPerspectiveOp(color, viewMatrix, rect, localRect, localMatrix)); } }; diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp index ffabad1dd5..69958c0d41 100644 --- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp @@ -46,7 +46,7 @@ inline static bool allowed_stroke(const SkStrokeRec& stroke) { (stroke.getJoin() == SkPaint::kMiter_Join && stroke.getMiter() > SK_ScalarSqrt2); } -class NonAAStrokeRectOp final : public GrMeshDrawOp { +class NonAAStrokeRectOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -63,9 +63,9 @@ public: return string; } - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkRect& rect, const SkStrokeRec& stroke, - bool snapToPixelCenters) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& rect, const SkStrokeRec& stroke, + bool snapToPixelCenters) { if (!allowed_stroke(stroke)) { return nullptr; } @@ -96,7 +96,7 @@ public: } else { op->setTransformedBounds(bounds, op->fViewMatrix, HasAABloat::kNo, IsZeroArea::kNo); } - return std::unique_ptr<GrMeshDrawOp>(op); + return std::unique_ptr<GrLegacyMeshDrawOp>(op); } private: @@ -158,7 +158,7 @@ private: GrMesh mesh; mesh.init(primType, vertexBuffer, firstVertex, vertexCount); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override { @@ -181,16 +181,16 @@ private: const static int kVertsPerHairlineRect = 5; const static int kVertsPerStrokeRect = 10; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; namespace GrNonAAStrokeRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke, - bool snapToPixelCenters) { +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke, + bool snapToPixelCenters) { return NonAAStrokeRectOp::Make(color, viewMatrix, rect, stroke, snapToPixelCenters); } } diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.h b/src/gpu/ops/GrNonAAStrokeRectOp.h index 5c9c98e8d2..4071cfd2a9 100644 --- a/src/gpu/ops/GrNonAAStrokeRectOp.h +++ b/src/gpu/ops/GrNonAAStrokeRectOp.h @@ -11,18 +11,18 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; struct SkRect; class SkStrokeRec; class SkMatrix; namespace GrNonAAStrokeRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec&, - bool snapToPixelCenters); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec&, + bool snapToPixelCenters); } #endif diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index 5ede5e152a..e00ee0b24d 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -608,7 +608,7 @@ static const uint16_t* circle_type_to_indices(bool stroked) { /////////////////////////////////////////////////////////////////////////////// -class CircleOp final : public GrMeshDrawOp { +class CircleOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -618,9 +618,10 @@ public: SkScalar fSweepAngleRadians; bool fUseCenter; }; - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - SkPoint center, SkScalar radius, const GrStyle& style, - const ArcParams* arcParams = nullptr) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + SkPoint center, SkScalar radius, + const GrStyle& style, + const ArcParams* arcParams = nullptr) { SkASSERT(circle_stays_circle(viewMatrix)); const SkStrokeRec& stroke = style.strokeRec(); if (style.hasPathEffect()) { @@ -1098,7 +1099,7 @@ private: GrMesh mesh; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, fVertCount, fIndexCount); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -1152,16 +1153,17 @@ private: bool fClipPlaneIsect; bool fClipPlaneUnion; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; /////////////////////////////////////////////////////////////////////////////// -class EllipseOp : public GrMeshDrawOp { +class EllipseOp : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkRect& ellipse, const SkStrokeRec& stroke) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& ellipse, + const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); // do any matrix crunching before we reset the draw state for device coords @@ -1334,7 +1336,7 @@ private: verts += kVerticesPerQuad; } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -1371,19 +1373,19 @@ private: SkMatrix fViewMatrixIfUsingLocalCoords; SkSTArray<1, Geometry, true> fGeoData; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; ///////////////////////////////////////////////////////////////////////////////////////////////// -class DIEllipseOp : public GrMeshDrawOp { +class DIEllipseOp : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& ellipse, - const SkStrokeRec& stroke) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& ellipse, + const SkStrokeRec& stroke) { SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); SkScalar xRadius = SkScalarHalf(ellipse.width()); SkScalar yRadius = SkScalarHalf(ellipse.height()); @@ -1536,7 +1538,7 @@ private: verts += kVerticesPerQuad; } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -1579,7 +1581,7 @@ private: bool fUsesLocalCoords; SkSTArray<1, Geometry, true> fGeoData; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; /////////////////////////////////////////////////////////////////////////////// @@ -1712,7 +1714,7 @@ static const uint16_t* rrect_type_to_indices(RRectType type) { // each vertex is also given the normalized x & y distance from the interior rect's edge // the GP takes the min of those depths +1 to get the normalized distance to the outer edge -class CircularRRectOp : public GrMeshDrawOp { +class CircularRRectOp : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -1998,7 +2000,7 @@ private: GrMesh mesh; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, fVertCount, fIndexCount); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -2040,7 +2042,7 @@ private: int fIndexCount; bool fAllFill; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; static const int kNumRRectsInIndexBuffer = 256; @@ -2066,16 +2068,16 @@ static const GrBuffer* ref_rrect_index_buffer(RRectType type, }; } -class EllipticalRRectOp : public GrMeshDrawOp { +class EllipticalRRectOp : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID // If devStrokeWidths values are <= 0 indicates then fill only. Otherwise, strokeOnly indicates // whether the rrect is only stroked or stroked and filled. - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkRect& devRect, float devXRadius, - float devYRadius, SkVector devStrokeWidths, - bool strokeOnly) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRect& devRect, float devXRadius, + float devYRadius, SkVector devStrokeWidths, + bool strokeOnly) { SkASSERT(devXRadius > 0.5); SkASSERT(devYRadius > 0.5); SkASSERT((devStrokeWidths.fX > 0) == (devStrokeWidths.fY > 0)); @@ -2246,7 +2248,7 @@ private: verts++; } } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -2283,14 +2285,14 @@ private: SkMatrix fViewMatrixIfUsingLocalCoords; SkSTArray<1, Geometry, true> fGeoData; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; -static std::unique_ptr<GrMeshDrawOp> make_rrect_op(GrColor color, - bool needsDistance, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkStrokeRec& stroke) { +static std::unique_ptr<GrLegacyMeshDrawOp> make_rrect_op(GrColor color, + bool needsDistance, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(rrect.isSimple()); SkASSERT(!rrect.isOval()); @@ -2348,7 +2350,7 @@ static std::unique_ptr<GrMeshDrawOp> make_rrect_op(GrColor color, // if the corners are circles, use the circle renderer if (isCircular) { - return std::unique_ptr<GrMeshDrawOp>(new CircularRRectOp( + return std::unique_ptr<GrLegacyMeshDrawOp>(new CircularRRectOp( color, needsDistance, viewMatrix, bounds, xRadius, scaledStroke.fX, isStrokeOnly)); // otherwise we use the ellipse renderer } else { @@ -2357,12 +2359,12 @@ static std::unique_ptr<GrMeshDrawOp> make_rrect_op(GrColor color, } } -std::unique_ptr<GrMeshDrawOp> GrOvalOpFactory::MakeRRectOp(GrColor color, - bool needsDistance, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrLegacyMeshDrawOp> GrOvalOpFactory::MakeRRectOp(GrColor color, + bool needsDistance, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { if (rrect.isOval()) { return MakeOvalOp(color, viewMatrix, rrect.getBounds(), stroke, shaderCaps); } @@ -2376,11 +2378,11 @@ std::unique_ptr<GrMeshDrawOp> GrOvalOpFactory::MakeRRectOp(GrColor color, /////////////////////////////////////////////////////////////////////////////// -std::unique_ptr<GrMeshDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& oval, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrLegacyMeshDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& oval, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { // we can draw circles SkScalar width = oval.width(); if (SkScalarNearlyEqual(width, oval.height()) && circle_stays_circle(viewMatrix)) { @@ -2403,11 +2405,9 @@ std::unique_ptr<GrMeshDrawOp> GrOvalOpFactory::MakeOvalOp(GrColor color, /////////////////////////////////////////////////////////////////////////////// -std::unique_ptr<GrMeshDrawOp> GrOvalOpFactory::MakeArcOp(GrColor color, const SkMatrix& viewMatrix, - const SkRect& oval, SkScalar startAngle, - SkScalar sweepAngle, bool useCenter, - const GrStyle& style, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrLegacyMeshDrawOp> GrOvalOpFactory::MakeArcOp( + GrColor color, const SkMatrix& viewMatrix, const SkRect& oval, SkScalar startAngle, + SkScalar sweepAngle, bool useCenter, const GrStyle& style, const GrShaderCaps* shaderCaps) { SkASSERT(!oval.isEmpty()); SkASSERT(sweepAngle); SkScalar width = oval.width(); @@ -2450,8 +2450,8 @@ DRAW_OP_TEST_DEFINE(CircleOp) { arcParamsTmp.fUseCenter = random->nextBool(); arcParams = &arcParamsTmp; } - std::unique_ptr<GrMeshDrawOp> op = CircleOp::Make(color, viewMatrix, center, radius, - GrStyle(stroke, nullptr), arcParams); + std::unique_ptr<GrLegacyMeshDrawOp> op = CircleOp::Make( + color, viewMatrix, center, radius, GrStyle(stroke, nullptr), arcParams); if (op) { return op; } diff --git a/src/gpu/ops/GrOvalOpFactory.h b/src/gpu/ops/GrOvalOpFactory.h index e6a160d3f5..72e0fa28a4 100644 --- a/src/gpu/ops/GrOvalOpFactory.h +++ b/src/gpu/ops/GrOvalOpFactory.h @@ -11,7 +11,7 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class GrShaderCaps; class GrStyle; class SkMatrix; @@ -24,26 +24,26 @@ class SkStrokeRec; */ class GrOvalOpFactory { public: - static std::unique_ptr<GrMeshDrawOp> MakeOvalOp(GrColor, - const SkMatrix& viewMatrix, - const SkRect& oval, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps); - static std::unique_ptr<GrMeshDrawOp> MakeRRectOp(GrColor, - bool needsDistance, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps); + static std::unique_ptr<GrLegacyMeshDrawOp> MakeOvalOp(GrColor, + const SkMatrix& viewMatrix, + const SkRect& oval, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps); + static std::unique_ptr<GrLegacyMeshDrawOp> MakeRRectOp(GrColor, + bool needsDistance, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps); - static std::unique_ptr<GrMeshDrawOp> MakeArcOp(GrColor, - const SkMatrix& viewMatrix, - const SkRect& oval, - SkScalar startAngle, - SkScalar sweepAngle, - bool useCenter, - const GrStyle&, - const GrShaderCaps* shaderCaps); + static std::unique_ptr<GrLegacyMeshDrawOp> MakeArcOp(GrColor, + const SkMatrix& viewMatrix, + const SkRect& oval, + SkScalar startAngle, + SkScalar sweepAngle, + bool useCenter, + const GrStyle&, + const GrShaderCaps* shaderCaps); }; #endif // GrOvalOpFactory_DEFINED diff --git a/src/gpu/ops/GrRectOpFactory.cpp b/src/gpu/ops/GrRectOpFactory.cpp index e6d0c1f0e5..45e2053f8d 100644 --- a/src/gpu/ops/GrRectOpFactory.cpp +++ b/src/gpu/ops/GrRectOpFactory.cpp @@ -13,9 +13,9 @@ namespace GrRectOpFactory { -std::unique_ptr<GrMeshDrawOp> MakeAAFillNestedRects(GrColor color, - const SkMatrix& viewMatrix, - const SkRect rects[2]) { +std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFillNestedRects(GrColor color, + const SkMatrix& viewMatrix, + const SkRect rects[2]) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty()); diff --git a/src/gpu/ops/GrRectOpFactory.h b/src/gpu/ops/GrRectOpFactory.h index 19bce7fd2c..fef88e6d31 100644 --- a/src/gpu/ops/GrRectOpFactory.h +++ b/src/gpu/ops/GrRectOpFactory.h @@ -27,11 +27,11 @@ class SkStrokeRec; */ namespace GrRectOpFactory { -inline std::unique_ptr<GrMeshDrawOp> MakeNonAAFill(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect* localRect, - const SkMatrix* localMatrix) { +inline std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAAFill(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect* localRect, + const SkMatrix* localMatrix) { if (viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective())) { return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect, localRect, localMatrix); @@ -40,11 +40,11 @@ inline std::unique_ptr<GrMeshDrawOp> MakeNonAAFill(GrColor color, } } -inline std::unique_ptr<GrMeshDrawOp> MakeAAFill(const GrPaint& paint, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& devRect) { +inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(const GrPaint& paint, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkRect& croppedRect, + const SkRect& devRect) { if (!paint.usesDistanceVectorField()) { return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect); } else { @@ -52,32 +52,32 @@ inline std::unique_ptr<GrMeshDrawOp> MakeAAFill(const GrPaint& paint, } } -inline std::unique_ptr<GrMeshDrawOp> MakeAAFill(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect) { +inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(GrColor color, + const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, + const SkRect& rect, + const SkRect& devRect) { return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect); } -inline std::unique_ptr<GrMeshDrawOp> MakeNonAAStroke(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& strokeRec, - bool snapToPixelCenters) { +inline std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAAStroke(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& strokeRec, + bool snapToPixelCenters) { return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, snapToPixelCenters); } -inline std::unique_ptr<GrMeshDrawOp> MakeAAStroke(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke) { +inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAStroke(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& rect, + const SkStrokeRec& stroke) { return GrAAStrokeRectOp::Make(color, viewMatrix, rect, stroke); } // First rect is outer; second rect is inner -std::unique_ptr<GrMeshDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, - const SkRect rects[2]); +std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, + const SkRect rects[2]); }; #endif diff --git a/src/gpu/ops/GrRegionOp.cpp b/src/gpu/ops/GrRegionOp.cpp index ba153a62e2..91191f3a3f 100644 --- a/src/gpu/ops/GrRegionOp.cpp +++ b/src/gpu/ops/GrRegionOp.cpp @@ -47,7 +47,7 @@ static void tesselate_region(intptr_t vertices, } } -class RegionOp final : public GrMeshDrawOp { +class RegionOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -118,7 +118,7 @@ private: int numRectsInRegion = fRegions[i].fRegion.computeRegionComplexity(); verts += numRectsInRegion * kVertsPerInstance * vertexStride; } - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -145,13 +145,13 @@ private: SkMatrix fViewMatrix; SkSTArray<1, RegionInfo, true> fRegions; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; namespace GrRegionOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkRegion& region) { - return std::unique_ptr<GrMeshDrawOp>(new RegionOp(color, viewMatrix, region)); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRegion& region) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new RegionOp(color, viewMatrix, region)); } } diff --git a/src/gpu/ops/GrRegionOp.h b/src/gpu/ops/GrRegionOp.h index 5ee6f35651..2170667582 100644 --- a/src/gpu/ops/GrRegionOp.h +++ b/src/gpu/ops/GrRegionOp.h @@ -11,13 +11,13 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkMatrix; class SkRegion; namespace GrRegionOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - const SkRegion& region); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + const SkRegion& region); } #endif diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index 9b2bc824c9..00ec35fba8 100644 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -63,13 +63,13 @@ static const uint16_t* circle_type_to_indices(bool stroked) { /////////////////////////////////////////////////////////////////////////////// -class ShadowCircleOp final : public GrMeshDrawOp { +class ShadowCircleOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, - SkPoint center, SkScalar radius, SkScalar blurRadius, - const GrStyle& style) { + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, + SkPoint center, SkScalar radius, + SkScalar blurRadius, const GrStyle& style) { SkASSERT(viewMatrix.isSimilarity()); const SkStrokeRec& stroke = style.strokeRec(); if (style.hasPathEffect()) { @@ -353,7 +353,7 @@ private: GrMesh mesh; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, fVertCount, fIndexCount); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -388,7 +388,7 @@ private: int fVertCount; int fIndexCount; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -504,7 +504,7 @@ static const uint16_t* rrect_type_to_indices(RRectType type) { // each vertex is also given the normalized x & y distance from the interior rect's edge // the GP takes the min of those depths +1 to get the normalized distance to the outer edge -class ShadowCircularRRectOp final : public GrMeshDrawOp { +class ShadowCircularRRectOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -768,7 +768,7 @@ private: GrMesh mesh; mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, fVertCount, fIndexCount); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -803,17 +803,17 @@ private: int fVertCount; int fIndexCount; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; /////////////////////////////////////////////////////////////////////////////// -std::unique_ptr<GrMeshDrawOp> make_shadow_circle_op(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& oval, - SkScalar blurRadius, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrLegacyMeshDrawOp> make_shadow_circle_op(GrColor color, + const SkMatrix& viewMatrix, + const SkRect& oval, + SkScalar blurRadius, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { // we can only draw circles SkScalar width = oval.width(); SkASSERT(SkScalarNearlyEqual(width, oval.height()) && viewMatrix.isSimilarity()); @@ -822,11 +822,11 @@ std::unique_ptr<GrMeshDrawOp> make_shadow_circle_op(GrColor color, GrStyle(stroke, nullptr)); } -static std::unique_ptr<GrMeshDrawOp> make_shadow_rrect_op(GrColor color, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - SkScalar blurRadius, - const SkStrokeRec& stroke) { +static std::unique_ptr<GrLegacyMeshDrawOp> make_shadow_rrect_op(GrColor color, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + SkScalar blurRadius, + const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(rrect.isSimple()); SkASSERT(!rrect.isOval()); @@ -879,17 +879,17 @@ static std::unique_ptr<GrMeshDrawOp> make_shadow_rrect_op(GrColor color, return nullptr; } - return std::unique_ptr<GrMeshDrawOp>(new ShadowCircularRRectOp( + return std::unique_ptr<GrLegacyMeshDrawOp>(new ShadowCircularRRectOp( color, viewMatrix, bounds, xRadius, blurRadius, scaledStroke.fX, isStrokeOnly)); } namespace GrShadowRRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor color, - const SkMatrix& viewMatrix, - const SkRRect& rrect, - const SkScalar blurRadius, - const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps) { +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, + const SkMatrix& viewMatrix, + const SkRRect& rrect, + const SkScalar blurRadius, + const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps) { if (rrect.isOval()) { return make_shadow_circle_op(color, viewMatrix, rrect.getBounds(), blurRadius, stroke, shaderCaps); @@ -922,7 +922,7 @@ DRAW_OP_TEST_DEFINE(ShadowCircleOp) { SkScalar radius = circle.width() / 2.f; SkStrokeRec stroke = GrTest::TestStrokeRec(random); SkScalar blurRadius = random->nextSScalar1() * 72.f; - std::unique_ptr<GrMeshDrawOp> op = ShadowCircleOp::Make( + std::unique_ptr<GrLegacyMeshDrawOp> op = ShadowCircleOp::Make( color, viewMatrix, center, radius, blurRadius, GrStyle(stroke, nullptr)); if (op) { return op; diff --git a/src/gpu/ops/GrShadowRRectOp.h b/src/gpu/ops/GrShadowRRectOp.h index 081b217873..9b9993e5be 100644 --- a/src/gpu/ops/GrShadowRRectOp.h +++ b/src/gpu/ops/GrShadowRRectOp.h @@ -11,7 +11,7 @@ #include "GrColor.h" #include "SkRefCnt.h" -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class GrShaderCaps; class SkMatrix; class SkRRect; @@ -19,9 +19,9 @@ class SkStrokeRec; namespace GrShadowRRectOp { -std::unique_ptr<GrMeshDrawOp> Make(GrColor, const SkMatrix& viewMatrix, const SkRRect& rrect, - const SkScalar blurRadius, const SkStrokeRec& stroke, - const GrShaderCaps* shaderCaps); +std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor, const SkMatrix& viewMatrix, const SkRRect& rrect, + const SkScalar blurRadius, const SkStrokeRec& stroke, + const GrShaderCaps* shaderCaps); } #endif diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp index ced9b4ebd7..ef70bc591a 100644 --- a/src/gpu/ops/GrSmallPathRenderer.cpp +++ b/src/gpu/ops/GrSmallPathRenderer.cpp @@ -133,7 +133,7 @@ bool GrSmallPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { // padding around path bounds to allow for antialiased pixels static const SkScalar kAntiAliasPad = 1.0f; -class SmallPathOp final : public GrMeshDrawOp { +class SmallPathOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID @@ -141,12 +141,12 @@ public: using ShapeCache = SkTDynamicHash<ShapeData, ShapeData::Key>; using ShapeDataList = GrSmallPathRenderer::ShapeDataList; - static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, const GrShape& shape, - const SkMatrix& viewMatrix, GrDrawOpAtlas* atlas, - ShapeCache* shapeCache, ShapeDataList* shapeList, - bool gammaCorrect) { - return std::unique_ptr<GrMeshDrawOp>(new SmallPathOp(color, shape, viewMatrix, atlas, - shapeCache, shapeList, gammaCorrect)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(GrColor color, const GrShape& shape, + const SkMatrix& viewMatrix, + GrDrawOpAtlas* atlas, ShapeCache* shapeCache, + ShapeDataList* shapeList, bool gammaCorrect) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new SmallPathOp( + color, shape, viewMatrix, atlas, shapeCache, shapeList, gammaCorrect)); } const char* name() const override { return "SmallPathOp"; } @@ -388,9 +388,9 @@ private: this->flush(target, &flushInfo); } - bool addDFPathToAtlas(GrMeshDrawOp::Target* target, FlushInfo* flushInfo, GrDrawOpAtlas* atlas, - ShapeData* shapeData, const GrShape& shape, uint32_t dimension, - SkScalar scale) const { + bool addDFPathToAtlas(GrLegacyMeshDrawOp::Target* target, FlushInfo* flushInfo, + GrDrawOpAtlas* atlas, ShapeData* shapeData, const GrShape& shape, + uint32_t dimension, SkScalar scale) const { const SkRect& bounds = shape.bounds(); // generate bounding rect for bitmap draw @@ -505,9 +505,9 @@ private: return true; } - bool addBMPathToAtlas(GrMeshDrawOp::Target* target, FlushInfo* flushInfo, - GrDrawOpAtlas* atlas, ShapeData* shapeData, - const GrShape& shape, const SkMatrix& ctm) const { + bool addBMPathToAtlas(GrLegacyMeshDrawOp::Target* target, FlushInfo* flushInfo, + GrDrawOpAtlas* atlas, ShapeData* shapeData, const GrShape& shape, + const SkMatrix& ctm) const { const SkRect& bounds = shape.bounds(); if (bounds.isEmpty()) { return false; @@ -677,7 +677,7 @@ private: textureCoords[1] = t; } - void flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const { + void flush(GrLegacyMeshDrawOp::Target* target, FlushInfo* flushInfo) const { if (flushInfo->fInstancesToFlush) { GrMesh mesh; int maxInstancesPerDraw = @@ -685,7 +685,7 @@ private: mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer.get(), flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset, kVerticesPerQuad, kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw); - target->draw(flushInfo->fGeometryProcessor.get(), mesh); + target->draw(flushInfo->fGeometryProcessor.get(), this->pipeline(), mesh); flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush; flushInfo->fInstancesToFlush = 0; } @@ -738,7 +738,7 @@ private: ShapeDataList* fShapeList; bool fGammaCorrect; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) { @@ -760,13 +760,13 @@ bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) { } } - std::unique_ptr<GrMeshDrawOp> op = SmallPathOp::Make( - args.fPaint.getColor(), *args.fShape, *args.fViewMatrix, fAtlas.get(), &fShapeCache, - &fShapeList, args.fGammaCorrect); + std::unique_ptr<GrLegacyMeshDrawOp> op = + SmallPathOp::Make(args.fPaint.getColor(), *args.fShape, *args.fViewMatrix, fAtlas.get(), + &fShapeCache, &fShapeList, args.fGammaCorrect); GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); return true; } diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp index 4c2edf408f..ea07644218 100644 --- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp @@ -112,7 +112,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { } const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix; - std::unique_ptr<GrMeshDrawOp> coverOp(GrRectOpFactory::MakeNonAAFill( + std::unique_ptr<GrLegacyMeshDrawOp> coverOp(GrRectOpFactory::MakeNonAAFill( args.fPaint.getColor(), viewM, bounds, nullptr, &invert)); // fake inverse with a stencil and cover @@ -141,8 +141,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), coverAAType); pipelineBuilder.setUserStencil(&kInvertedCoverPass); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, - std::move(coverOp)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, + std::move(coverOp)); } } else { GrAA aa = GrBoolToAA(GrAATypeIsHW(args.fAAType)); diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp index 9f3b1d6e1d..eda39c2eec 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.cpp +++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp @@ -103,8 +103,11 @@ private: class DynamicVertexAllocator : public GrTessellator::VertexAllocator { public: - DynamicVertexAllocator(size_t stride, GrMeshDrawOp::Target* target) - : VertexAllocator(stride), fTarget(target), fVertexBuffer(nullptr), fVertices(nullptr) {} + DynamicVertexAllocator(size_t stride, GrLegacyMeshDrawOp::Target* target) + : VertexAllocator(stride) + , fTarget(target) + , fVertexBuffer(nullptr) + , fVertices(nullptr) {} void* lock(int vertexCount) override { fVertexCount = vertexCount; fVertices = fTarget->makeVertexSpace(stride(), vertexCount, &fVertexBuffer, &fFirstVertex); @@ -117,7 +120,7 @@ public: const GrBuffer* vertexBuffer() const { return fVertexBuffer; } int firstVertex() const { return fFirstVertex; } private: - GrMeshDrawOp::Target* fTarget; + GrLegacyMeshDrawOp::Target* fTarget; const GrBuffer* fVertexBuffer; int fVertexCount; int fFirstVertex; @@ -156,16 +159,16 @@ bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons return true; } -class TessellatingPathOp final : public GrMeshDrawOp { +class TessellatingPathOp final : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrMeshDrawOp> Make(const GrColor& color, - const GrShape& shape, - const SkMatrix& viewMatrix, - SkIRect devClipBounds, - bool antiAlias) { - return std::unique_ptr<GrMeshDrawOp>( + static std::unique_ptr<GrLegacyMeshDrawOp> Make(const GrColor& color, + const GrShape& shape, + const SkMatrix& viewMatrix, + SkIRect devClipBounds, + bool antiAlias) { + return std::unique_ptr<GrLegacyMeshDrawOp>( new TessellatingPathOp(color, shape, viewMatrix, devClipBounds, antiAlias)); } @@ -314,7 +317,7 @@ private: : kTriangles_GrPrimitiveType; GrMesh mesh; mesh.init(primitiveType, vb, firstVertex, count); - target->draw(gp, mesh); + target->draw(gp, this->pipeline(), mesh); } bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; } @@ -348,7 +351,7 @@ private: bool fCanTweakAlphaForCoverage; bool fNeedsLocalCoords; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { @@ -358,7 +361,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { args.fClip->getConservativeBounds(args.fRenderTargetContext->width(), args.fRenderTargetContext->height(), &clipBoundsI); - std::unique_ptr<GrMeshDrawOp> op = + std::unique_ptr<GrLegacyMeshDrawOp> op = TessellatingPathOp::Make(args.fPaint.getColor(), *args.fShape, *args.fViewMatrix, @@ -366,7 +369,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) { GrAAType::kCoverage == args.fAAType); GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType); pipelineBuilder.setUserStencil(args.fUserStencilSettings); - args.fRenderTargetContext->addMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); + args.fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, *args.fClip, std::move(op)); return true; } diff --git a/src/gpu/ops/GrTestMeshDrawOp.h b/src/gpu/ops/GrTestMeshDrawOp.h index 5ca4af754f..aad6774eb2 100644 --- a/src/gpu/ops/GrTestMeshDrawOp.h +++ b/src/gpu/ops/GrTestMeshDrawOp.h @@ -14,10 +14,10 @@ #include "ops/GrMeshDrawOp.h" /* - * A simple solid color GrMeshDrawOp for testing purposes which doesn't ever combine. Subclassing - * this in tests saves having to fill out some boiler plate methods. + * A simple solid color GrLegacyMeshDrawOp for testing purposes which doesn't ever combine. + * Subclassing this in tests saves having to fill out some boiler plate methods. */ -class GrTestMeshDrawOp : public GrMeshDrawOp { +class GrTestMeshDrawOp : public GrLegacyMeshDrawOp { public: const char* name() const override = 0; @@ -49,7 +49,7 @@ private: GrColor fColor; bool fUsesLocalCoords = false; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; #endif diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index 5427855cfc..e8eeb0c78a 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -257,7 +257,7 @@ bool GrAtlasTextBlob::mustRegenerate(const GrTextUtils::Paint& paint, return false; } -inline std::unique_ptr<GrMeshDrawOp> GrAtlasTextBlob::makeOp( +inline std::unique_ptr<GrLegacyMeshDrawOp> GrAtlasTextBlob::makeOp( const Run::SubRunInfo& info, int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const GrTextUtils::Paint& paint, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, @@ -305,12 +305,12 @@ inline void GrAtlasTextBlob::flushRun(GrRenderTargetContext* rtc, const GrClip& continue; } - std::unique_ptr<GrMeshDrawOp> op(this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, - y, paint, props, distanceAdjustTable, - rtc->isGammaCorrect(), cache)); + std::unique_ptr<GrLegacyMeshDrawOp> op( + this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, paint, props, + distanceAdjustTable, rtc->isGammaCorrect(), cache)); GrPipelineBuilder pipelineBuilder(std::move(grPaint), GrAAType::kNone); - rtc->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); + rtc->addLegacyMeshDrawOp(pipelineBuilder, clip, std::move(op)); } } @@ -425,7 +425,7 @@ void GrAtlasTextBlob::flushThrowaway(GrContext* context, GrRenderTargetContext* this->flushBigGlyphs(context, rtc, clip, paint, viewMatrix, x, y, clipBounds); } -std::unique_ptr<GrMeshDrawOp> GrAtlasTextBlob::test_makeOp( +std::unique_ptr<GrLegacyMeshDrawOp> GrAtlasTextBlob::test_makeOp( int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const GrTextUtils::Paint& paint, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache) { diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h index 47dd1db5c5..855413bcd1 100644 --- a/src/gpu/text/GrAtlasTextBlob.h +++ b/src/gpu/text/GrAtlasTextBlob.h @@ -24,7 +24,7 @@ class GrBlobRegenHelper; struct GrDistanceFieldAdjustTable; class GrMemoryPool; -class GrMeshDrawOp; +class GrLegacyMeshDrawOp; class SkDrawFilter; class SkTextBlob; class SkTextBlobRunIterator; @@ -270,12 +270,10 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////// // Internal test methods - std::unique_ptr<GrMeshDrawOp> test_makeOp(int glyphCount, int run, int subRun, - const SkMatrix& viewMatrix, SkScalar x, SkScalar y, - const GrTextUtils::Paint& paint, - const SkSurfaceProps& props, - const GrDistanceFieldAdjustTable* distanceAdjustTable, - GrAtlasGlyphCache* cache); + std::unique_ptr<GrLegacyMeshDrawOp> test_makeOp( + int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, + const GrTextUtils::Paint& paint, const SkSurfaceProps& props, + const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache); private: GrAtlasTextBlob() @@ -489,7 +487,7 @@ private: Run* run, Run::SubRunInfo* info, SkAutoGlyphCache*, int glyphCount, size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const; - inline std::unique_ptr<GrMeshDrawOp> makeOp( + inline std::unique_ptr<GrLegacyMeshDrawOp> makeOp( const Run::SubRunInfo& info, int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const GrTextUtils::Paint& paint, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 125f5d064c..489aec1391 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -323,7 +323,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { GrPaint grPaint; - std::unique_ptr<GrMeshDrawOp> op(GrRandomDrawOp(&random, context)); + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRandomDrawOp(&random, context)); SkASSERT(op); GrProcessorTestData ptd(&random, context, renderTargetContext.get(), dummyTextures); @@ -336,8 +336,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { static constexpr GrAAType kAATypes[] = {GrAAType::kNone, GrAAType::kCoverage}; GrAAType aaType = kAATypes[random.nextULessThan(SK_ARRAY_COUNT(kAATypes))]; - renderTargetContext->priv().testingOnly_addMeshDrawOp(std::move(grPaint), aaType, - std::move(op), uss, snapToCenters); + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( + std::move(grPaint), aaType, std::move(op), uss, snapToCenters); } // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes) drawingManager->flush(nullptr); @@ -358,7 +358,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { for (int i = 0; i < fpFactoryCnt; ++i) { // Since FP factories internally randomize, call each 10 times. for (int j = 0; j < 10; ++j) { - std::unique_ptr<GrMeshDrawOp> op(GrRandomDrawOp(&random, context)); + std::unique_ptr<GrLegacyMeshDrawOp> op(GrRandomDrawOp(&random, context)); SkASSERT(op); GrProcessorTestData ptd(&random, context, renderTargetContext.get(), dummyTextures); GrPaint grPaint; @@ -370,7 +370,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { BlockInputFragmentProcessor::Make(std::move(fp))); grPaint.addColorFragmentProcessor(std::move(blockFP)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(grPaint), GrAAType::kNone, std::move(op)); drawingManager->flush(nullptr); } diff --git a/tests/PreFlushCallbackTest.cpp b/tests/PreFlushCallbackTest.cpp index e5acae9e42..7be01fb709 100644 --- a/tests/PreFlushCallbackTest.cpp +++ b/tests/PreFlushCallbackTest.cpp @@ -21,7 +21,7 @@ // This is a simplified mesh drawing op that can be used in the atlas generation test. // Please see AtlasedRectOp below. -class NonAARectOp : public GrMeshDrawOp { +class NonAARectOp : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID const char* name() const override { return "NonAARectOp"; } @@ -150,10 +150,10 @@ private: firstVertex, firstIndex, 4, 6); - target->draw(gp.get(), mesh); + target->draw(gp.get(), this->pipeline(), mesh); } - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; #ifdef SK_DEBUG @@ -444,9 +444,8 @@ static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject AtlasedRectOp* sparePtr = op.get(); - uint32_t opListID = rtc->priv().testingOnly_addMeshDrawOp(std::move(paint), - GrAAType::kNone, - std::move(op)); + uint32_t opListID = rtc->priv().testingOnly_addLegacyMeshDrawOp( + std::move(paint), GrAAType::kNone, std::move(op)); object->addOp(opListID, sparePtr); } diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 337c8b93cf..4e4edb7e35 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -25,14 +25,14 @@ #include "ops/GrMeshDrawOp.h" namespace { -class Op : public GrMeshDrawOp { +class Op : public GrLegacyMeshDrawOp { public: DEFINE_OP_CLASS_ID const char* name() const override { return "Dummy Op"; } - static std::unique_ptr<GrMeshDrawOp> Make(int numAttribs) { - return std::unique_ptr<GrMeshDrawOp>(new Op(numAttribs)); + static std::unique_ptr<GrLegacyMeshDrawOp> Make(int numAttribs) { + return std::unique_ptr<GrLegacyMeshDrawOp>(new Op(numAttribs)); } private: @@ -93,12 +93,12 @@ private: size_t vertexStride = gp->getVertexStride(); SkPoint* vertices = reinterpret_cast<SkPoint*>(helper.init(target, vertexStride, 1)); vertices->setRectFan(0.f, 0.f, 1.f, 1.f, vertexStride); - helper.recordDraw(target, gp.get()); + helper.recordDraw(target, gp.get(), this->pipeline()); } int fNumAttribs; - typedef GrMeshDrawOp INHERITED; + typedef GrLegacyMeshDrawOp INHERITED; }; } @@ -126,16 +126,16 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { #endif GrPaint grPaint; // This one should succeed. - renderTargetContext->priv().testingOnly_addMeshDrawOp(GrPaint(grPaint), GrAAType::kNone, - Op::Make(attribCnt)); + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp(GrPaint(grPaint), GrAAType::kNone, + Op::Make(attribCnt)); context->flush(); #if GR_GPU_STATS REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1); REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0); #endif context->resetGpuStats(); - renderTargetContext->priv().testingOnly_addMeshDrawOp(std::move(grPaint), GrAAType::kNone, - Op::Make(attribCnt + 1)); + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp(std::move(grPaint), GrAAType::kNone, + Op::Make(attribCnt + 1)); context->flush(); #if GR_GPU_STATS REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 140ff15cfd..241c0fa4e3 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -28,8 +28,8 @@ public: DEFINE_OP_CLASS_ID const char* name() const override { return "TestOp"; } - static std::unique_ptr<GrMeshDrawOp> Make() { - return std::unique_ptr<GrMeshDrawOp>(new TestOp); + static std::unique_ptr<GrLegacyMeshDrawOp> Make() { + return std::unique_ptr<GrLegacyMeshDrawOp>(new TestOp); } private: @@ -170,7 +170,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { images.emplace_back(texture3, GrIOType::kWrite_GrIOType); images.emplace_back(texture4, GrIOType::kRW_GrIOType); } - std::unique_ptr<GrMeshDrawOp> op(TestOp::Make()); + std::unique_ptr<GrLegacyMeshDrawOp> op(TestOp::Make()); GrPaint paint; auto fp = TestFP::Make(context, std::move(proxies), std::move(buffers), std::move(images)); @@ -178,7 +178,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { fp = TestFP::Make(std::move(fp)); } paint.addColorFragmentProcessor(std::move(fp)); - renderTargetContext->priv().testingOnly_addMeshDrawOp( + renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp( std::move(paint), GrAAType::kNone, std::move(op)); } int refCnt, readCnt, writeCnt; @@ -270,7 +270,7 @@ void test_draw_op(GrRenderTargetContext* rtc, sk_sp<GrFragmentProcessor> fp, auto op = GrNonAAFillRectOp::Make(GrColor_WHITE, SkMatrix::I(), SkRect::MakeWH(rtc->width(), rtc->height()), nullptr, nullptr); - rtc->addMeshDrawOp(pb, GrNoClip(), std::move(op)); + rtc->addLegacyMeshDrawOp(pb, GrNoClip(), std::move(op)); } #include "SkCommandLineFlags.h" diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index 28c1738a0d..005595d2eb 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -228,18 +228,18 @@ int GrResourceCache::countUniqueKeysWithTag(const char* tag) const { #define ASSERT_SINGLE_OWNER \ SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->fSingleOwner);) -uint32_t GrRenderTargetContextPriv::testingOnly_addMeshDrawOp(GrPaint&& paint, - GrAAType aaType, - std::unique_ptr<GrMeshDrawOp> op, - const GrUserStencilSettings* uss, - bool snapToCenters) { +uint32_t GrRenderTargetContextPriv::testingOnly_addLegacyMeshDrawOp( + GrPaint&& paint, + GrAAType aaType, + std::unique_ptr<GrLegacyMeshDrawOp> op, + const GrUserStencilSettings* uss, + bool snapToCenters) { ASSERT_SINGLE_OWNER if (fRenderTargetContext->drawingManager()->wasAbandoned()) { return SK_InvalidUniqueID; } - SkDEBUGCODE(fRenderTargetContext->validate();) - GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail, - "GrRenderTargetContext::testingOnly_addMeshDrawOp"); + SkDEBUGCODE(fRenderTargetContext->validate();) GR_AUDIT_TRAIL_AUTO_FRAME( + fRenderTargetContext->fAuditTrail, "GrRenderTargetContext::testingOnly_addMeshDrawOp"); GrPipelineBuilder pipelineBuilder(std::move(paint), aaType); if (uss) { @@ -247,7 +247,7 @@ uint32_t GrRenderTargetContextPriv::testingOnly_addMeshDrawOp(GrPaint&& paint, } pipelineBuilder.setSnapVerticesToPixelCenters(snapToCenters); - return fRenderTargetContext->addMeshDrawOp(pipelineBuilder, GrNoClip(), std::move(op)); + return fRenderTargetContext->addLegacyMeshDrawOp(pipelineBuilder, GrNoClip(), std::move(op)); } #undef ASSERT_SINGLE_OWNER |