Add ability to remove unique key from proxy and underlying surface.

Bug: skia:
Change-Id: I66b891ce9ca35906fdbddb36f565b35b25825112
Reviewed-on: https://skia-review.googlesource.com/51240
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Greg Daniel 2017-09-26 12:49:26 -04:00 committed by Skia Commit-Bot
parent 98a6216b18
commit cd87140111
18 changed files with 199 additions and 43 deletions

View File

@ -205,7 +205,7 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource
builder.finish();
sk_sp<GrTextureProxy> blurProfile =
resourceProvider->findProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
resourceProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
if (!blurProfile) {
static constexpr int kProfileTextureWidth = 512;
GrSurfaceDesc texDesc;

View File

@ -224,7 +224,7 @@ uniform half4 circleData;
builder.finish();
sk_sp<GrTextureProxy> blurProfile =
resourceProvider->findProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
resourceProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
if (!blurProfile) {
static constexpr int kProfileTextureWidth = 512;
GrSurfaceDesc texDesc;

View File

@ -947,7 +947,7 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
builder[0] = profileSize;
builder.finish();
sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(
sk_sp<GrTextureProxy> blurProfile(resourceProvider->findOrCreateProxyByUniqueKey(
key, kTopLeft_GrSurfaceOrigin));
if (!blurProfile) {
GrSurfaceDesc texDesc;
@ -1118,7 +1118,7 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context,
}
builder.finish();
sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey(
sk_sp<GrTextureProxy> mask(context->resourceProvider()->findOrCreateProxyByUniqueKey(
key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
// TODO: this could be approx but the texture coords will need to be updated

View File

@ -37,7 +37,7 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM
sk_sp<GrTextureProxy> proxy;
if (fOriginalKey.isValid()) {
proxy = this->context()->resourceProvider()->findProxyByUniqueKey(
proxy = this->context()->resourceProvider()->findOrCreateProxyByUniqueKey(
fOriginalKey, kTopLeft_GrSurfaceOrigin);
if (proxy) {
return proxy;

View File

@ -393,7 +393,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context,
GrUniqueKey key;
create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key);
sk_sp<GrTextureProxy> proxy(resourceProvider->findProxyByUniqueKey(
sk_sp<GrTextureProxy> proxy(resourceProvider->findOrCreateProxyByUniqueKey(
key, kBottomLeft_GrSurfaceOrigin));
if (proxy) {
return proxy;
@ -505,7 +505,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask(
GrUniqueKey key;
create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key);
sk_sp<GrTextureProxy> proxy(context->resourceProvider()->findProxyByUniqueKey(
sk_sp<GrTextureProxy> proxy(context->resourceProvider()->findOrCreateProxyByUniqueKey(
key, kTopLeft_GrSurfaceOrigin));
if (proxy) {
return proxy;

View File

@ -852,6 +852,15 @@ bool GrResourceCache::isInCache(const GrGpuResource* resource) const {
#endif
void GrResourceCache::adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface* surf) {
SkASSERT(surf->getUniqueKey().isValid());
proxy->cacheAccess().setUniqueKey(this, surf->getUniqueKey());
SkASSERT(proxy->getUniqueKey() == surf->getUniqueKey());
// multiple proxies can't get the same key
SkASSERT(!fUniquelyKeyedProxies.find(surf->getUniqueKey()));
fUniquelyKeyedProxies.add(proxy);
}
void GrResourceCache::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
SkASSERT(key.isValid());
SkASSERT(proxy);
@ -884,6 +893,14 @@ sk_sp<GrTextureProxy> GrResourceCache::findProxyByUniqueKey(const GrUniqueKey& k
sk_sp<GrTextureProxy> result = sk_ref_sp(fUniquelyKeyedProxies.find(key));
if (result) {
SkASSERT(result->origin() == origin);
}
return result;
}
sk_sp<GrTextureProxy> GrResourceCache::findOrCreateProxyByUniqueKey(const GrUniqueKey& key,
GrSurfaceOrigin origin) {
sk_sp<GrTextureProxy> result = this->findProxyByUniqueKey(key, origin);
if (result) {
return result;
}
@ -897,7 +914,8 @@ sk_sp<GrTextureProxy> GrResourceCache::findProxyByUniqueKey(const GrUniqueKey& k
result = GrSurfaceProxy::MakeWrapped(std::move(texture), origin);
SkASSERT(result->getUniqueKey() == key);
fUniquelyKeyedProxies.add(result.get());
// MakeWrapped should've added this for us
SkASSERT(fUniquelyKeyedProxies.find(key));
return result;
}
@ -906,8 +924,24 @@ void GrResourceCache::processInvalidProxyUniqueKey(const GrUniqueKey& key) {
// will not be in 'fUniquelyKeyedProxies'.
GrTextureProxy* proxy = fUniquelyKeyedProxies.find(key);
if (proxy) {
fUniquelyKeyedProxies.remove(key);
proxy->cacheAccess().clearUniqueKey();
this->processInvalidProxyUniqueKey(key, proxy, false);
}
}
void GrResourceCache::processInvalidProxyUniqueKey(const GrUniqueKey& key, GrTextureProxy* proxy,
bool invalidateSurface) {
SkASSERT(proxy);
SkASSERT(proxy->getUniqueKey().isValid());
SkASSERT(proxy->getUniqueKey() == key);
fUniquelyKeyedProxies.remove(key);
proxy->cacheAccess().clearUniqueKey();
if (invalidateSurface && proxy->priv().isInstantiated()) {
GrSurface* surface = proxy->priv().peekSurface();
if (surface) {
surface->resourcePriv().removeUniqueKey();
}
}
}

View File

@ -160,8 +160,9 @@ public:
///////////////////////////////////////////////////////////////////////////
// TextureProxies & GrUniqueKeys
//
// The two GrResourceCache methods assignUniqueKeyToProxy and findProxyByUniqueKey drive
// the behavior of uniqueKeys on proxies.
// The four GrResourceCache methods assignUniqueKeyToProxy, adoptUniqueKeyFromSurface,
// findPorxyByUniqueKey, and findOrCreateProxyByUniqueKey drive the behavior of uniqueKeys on
// proxies.
//
// assignUniqueKeyToProxy does the following:
// if the proxy is wrapped, it sets the texture & proxy keys & adds the proxy to the hash
@ -174,8 +175,16 @@ public:
// determines that the key will never be used again but, in that case, the proxy should
// never receive another key.
//
// adoptUniqueKeyFromSurface does the following:
// takes in a GrSurface which must have a valid unique key. It sets the proxy's key to match
// the surface and adds the proxy to the hash.
//
// findProxyByUniqueKey does the following:
// first looks in the UniqueKeyProxy hash table to see if there is already a proxy w/ the key
// looks in the UniqueKeyProxy hash table to see if there is already a proxy w/ the key and
// returns the proxy. If it fails it will return null.
//
// findOrCreateProxyByUniqueKey does the following:
// first calls findProxyByUniqueKey to see if a proxy already exists with the key
// failing that it looks in the ResourceCache to see there is a texture with that key
// if so, it will wrap the texture in a proxy, add the proxy to the hash and return it
// failing that it will return null
@ -185,11 +194,25 @@ public:
*/
void assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
/*
* Sets the unique key of the provided proxy to the unique key of the surface. The surface must
* have a valid unique key.
*/
void adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface*);
/**
* Find a texture proxy that is associated with the provided unique key.
* Find a texture proxy that is associated with the provided unique key. It will not look for a
* GrSurface that has the unique key.
*/
sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
/**
* Find a texture proxy that is associated with the provided unique key. If not proxy is found,
* try to find a resources that is associated with the unique key and create a proxy that wraps
* it.
*/
sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
/**
* Either the proxy attached to the unique key is being deleted (in which case we
* don't want it cluttering up the hash table) or the client has indicated that
@ -199,6 +222,13 @@ public:
*/
void processInvalidProxyUniqueKey(const GrUniqueKey&);
/**
* Same as above, but you must pass in a GrTextureProxy to save having to search for it. The
* GrUniqueKey of the proxy must be valid and it must match the passed in key. This function
* also gives the option to invalidate the GrUniqueKey on the underlying GrTexture.
*/
void processInvalidProxyUniqueKey(const GrUniqueKey&, GrTextureProxy*, bool invalidateSurface);
/**
* Query whether a unique key exists in the cache.
*/

View File

@ -276,6 +276,14 @@ void GrResourceProvider::assignUniqueKeyToResource(const GrUniqueKey& key,
resource->resourcePriv().setUniqueKey(key);
}
void GrResourceProvider::removeUniqueKeyFromProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned() || !proxy) {
return;
}
fCache->processInvalidProxyUniqueKey(key, proxy, true);
}
GrGpuResource* GrResourceProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) {
ASSERT_SINGLE_OWNER
return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key);
@ -313,6 +321,12 @@ sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey
return this->isAbandoned() ? nullptr : fCache->findProxyByUniqueKey(key, origin);
}
sk_sp<GrTextureProxy> GrResourceProvider::findOrCreateProxyByUniqueKey(const GrUniqueKey& key,
GrSurfaceOrigin origin) {
ASSERT_SINGLE_OWNER
return this->isAbandoned() ? nullptr : fCache->findOrCreateProxyByUniqueKey(key, origin);
}
const GrBuffer* GrResourceProvider::createPatternedIndexBuffer(const uint16_t* pattern,
int patternSize,
int reps,

View File

@ -51,11 +51,23 @@ public:
*/
void assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
/*
* Removes a unique key from a proxy. If the proxy has already been instantiated, it will
* also remove the unique key from the target GrSurface.
*/
void removeUniqueKeyFromProxy(const GrUniqueKey&, GrTextureProxy*);
/*
* Finds a proxy by unique key.
*/
sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
/*
* Finds a proxy by unique key or creates a new one that wraps a resource matching the unique
* key.
*/
sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
///////////////////////////////////////////////////////////////////////////
// Textures

View File

@ -290,7 +290,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
sk_sp<GrTextureProxy> proxy;
if (useCache) {
proxy = fResourceProvider->findProxyByUniqueKey(maskKey, kTopLeft_GrSurfaceOrigin);
proxy = fResourceProvider->findOrCreateProxyByUniqueKey(maskKey, kTopLeft_GrSurfaceOrigin);
}
if (!proxy) {
SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox;

View File

@ -182,6 +182,16 @@ sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf, GrSurfa
return nullptr;
}
if (surf->getUniqueKey().isValid()) {
// The proxy may already be in the hash. Thus we need to look for it first before creating
// new one.
GrResourceProvider* provider = surf->getContext()->resourceProvider();
sk_sp<GrSurfaceProxy> proxy = provider->findProxyByUniqueKey(surf->getUniqueKey(), origin);
if (proxy) {
return proxy;
}
}
if (surf->asTexture()) {
if (surf->asRenderTarget()) {
return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf), origin));
@ -201,6 +211,16 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfac
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.
GrResourceProvider* provider = tex->getContext()->resourceProvider();
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 {

View File

@ -46,8 +46,9 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
GrUniqueKey key;
this->makeCopyKey(copyParams, &key, nullptr);
if (key.isValid()) {
sk_sp<GrTextureProxy> cachedCopy = fContext->resourceProvider()->findProxyByUniqueKey(
key, this->originalProxy()->origin());
sk_sp<GrTextureProxy> cachedCopy =
fContext->resourceProvider()->findOrCreateProxyByUniqueKey(
key, this->originalProxy()->origin());
if (cachedCopy) {
return cachedCopy;
}

View File

@ -50,7 +50,7 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerSt
} else {
origOrigin = kTopLeft_GrSurfaceOrigin;
}
sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findProxyByUniqueKey(
sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findOrCreateProxyByUniqueKey(
copyKey, origOrigin));
if (result) {
return result;

View File

@ -28,8 +28,8 @@ GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin)
, fMipColorMode(fTarget->asTexture()->texturePriv().mipColorMode())
, fCache(nullptr) {
if (fTarget->getUniqueKey().isValid()) {
fUniqueKey = fTarget->getUniqueKey();
fCache = fTarget->asTexture()->getContext()->getResourceCache();
fCache->adoptUniqueKeyFromSurface(this, fTarget);
}
}
@ -38,7 +38,7 @@ GrTextureProxy::~GrTextureProxy() {
// at this point. Zero out the pointer so the cache invalidation code doesn't try to use it.
fTarget = nullptr;
if (fUniqueKey.isValid()) {
fCache->processInvalidProxyUniqueKey(fUniqueKey);
fCache->processInvalidProxyUniqueKey(fUniqueKey, this, false);
} else {
SkASSERT(!fCache);
}
@ -97,8 +97,7 @@ void GrTextureProxy::setUniqueKey(GrResourceCache* cache, const GrUniqueKey& key
SkASSERT(key.isValid());
SkASSERT(!fUniqueKey.isValid()); // proxies can only ever get one uniqueKey
if (fTarget) {
SkASSERT(!fTarget->getUniqueKey().isValid());
if (fTarget && !fTarget->getUniqueKey().isValid()) {
fTarget->resourcePriv().setUniqueKey(key);
SkASSERT(fTarget->getUniqueKey() == key);
}

View File

@ -256,7 +256,8 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider* resourceProvid
sk_sp<GrTextureProxy> proxy;
if (originalKey.isValid()) {
proxy = resourceProvider->findProxyByUniqueKey(originalKey, kTopLeft_GrSurfaceOrigin);
proxy = resourceProvider->findOrCreateProxyByUniqueKey(originalKey,
kTopLeft_GrSurfaceOrigin);
}
if (!proxy) {
// Pass nullptr for |dstColorSpace|. This is lenient - we allow a wider range of

View File

@ -207,7 +207,7 @@ void GrTextureStripAtlas::lockTexture() {
builder[0] = static_cast<uint32_t>(fCacheKey);
builder.finish();
sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(
sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findOrCreateProxyByUniqueKey(
key, kTopLeft_GrSurfaceOrigin);
if (!proxy) {
GrSurfaceDesc texDesc;

View File

@ -753,7 +753,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
// 1. Check the cache for a pre-existing one
if (key.isValid()) {
if (sk_sp<GrTextureProxy> proxy = ctx->resourceProvider()->findProxyByUniqueKey(
if (sk_sp<GrTextureProxy> proxy = ctx->resourceProvider()->findOrCreateProxyByUniqueKey(
key, kTopLeft_GrSurfaceOrigin)) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath,
kLockTexturePathCount);

View File

@ -41,21 +41,30 @@ static GrSurfaceDesc make_desc(GrSurfaceFlags flags) {
///////////////////////////////////////////////////////////////////////////////////////////////////
// Basic test
static sk_sp<GrTextureProxy> deferred_tex(GrResourceProvider* provider, SkBackingFit fit) {
static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
GrResourceProvider* provider, SkBackingFit fit) {
GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
return GrSurfaceProxy::MakeDeferred(provider, desc, fit, SkBudgeted::kYes);
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(provider, desc, fit,
SkBudgeted::kYes);
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
static sk_sp<GrTextureProxy> deferred_texRT(GrResourceProvider* provider, SkBackingFit fit) {
static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
GrResourceProvider* provider, SkBackingFit fit) {
GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
return GrSurfaceProxy::MakeDeferred(provider, desc, fit, SkBudgeted::kYes);
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(provider, desc, fit,
SkBudgeted::kYes);
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
static sk_sp<GrTextureProxy> wrapped(GrResourceProvider* provider, SkBackingFit fit) {
static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter,
GrResourceProvider* provider, SkBackingFit fit) {
GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
sk_sp<GrTexture> tex;
@ -66,7 +75,39 @@ static sk_sp<GrTextureProxy> wrapped(GrResourceProvider* provider, SkBackingFit
tex = provider->createTexture(desc, SkBudgeted::kYes);
}
return GrSurfaceProxy::MakeWrapped(std::move(tex), kBottomLeft_GrSurfaceOrigin);
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex),
kBottomLeft_GrSurfaceOrigin);
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
GrResourceProvider* provider, SkBackingFit fit) {
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
static int kUniqueKeyData = 0;
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, d, 1, nullptr);
builder[0] = kUniqueKeyData++;
builder.finish();
GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
tex = sk_sp<GrTexture>(provider->createApproxTexture(desc, 0));
} else {
// Only budgeted & wrapped external proxies get to carry uniqueKeys
tex = provider->createTexture(desc, SkBudgeted::kYes);
}
tex->resourcePriv().setUniqueKey(key);
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex),
kBottomLeft_GrSurfaceOrigin);
REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid());
return proxy;
}
static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
@ -102,15 +143,18 @@ static void basic_test(GrContext* context,
int startCacheCount = cache->getResourceCount();
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
GrUniqueKey key;
GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
++id;
if (proxy->getUniqueKey().isValid()) {
key = proxy->getUniqueKey();
} else {
GrMakeKeyFromImageID(&key, id, SkIRect::MakeWH(64, 64));
++id;
// Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
REPORTER_ASSERT(reporter, !cache->numUniqueKeyProxies_TestOnly());
provider->assignUniqueKeyToProxy(key, proxy.get());
}
// Assigning the uniqueKey adds the proxy to the hash but doesn't force instantiation
REPORTER_ASSERT(reporter, !cache->numUniqueKeyProxies_TestOnly());
provider->assignUniqueKeyToProxy(key, proxy.get());
REPORTER_ASSERT(reporter, 1 == cache->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, startCacheCount == cache->getResourceCount());
@ -118,7 +162,8 @@ static void basic_test(GrContext* context,
REPORTER_ASSERT(reporter, key == proxy->getUniqueKey());
// We just added it, surely we can find it
REPORTER_ASSERT(reporter, provider->findProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin));
REPORTER_ASSERT(reporter, provider->findOrCreateProxyByUniqueKey(key,
kBottomLeft_GrSurfaceOrigin));
REPORTER_ASSERT(reporter, 1 == cache->numUniqueKeyProxies_TestOnly());
// Once instantiated, the backing resource should have the same key
@ -136,7 +181,7 @@ static void basic_test(GrContext* context,
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
// If the proxy was cached refinding it should bring it back to life
proxy = provider->findProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
proxy = provider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
if (proxyIsCached) {
REPORTER_ASSERT(reporter, proxy);
REPORTER_ASSERT(reporter, 1 == cache->numUniqueKeyProxies_TestOnly());
@ -156,7 +201,7 @@ static void basic_test(GrContext* context,
}
// We can bring neither the texture nor proxy back from perma-death
proxy = provider->findProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
proxy = provider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin);
REPORTER_ASSERT(reporter, !proxy);
if (proxyIsCached) {
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
@ -218,9 +263,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto create : { deferred_tex, deferred_texRT, wrapped }) {
for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
basic_test(context, reporter, create(provider, fit), true);
basic_test(context, reporter, create(reporter, provider, fit), true);
}
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());