Remove GrProxyPendingIO

Change-Id: I9cf40f0518673206c6304e3f386dd75c9a44f269
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235865
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-08-20 16:56:18 -04:00 committed by Skia Commit-Bot
parent 362a1e0fab
commit 80bff5b3a2
6 changed files with 18 additions and 54 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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<const GrFragmentProcessor>>;
GrProxyPendingIO fDstTextureProxy;
sk_sp<GrTextureProxy> fDstTextureProxy;
SkIPoint fDstTextureOffset;
GrWindowRectsState fWindowRectsState;
const GrUserStencilSettings* fUserStencilSettings;

View File

@ -87,6 +87,7 @@ public:
void setOffset(int ox, int oy) { fOffset.set(ox, oy); }
GrTextureProxy* proxy() const { return fProxy.get(); }
sk_sp<GrTextureProxy> refProxy() const { return fProxy; }
void setProxy(sk_sp<GrTextureProxy> proxy) {
fProxy = std::move(proxy);

View File

@ -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<GrSurfaceProxy> fSrc;
sk_sp<GrSurfaceProxy> fDst;
SkIRect fSrcRect;
SkIPoint fDstPoint;
typedef GrOp INHERITED;
};

View File

@ -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<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
if (proxy.get()) {
GrProxyPendingIO pendingIO(proxy.get());
if (proxy) {
sk_sp<GrTextureProxy> 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<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
if (proxy.get()) {
proxy->ref();
GrProxyPendingIO pendingIO(proxy.get());
if (proxy) {
sk_sp<GrTextureProxy> 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<GrTextureProxy> secondExtraRef(proxy);
check_refs(reporter, proxy.get(), 3, 1);
}
check_refs(reporter, proxy.get(), 1, 1);