diff options
author | Robert Phillips <robertphillips@google.com> | 2018-01-17 13:35:46 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-17 19:43:57 +0000 |
commit | adbe1328789071d1f742023edd93b6948eed9470 (patch) | |
tree | 952806d1cb29fc01b5743b433f6bfaabc6d6869e /src/gpu/GrProxyProvider.cpp | |
parent | fe266c2bce2b8ac4ef953f16c8e1a7801da9c57d (diff) |
Remove GrSurfaceProxy::MakeWrapped (take 2)
TBR=bsalomon@google.com
Change-Id: I26fd911da502fb00addacb8b2c1a263efc5aa4ec
Reviewed-on: https://skia-review.googlesource.com/95881
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrProxyProvider.cpp')
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index bf5caeb26a..f60fc3eba6 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -40,11 +40,11 @@ GrProxyProvider::~GrProxyProvider() { SkASSERT(!fUniquelyKeyedProxies.count()); } -void GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) { +bool GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) { ASSERT_SINGLE_OWNER SkASSERT(key.isValid()); if (this->isAbandoned() || !proxy) { - return; + return false; } // If there is already a GrResource with this key then the caller has violated the normal @@ -59,7 +59,7 @@ void GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTexturePr if (SkBudgeted::kNo == proxy->isBudgeted() && (!proxy->priv().isInstantiated() || !proxy->priv().peekSurface()->resourcePriv().refsWrappedObjects())) { - return; + return false; } SkASSERT(!fUniquelyKeyedProxies.find(key)); // multiple proxies can't get the same key @@ -67,6 +67,7 @@ void GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTexturePr proxy->cacheAccess().setUniqueKey(this, key); SkASSERT(proxy->getUniqueKey() == key); fUniquelyKeyedProxies.add(proxy); + return true; } void GrProxyProvider::adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface* surf) { @@ -101,6 +102,20 @@ sk_sp<GrTextureProxy> GrProxyProvider::findProxyByUniqueKey(const GrUniqueKey& k return result; } +sk_sp<GrTextureProxy> GrProxyProvider::createWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) { +#ifdef SK_DEBUG + if (tex->getUniqueKey().isValid()) { + SkASSERT(!this->findProxyByUniqueKey(tex->getUniqueKey(), origin)); + } +#endif + + if (tex->asRenderTarget()) { + return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin)); + } else { + return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin)); + } +} + sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniqueKey& key, GrSurfaceOrigin origin) { ASSERT_SINGLE_OWNER @@ -122,9 +137,9 @@ sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniq sk_sp<GrTexture> texture(static_cast<GrSurface*>(resource)->asTexture()); SkASSERT(texture); - result = GrSurfaceProxy::MakeWrapped(std::move(texture), origin); + result = this->createWrapped(std::move(texture), origin); SkASSERT(result->getUniqueKey() == key); - // MakeWrapped should've added this for us + // createWrapped should've added this for us SkASSERT(fUniquelyKeyedProxies.find(key)); return result; } @@ -144,13 +159,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createInstantiatedProxy(const GrSurfaceDe return nullptr; } - SkASSERT(!tex->getUniqueKey().isValid()); - - if (tex->asRenderTarget()) { - return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), desc.fOrigin)); - } - - return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), desc.fOrigin)); + return this->createWrapped(std::move(tex), desc.fOrigin); } sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(const GrSurfaceDesc& desc, @@ -170,7 +179,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(const GrSurfaceDesc& d return nullptr; } - return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); + return this->createWrapped(std::move(tex), desc.fOrigin); } return this->createProxy(desc, SkBackingFit::kExact, budgeted); @@ -225,7 +234,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy( return nullptr; } - return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); + return this->createWrapped(std::move(tex), desc.fOrigin); } sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& desc, @@ -310,19 +319,27 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc, #endif } -sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& backendTex, - GrSurfaceOrigin origin) { +sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy( + const GrBackendTexture& backendTex, + GrSurfaceOrigin origin, + GrWrapOwnership ownership, + ReleaseProc releaseProc, + ReleaseContext releaseCtx) { if (this->isAbandoned()) { return nullptr; } - sk_sp<GrTexture> texture(fResourceProvider->wrapBackendTexture(backendTex)); + sk_sp<GrTexture> texture(fResourceProvider->wrapBackendTexture(backendTex, ownership)); if (!texture) { return nullptr; } + if (releaseProc) { + texture->setRelease(releaseProc, releaseCtx); + } + SkASSERT(!texture->asRenderTarget()); // Strictly a GrTexture - return GrSurfaceProxy::MakeWrapped(std::move(texture), origin); + return this->createWrapped(std::move(texture), origin); } sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& tex, @@ -338,7 +355,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackend } SkASSERT(texture->asRenderTarget()); // A GrTextureRenderTarget - return GrSurfaceProxy::MakeWrapped(std::move(texture), origin); + return this->createWrapped(std::move(texture), origin); } sk_sp<GrSurfaceProxy> GrProxyProvider::createWrappedRenderTargetProxy( |