Remove GrSurfaceProxy::MakeWrapped
Change-Id: Ic44cf1745dc3be21cbbaa1dc4ac85c8b1b21c6bb Reviewed-on: https://skia-review.googlesource.com/94101 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
8008df1080
commit
2ac5868f4a
@ -182,9 +182,6 @@ private:
|
|||||||
|
|
||||||
class GrSurfaceProxy : public GrIORefProxy {
|
class GrSurfaceProxy : public GrIORefProxy {
|
||||||
public:
|
public:
|
||||||
// DDL TODO: remove this entry point
|
|
||||||
static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>, GrSurfaceOrigin);
|
|
||||||
|
|
||||||
enum class LazyState {
|
enum class LazyState {
|
||||||
kNot, // The proxy has no lazy callback that must be made.
|
kNot, // The proxy has no lazy callback that must be made.
|
||||||
kPartially, // The proxy has a lazy callback but knows basic information about itself.
|
kPartially, // The proxy has a lazy callback but knows basic information about itself.
|
||||||
|
@ -40,11 +40,11 @@ GrProxyProvider::~GrProxyProvider() {
|
|||||||
SkASSERT(!fUniquelyKeyedProxies.count());
|
SkASSERT(!fUniquelyKeyedProxies.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
|
bool GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
|
||||||
ASSERT_SINGLE_OWNER
|
ASSERT_SINGLE_OWNER
|
||||||
SkASSERT(key.isValid());
|
SkASSERT(key.isValid());
|
||||||
if (this->isAbandoned() || !proxy) {
|
if (this->isAbandoned() || !proxy) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is already a GrResource with this key then the caller has violated the normal
|
// 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() &&
|
if (SkBudgeted::kNo == proxy->isBudgeted() &&
|
||||||
(!proxy->priv().isInstantiated() ||
|
(!proxy->priv().isInstantiated() ||
|
||||||
!proxy->priv().peekSurface()->resourcePriv().refsWrappedObjects())) {
|
!proxy->priv().peekSurface()->resourcePriv().refsWrappedObjects())) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(!fUniquelyKeyedProxies.find(key)); // multiple proxies can't get the same key
|
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);
|
proxy->cacheAccess().setUniqueKey(this, key);
|
||||||
SkASSERT(proxy->getUniqueKey() == key);
|
SkASSERT(proxy->getUniqueKey() == key);
|
||||||
fUniquelyKeyedProxies.add(proxy);
|
fUniquelyKeyedProxies.add(proxy);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrProxyProvider::adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface* surf) {
|
void GrProxyProvider::adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface* surf) {
|
||||||
@ -101,6 +102,20 @@ sk_sp<GrTextureProxy> GrProxyProvider::findProxyByUniqueKey(const GrUniqueKey& k
|
|||||||
return result;
|
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,
|
sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniqueKey& key,
|
||||||
GrSurfaceOrigin origin) {
|
GrSurfaceOrigin origin) {
|
||||||
ASSERT_SINGLE_OWNER
|
ASSERT_SINGLE_OWNER
|
||||||
@ -122,9 +137,9 @@ sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniq
|
|||||||
sk_sp<GrTexture> texture(static_cast<GrSurface*>(resource)->asTexture());
|
sk_sp<GrTexture> texture(static_cast<GrSurface*>(resource)->asTexture());
|
||||||
SkASSERT(texture);
|
SkASSERT(texture);
|
||||||
|
|
||||||
result = GrSurfaceProxy::MakeWrapped(std::move(texture), origin);
|
result = this->createWrapped(std::move(texture), origin);
|
||||||
SkASSERT(result->getUniqueKey() == key);
|
SkASSERT(result->getUniqueKey() == key);
|
||||||
// MakeWrapped should've added this for us
|
// createWrapped should've added this for us
|
||||||
SkASSERT(fUniquelyKeyedProxies.find(key));
|
SkASSERT(fUniquelyKeyedProxies.find(key));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -144,13 +159,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createInstantiatedProxy(const GrSurfaceDe
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(!tex->getUniqueKey().isValid());
|
return this->createWrapped(std::move(tex), desc.fOrigin);
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(const GrSurfaceDesc& desc,
|
sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(const GrSurfaceDesc& desc,
|
||||||
@ -170,7 +179,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(const GrSurfaceDesc& d
|
|||||||
return nullptr;
|
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);
|
return this->createProxy(desc, SkBackingFit::kExact, budgeted);
|
||||||
@ -225,7 +234,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(
|
|||||||
return nullptr;
|
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,
|
sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& desc,
|
||||||
@ -310,19 +319,27 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& backendTex,
|
sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(
|
||||||
GrSurfaceOrigin origin) {
|
const GrBackendTexture& backendTex,
|
||||||
|
GrSurfaceOrigin origin,
|
||||||
|
GrWrapOwnership ownership,
|
||||||
|
ReleaseProc releaseProc,
|
||||||
|
ReleaseContext releaseCtx) {
|
||||||
if (this->isAbandoned()) {
|
if (this->isAbandoned()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTexture> texture(fResourceProvider->wrapBackendTexture(backendTex));
|
sk_sp<GrTexture> texture(fResourceProvider->wrapBackendTexture(backendTex, ownership));
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (releaseProc) {
|
||||||
|
texture->setRelease(releaseProc, releaseCtx);
|
||||||
|
}
|
||||||
|
|
||||||
SkASSERT(!texture->asRenderTarget()); // Strictly a GrTexture
|
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,
|
sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& tex,
|
||||||
@ -338,7 +355,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackend
|
|||||||
}
|
}
|
||||||
SkASSERT(texture->asRenderTarget()); // A GrTextureRenderTarget
|
SkASSERT(texture->asRenderTarget()); // A GrTextureRenderTarget
|
||||||
|
|
||||||
return GrSurfaceProxy::MakeWrapped(std::move(texture), origin);
|
return this->createWrapped(std::move(texture), origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrSurfaceProxy> GrProxyProvider::createWrappedRenderTargetProxy(
|
sk_sp<GrSurfaceProxy> GrProxyProvider::createWrappedRenderTargetProxy(
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
* Assigns a unique key to a proxy. The proxy will be findable via this key using
|
* Assigns a unique key to a proxy. The proxy will be findable via this key using
|
||||||
* findProxyByUniqueKey(). It is an error if an existing proxy already has a key.
|
* findProxyByUniqueKey(). It is an error if an existing proxy already has a key.
|
||||||
*/
|
*/
|
||||||
void assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
|
bool assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets the unique key of the provided proxy to the unique key of the surface. The surface must
|
* Sets the unique key of the provided proxy to the unique key of the surface. The surface must
|
||||||
@ -102,10 +102,17 @@ public:
|
|||||||
sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc&, SkBackingFit, SkBudgeted,
|
sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc&, SkBackingFit, SkBudgeted,
|
||||||
uint32_t flags = 0);
|
uint32_t flags = 0);
|
||||||
|
|
||||||
|
// These match the definitions in SkImage & GrTexture.h, for whence they came
|
||||||
|
typedef void* ReleaseContext;
|
||||||
|
typedef void (*ReleaseProc)(ReleaseContext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a texture proxy that wraps a (non-renderable) backend texture.
|
* Create a texture proxy that wraps a (non-renderable) backend texture.
|
||||||
*/
|
*/
|
||||||
sk_sp<GrTextureProxy> createWrappedTextureProxy(const GrBackendTexture&, GrSurfaceOrigin);
|
sk_sp<GrTextureProxy> createWrappedTextureProxy(const GrBackendTexture&, GrSurfaceOrigin,
|
||||||
|
GrWrapOwnership = kBorrow_GrWrapOwnership,
|
||||||
|
ReleaseProc = nullptr,
|
||||||
|
ReleaseContext = nullptr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a texture proxy that wraps a backend texture and is both texture-able and renderable
|
* Create a texture proxy that wraps a backend texture and is both texture-able and renderable
|
||||||
@ -188,6 +195,8 @@ public:
|
|||||||
void removeAllUniqueKeys();
|
void removeAllUniqueKeys();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
sk_sp<GrTextureProxy> createWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin);
|
||||||
|
|
||||||
struct UniquelyKeyedProxyHashTraits {
|
struct UniquelyKeyedProxyHashTraits {
|
||||||
static const GrUniqueKey& GetKey(const GrTextureProxy& p) { return p.getUniqueKey(); }
|
static const GrUniqueKey& GetKey(const GrTextureProxy& p) { return p.getUniqueKey(); }
|
||||||
|
|
||||||
|
@ -228,28 +228,6 @@ GrTextureOpList* GrSurfaceProxy::getLastTextureOpList() {
|
|||||||
return fLastOpList ? fLastOpList->asTextureOpList() : nullptr;
|
return fLastOpList ? fLastOpList->asTextureOpList() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) {
|
|
||||||
if (!tex) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tex->getUniqueKey().isValid()) {
|
|
||||||
// The proxy may already be in the hash. Thus we need to look for it first before creating
|
|
||||||
// new one.
|
|
||||||
GrProxyProvider* provider = tex->getContext()->contextPriv().proxyProvider();
|
|
||||||
sk_sp<GrTextureProxy> proxy = provider->findProxyByUniqueKey(tex->getUniqueKey(), origin);
|
|
||||||
if (proxy) {
|
|
||||||
return proxy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tex->asRenderTarget()) {
|
|
||||||
return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin));
|
|
||||||
} else {
|
|
||||||
return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int GrSurfaceProxy::worstCaseWidth() const {
|
int GrSurfaceProxy::worstCaseWidth() const {
|
||||||
SkASSERT(LazyState::kFully != this->lazyInstantiationState());
|
SkASSERT(LazyState::kFully != this->lazyInstantiationState());
|
||||||
if (fTarget) {
|
if (fTarget) {
|
||||||
|
@ -131,8 +131,10 @@ void GrTextureProxy::setUniqueKey(GrProxyProvider* proxyProvider, const GrUnique
|
|||||||
SkASSERT(key.isValid());
|
SkASSERT(key.isValid());
|
||||||
SkASSERT(!fUniqueKey.isValid()); // proxies can only ever get one uniqueKey
|
SkASSERT(!fUniqueKey.isValid()); // proxies can only ever get one uniqueKey
|
||||||
|
|
||||||
if (fTarget && !fTarget->getUniqueKey().isValid()) {
|
if (fTarget) {
|
||||||
|
if (!fTarget->getUniqueKey().isValid()) {
|
||||||
fTarget->resourcePriv().setUniqueKey(key);
|
fTarget->resourcePriv().setUniqueKey(key);
|
||||||
|
}
|
||||||
SkASSERT(fTarget->getUniqueKey() == key);
|
SkASSERT(fTarget->getUniqueKey() == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,17 +284,9 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrResourceProvider* resourceProvider = ctx->contextPriv().resourceProvider();
|
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
|
||||||
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createWrappedTextureProxy(
|
||||||
sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(backendTex, ownership);
|
backendTex, origin, ownership, releaseProc, releaseCtx);
|
||||||
if (!tex) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
if (releaseProc) {
|
|
||||||
tex->setRelease(releaseProc, releaseCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex), origin));
|
|
||||||
|
|
||||||
return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID,
|
return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID,
|
||||||
at, std::move(proxy), std::move(colorSpace), SkBudgeted::kNo);
|
at, std::move(proxy), std::move(colorSpace), SkBudgeted::kNo);
|
||||||
|
@ -43,8 +43,7 @@ static GrSurfaceDesc make_desc(GrSurfaceFlags flags) {
|
|||||||
// Basic test
|
// Basic test
|
||||||
|
|
||||||
static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
|
static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
|
||||||
GrContext* context, SkBackingFit fit) {
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
||||||
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
|
|
||||||
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
|
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
|
||||||
@ -54,8 +53,7 @@ static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
|
static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
|
||||||
GrContext* context, SkBackingFit fit) {
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
||||||
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
|
|
||||||
const GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
|
const GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
|
||||||
@ -65,8 +63,7 @@ static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter,
|
static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter,
|
||||||
GrContext* context, SkBackingFit fit) {
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
||||||
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
|
|
||||||
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
|
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy(desc, fit,
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy(desc, fit,
|
||||||
@ -77,9 +74,7 @@ static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
|
static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
|
||||||
GrContext* context, SkBackingFit fit) {
|
GrProxyProvider* proxyProvider, SkBackingFit fit) {
|
||||||
GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
|
|
||||||
|
|
||||||
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
|
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
|
||||||
static int kUniqueKeyData = 0;
|
static int kUniqueKeyData = 0;
|
||||||
|
|
||||||
@ -91,18 +86,10 @@ static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
|
|||||||
|
|
||||||
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
|
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
|
||||||
|
|
||||||
sk_sp<GrTexture> tex;
|
|
||||||
if (SkBackingFit::kApprox == fit) {
|
|
||||||
tex = sk_sp<GrTexture>(resourceProvider->createApproxTexture(desc, 0));
|
|
||||||
} else {
|
|
||||||
// Only budgeted & wrapped external proxies get to carry uniqueKeys
|
// Only budgeted & wrapped external proxies get to carry uniqueKeys
|
||||||
tex = resourceProvider->createTexture(desc, SkBudgeted::kYes);
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy(desc, fit,
|
||||||
}
|
SkBudgeted::kYes, 0);
|
||||||
|
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
|
||||||
tex->resourcePriv().setUniqueKey(key);
|
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex),
|
|
||||||
kBottomLeft_GrSurfaceOrigin);
|
|
||||||
REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
|
REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
@ -147,7 +134,7 @@ static void basic_test(GrContext* context,
|
|||||||
|
|
||||||
// Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
|
// Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
|
||||||
REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
|
REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
|
||||||
proxyProvider->assignUniqueKeyToProxy(key, proxy.get());
|
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
||||||
@ -265,8 +252,8 @@ static void invalidation_and_instantiation_test(GrContext* context, skiatest::Re
|
|||||||
builder.finish();
|
builder.finish();
|
||||||
|
|
||||||
// Create proxy, assign unique key
|
// Create proxy, assign unique key
|
||||||
sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, SkBackingFit::kExact);
|
sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, proxyProvider, SkBackingFit::kExact);
|
||||||
proxyProvider->assignUniqueKeyToProxy(key, proxy.get());
|
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
|
||||||
|
|
||||||
// Send an invalidation message, which will be sitting in the cache's inbox
|
// Send an invalidation message, which will be sitting in the cache's inbox
|
||||||
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(GrUniqueKeyInvalidatedMessage(key));
|
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(GrUniqueKeyInvalidatedMessage(key));
|
||||||
@ -302,7 +289,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
|
|||||||
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
||||||
for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
|
for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
|
||||||
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
||||||
basic_test(context, reporter, create(reporter, context, fit), true);
|
basic_test(context, reporter, create(reporter, proxyProvider, fit), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
||||||
|
Loading…
Reference in New Issue
Block a user