From 80bff5b3a2d7fa772ce0e32247c1a448d8bb48bf Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 20 Aug 2019 16:56:18 -0400 Subject: [PATCH] Remove GrProxyPendingIO Change-Id: I9cf40f0518673206c6304e3f386dd75c9a44f269 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235865 Reviewed-by: Greg Daniel Commit-Queue: Robert Phillips --- src/gpu/GrPendingIOResource.h | 32 -------------------------------- src/gpu/GrPipeline.cpp | 4 ++-- src/gpu/GrPipeline.h | 4 ++-- src/gpu/GrXferProcessor.h | 1 + src/gpu/ops/GrCopySurfaceOp.h | 12 ++++++------ tests/ProxyRefTest.cpp | 19 +++++++------------ 6 files changed, 18 insertions(+), 54 deletions(-) diff --git a/src/gpu/GrPendingIOResource.h b/src/gpu/GrPendingIOResource.h index 09340fe140..17bec297ea 100644 --- a/src/gpu/GrPendingIOResource.h +++ b/src/gpu/GrPendingIOResource.h @@ -13,38 +13,6 @@ #include "include/private/SkNoncopyable.h" #include "src/gpu/GrSurfaceProxy.h" -class GrProxyPendingIO : SkNoncopyable { -public: - GrProxyPendingIO() = default; - GrProxyPendingIO(GrSurfaceProxy* resource) { this->reset(resource); } - ~GrProxyPendingIO() { this->reset(nullptr); } - - void reset(GrSurfaceProxy* resource = nullptr) { - if (resource == fResource) { - return; - } - - if (fResource) { - fResource->unref(); - } - - fResource = resource; - if (fResource) { - fResource->ref(); - } - } - - explicit operator bool() const { return SkToBool(fResource); } - - GrSurfaceProxy* get() const { return fResource; } - GrSurfaceProxy* operator->() const { return fResource; } - -private: - bool operator==(const GrProxyPendingIO& other) const = delete; - - GrSurfaceProxy* fResource = nullptr; -}; - /** * Helper for owning a pending read, write, read-write on a GrGpuResource. It never owns a regular * ref. diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index af2a5e6c98..1de219928a 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -42,7 +42,7 @@ GrPipeline::GrPipeline(const InitArgs& args, if (args.fDstProxy.proxy()) { SkASSERT(args.fDstProxy.proxy()->isInstantiated()); - fDstTextureProxy.reset(args.fDstProxy.proxy()); + fDstTextureProxy = args.fDstProxy.refProxy(); fDstTextureOffset = args.fDstProxy.offset(); } @@ -75,7 +75,7 @@ GrPipeline::GrPipeline(const InitArgs& args, } GrXferBarrierType GrPipeline::xferBarrierType(GrTexture* texture, const GrCaps& caps) const { - if (fDstTextureProxy.get() && fDstTextureProxy.get()->peekTexture() == texture) { + if (fDstTextureProxy && fDstTextureProxy->peekTexture() == texture) { return kTexture_GrXferBarrierType; } return this->getXferProcessor().xferBarrierType(caps); diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 2978c6975d..cacf02034c 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -142,7 +142,7 @@ public: *offset = fDstTextureOffset; } - return fDstTextureProxy ? fDstTextureProxy->asTextureProxy() : nullptr; + return fDstTextureProxy.get(); } GrTexture* peekDstTexture(SkIPoint* offset = nullptr) const { @@ -218,7 +218,7 @@ private: using FragmentProcessorArray = SkAutoSTArray<8, std::unique_ptr>; - GrProxyPendingIO fDstTextureProxy; + sk_sp fDstTextureProxy; SkIPoint fDstTextureOffset; GrWindowRectsState fWindowRectsState; const GrUserStencilSettings* fUserStencilSettings; diff --git a/src/gpu/GrXferProcessor.h b/src/gpu/GrXferProcessor.h index 604c68d1da..18525e7c05 100644 --- a/src/gpu/GrXferProcessor.h +++ b/src/gpu/GrXferProcessor.h @@ -87,6 +87,7 @@ public: void setOffset(int ox, int oy) { fOffset.set(ox, oy); } GrTextureProxy* proxy() const { return fProxy.get(); } + sk_sp refProxy() const { return fProxy; } void setProxy(sk_sp proxy) { fProxy = std::move(proxy); diff --git a/src/gpu/ops/GrCopySurfaceOp.h b/src/gpu/ops/GrCopySurfaceOp.h index 69652bd360..f5d41dda12 100644 --- a/src/gpu/ops/GrCopySurfaceOp.h +++ b/src/gpu/ops/GrCopySurfaceOp.h @@ -49,8 +49,8 @@ private: GrCopySurfaceOp(GrSurfaceProxy* src, GrSurfaceProxy* dst, const SkIRect& srcRect, const SkIPoint& dstPoint) : INHERITED(ClassID()) - , fSrc(src) - , fDst(dst) + , fSrc(sk_ref_sp(src)) + , fDst(sk_ref_sp(dst)) , fSrcRect(srcRect) , fDstPoint(dstPoint) { SkRect bounds = @@ -72,10 +72,10 @@ private: void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; - GrProxyPendingIO fSrc; - GrProxyPendingIO fDst; - SkIRect fSrcRect; - SkIPoint fDstPoint; + sk_sp fSrc; + sk_sp fDst; + SkIRect fSrcRect; + SkIPoint fDstPoint; typedef GrOp INHERITED; }; diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index 6e0ab22c35..b82ab91d82 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -62,11 +62,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrResourceProvider* resourceProvider = ctxInfo.grContext()->priv().resourceProvider(); for (auto make : { make_deferred, make_wrapped }) { - // Pending IO ref + // An extra ref { sk_sp proxy((*make)(ctxInfo.grContext())); - if (proxy.get()) { - GrProxyPendingIO pendingIO(proxy.get()); + if (proxy) { + sk_sp extraRef(proxy); int backingRefs = proxy->isInstantiated() ? 1 : -1; @@ -103,23 +103,18 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { // Continue using (reffing) proxy after instantiation { sk_sp proxy((*make)(ctxInfo.grContext())); - if (proxy.get()) { - proxy->ref(); - - GrProxyPendingIO pendingIO(proxy.get()); + if (proxy) { + sk_sp firstExtraRef(proxy); int backingRefs = proxy->isInstantiated() ? 1 : -1; - check_refs(reporter, proxy.get(), 3, backingRefs); + check_refs(reporter, proxy.get(), 2, backingRefs); proxy->instantiate(resourceProvider); - check_refs(reporter, proxy.get(), 3, 1); - - proxy->unref(); check_refs(reporter, proxy.get(), 2, 1); - GrProxyPendingIO secondPendingIO(proxy.get()); + sk_sp secondExtraRef(proxy); check_refs(reporter, proxy.get(), 3, 1); } check_refs(reporter, proxy.get(), 1, 1);