diff options
author | Robert Phillips <robertphillips@google.com> | 2018-06-07 11:05:56 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-08 11:55:11 +0000 |
commit | 88a32efa75cbc0fc6f84bc7a0522a94166a2ab13 (patch) | |
tree | 48ccbee45d39a1a62b1d54616b78fea564456eb1 /src/gpu/ccpr | |
parent | 7a45dd1daca8de90f984591cf938dd089a7795a3 (diff) |
Add a factory to any GrOp-derived class that lacked one
All GrOp-derived classes are going to have allocate their memory in a GrMemoryPool.
Change-Id: Ifa410b05eecd9b68c39dcc15dd4298d617204c13
Reviewed-on: https://skia-review.googlesource.com/132828
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/ccpr')
-rw-r--r-- | src/gpu/ccpr/GrCCAtlas.cpp | 33 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCCDrawPathsOp.cpp | 9 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCCDrawPathsOp.h | 12 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp | 13 |
4 files changed, 49 insertions, 18 deletions
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp index da4138f4d5..afa82c4ec7 100644 --- a/src/gpu/ccpr/GrCCAtlas.cpp +++ b/src/gpu/ccpr/GrCCAtlas.cpp @@ -9,6 +9,7 @@ #include "GrClip.h" #include "GrOnFlushResourceProvider.h" +#include "GrSurfaceContextPriv.h" #include "GrRectanizer_skyline.h" #include "GrRenderTargetContext.h" #include "GrTextureProxy.h" @@ -54,14 +55,12 @@ class GrCCAtlas::DrawCoverageCountOp : public GrDrawOp { public: DEFINE_OP_CLASS_ID - DrawCoverageCountOp(sk_sp<const GrCCPathParser> parser, CoverageCountBatchID batchID, - const SkISize& drawBounds) - : INHERITED(ClassID()) - , fParser(std::move(parser)) - , fBatchID(batchID) - , fDrawBounds(drawBounds) { - this->setBounds(SkRect::MakeIWH(fDrawBounds.width(), fDrawBounds.height()), - GrOp::HasAABloat::kNo, GrOp::IsZeroArea::kNo); + static std::unique_ptr<GrDrawOp> Make(GrContext* context, + sk_sp<const GrCCPathParser> parser, + CoverageCountBatchID batchID, + const SkISize& drawBounds) { + return std::unique_ptr<GrDrawOp>(new DrawCoverageCountOp(std::move(parser), + batchID, drawBounds)); } // GrDrawOp interface. @@ -77,6 +76,16 @@ public: } private: + DrawCoverageCountOp(sk_sp<const GrCCPathParser> parser, CoverageCountBatchID batchID, + const SkISize& drawBounds) + : INHERITED(ClassID()) + , fParser(std::move(parser)) + , fBatchID(batchID) + , fDrawBounds(drawBounds) { + this->setBounds(SkRect::MakeIWH(fDrawBounds.width(), fDrawBounds.height()), + GrOp::HasAABloat::kNo, GrOp::IsZeroArea::kNo); + } + const sk_sp<const GrCCPathParser> fParser; const CoverageCountBatchID fBatchID; const SkISize fDrawBounds; @@ -160,8 +169,12 @@ sk_sp<GrRenderTargetContext> GrCCAtlas::finalize(GrOnFlushResourceProvider* onFl SkIRect clearRect = SkIRect::MakeSize(fDrawBounds); rtc->clear(&clearRect, 0, GrRenderTargetContext::CanClearFullscreen::kYes); - auto op = skstd::make_unique<DrawCoverageCountOp>(std::move(parser), fCoverageCountBatchID, - fDrawBounds); + GrContext* context = rtc->surfPriv().getContext(); + + std::unique_ptr<GrDrawOp> op = DrawCoverageCountOp::Make(context, + std::move(parser), + fCoverageCountBatchID, + fDrawBounds); rtc->addDrawOp(GrNoClip(), std::move(op)); fTextureProxy = sk_ref_sp(rtc->asTextureProxy()); diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp index 39c1b26223..c4be7c59a5 100644 --- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp +++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp @@ -12,6 +12,15 @@ #include "ccpr/GrCCPerFlushResources.h" #include "ccpr/GrCoverageCountingPathRenderer.h" +GrCCDrawPathsOp* GrCCDrawPathsOp::Make(GrContext* context, + GrPaint&& paint, + const SkIRect& clipIBounds, + const SkMatrix& m, + const SkPath& path, + const SkRect& devBounds) { + return new GrCCDrawPathsOp(std::move(paint), clipIBounds, m, path, devBounds); +} + static bool has_coord_transforms(const GrPaint& paint) { GrFragmentProcessor::Iter iter(paint); while (const GrFragmentProcessor* fp = iter.next()) { diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.h b/src/gpu/ccpr/GrCCDrawPathsOp.h index 9189e5a757..f43ccd0e57 100644 --- a/src/gpu/ccpr/GrCCDrawPathsOp.h +++ b/src/gpu/ccpr/GrCCDrawPathsOp.h @@ -26,8 +26,13 @@ public: DEFINE_OP_CLASS_ID SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrCCDrawPathsOp); - GrCCDrawPathsOp(GrPaint&&, const SkIRect& clipIBounds, const SkMatrix&, const SkPath&, - const SkRect& devBounds); + static GrCCDrawPathsOp* Make(GrContext*, + GrPaint&&, + const SkIRect& clipIBounds, + const SkMatrix&, + const SkPath&, + const SkRect& devBounds); + ~GrCCDrawPathsOp() override; const char* name() const override { return "GrCCDrawOp"; } @@ -48,6 +53,9 @@ public: void onExecute(GrOpFlushState*) override; private: + GrCCDrawPathsOp(GrPaint&&, const SkIRect& clipIBounds, const SkMatrix&, const SkPath&, + const SkRect& devBounds); + struct AtlasBatch { const GrCCAtlas* fAtlas; int fEndInstanceIdx; diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp index c8fafeb566..dcb9a588aa 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp @@ -127,19 +127,20 @@ bool GrCoverageCountingPathRenderer::onDrawPath(const DrawPathArgs& args) { SkRect devBounds; args.fViewMatrix->mapRect(&devBounds, path.getBounds()); + GrCCDrawPathsOp* op; if (SkTMax(devBounds.height(), devBounds.width()) > kPathCropThreshold) { // The path is too large. Crop it or analytic AA can run out of fp32 precision. SkPath croppedPath; path.transform(*args.fViewMatrix, &croppedPath); crop_path(croppedPath, clipIBounds, &croppedPath); - this->adoptAndRecordOp(new GrCCDrawPathsOp(std::move(args.fPaint), clipIBounds, - SkMatrix::I(), croppedPath, - croppedPath.getBounds()), args); - return true; + op = GrCCDrawPathsOp::Make(args.fContext, std::move(args.fPaint), clipIBounds, + SkMatrix::I(), croppedPath, croppedPath.getBounds()); + } else { + op = GrCCDrawPathsOp::Make(args.fContext, std::move(args.fPaint), clipIBounds, + *args.fViewMatrix, path, devBounds); } - this->adoptAndRecordOp(new GrCCDrawPathsOp(std::move(args.fPaint), clipIBounds, - *args.fViewMatrix, path, devBounds), args); + this->adoptAndRecordOp(op, args); return true; } |