diff options
author | 2018-06-07 11:05:56 -0400 | |
---|---|---|
committer | 2018-06-08 11:55:11 +0000 | |
commit | 88a32efa75cbc0fc6f84bc7a0522a94166a2ab13 (patch) | |
tree | 48ccbee45d39a1a62b1d54616b78fea564456eb1 /src | |
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')
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 2 | ||||
-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 | ||||
-rw-r--r-- | src/gpu/ops/GrDebugMarkerOp.cpp | 27 | ||||
-rw-r--r-- | src/gpu/ops/GrDebugMarkerOp.h | 17 |
7 files changed, 83 insertions, 30 deletions
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index a79f9d113d..a4c08f3e78 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -1409,7 +1409,7 @@ bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores, } void GrRenderTargetContext::insertEventMarker(const SkString& str) { - std::unique_ptr<GrOp> op(GrDebugMarkerOp::Make(fRenderTargetProxy.get(), str)); + std::unique_ptr<GrOp> op(GrDebugMarkerOp::Make(fContext, fRenderTargetProxy.get(), str)); this->getRTOpList()->addOp(std::move(op), *this->caps()); } 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; } diff --git a/src/gpu/ops/GrDebugMarkerOp.cpp b/src/gpu/ops/GrDebugMarkerOp.cpp new file mode 100644 index 0000000000..1b663ceb1f --- /dev/null +++ b/src/gpu/ops/GrDebugMarkerOp.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrDebugMarkerOp.h" + +#include "GrCaps.h" +#include "GrContext.h" +#include "GrContextPriv.h" +#include "GrGpuCommandBuffer.h" +#include "GrOpFlushState.h" + +std::unique_ptr<GrOp> GrDebugMarkerOp::Make(GrContext* context, + GrRenderTargetProxy* proxy, + const SkString& str) { + return std::unique_ptr<GrOp>(new GrDebugMarkerOp(proxy, str)); +} + +void GrDebugMarkerOp::onExecute(GrOpFlushState* state) { + //SkDebugf("%s\n", fStr.c_str()); + if (state->caps().gpuTracingSupport()) { + state->commandBuffer()->insertEventMarker(fStr.c_str()); + } +} diff --git a/src/gpu/ops/GrDebugMarkerOp.h b/src/gpu/ops/GrDebugMarkerOp.h index 1b02c62e1a..931882ec4e 100644 --- a/src/gpu/ops/GrDebugMarkerOp.h +++ b/src/gpu/ops/GrDebugMarkerOp.h @@ -8,18 +8,18 @@ #ifndef GrDebugMarkerOp_DEFINED #define GrDebugMarkerOp_DEFINED -#include "GrGpuCommandBuffer.h" #include "GrOp.h" -#include "GrOpFlushState.h" #include "GrRenderTargetProxy.h" +class GrOpFlushState; + class GrDebugMarkerOp final : public GrOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrOp> Make(GrRenderTargetProxy* proxy, const SkString& str) { - return std::unique_ptr<GrOp>(new GrDebugMarkerOp(proxy, str)); - } + static std::unique_ptr<GrOp> Make(GrContext* context, + GrRenderTargetProxy* proxy, + const SkString& str); const char* name() const override { return "DebugMarker"; } @@ -41,12 +41,7 @@ private: void onPrepare(GrOpFlushState*) override {} - void onExecute(GrOpFlushState* state) override { - //SkDebugf("%s\n", fStr.c_str()); - if (state->caps().gpuTracingSupport()) { - state->commandBuffer()->insertEventMarker(fStr.c_str()); - } - } + void onExecute(GrOpFlushState* state) override; SkString fStr; |