Disable caching of GrTextures in promise images.
Leave the code to support it in place until we know if this causes a regression. Change-Id: Ic9f6a42cb83cc82a33a534d3f98cb9aaf11f813f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356998 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
84b0233bb3
commit
9374617a4c
@ -306,30 +306,42 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> tex;
|
||||
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
|
||||
GrUniqueKey key;
|
||||
GrUniqueKey::Builder builder(&key, kDomain, 1, "promise");
|
||||
builder[0] = promiseTexture->uniqueID();
|
||||
builder.finish();
|
||||
// A texture with this key may already exist from a different instance of this lazy
|
||||
// callback. This could happen if the client fulfills a promise image with a texture
|
||||
// that was previously used to fulfill a different promise image.
|
||||
if (auto surf = resourceProvider->findByUniqueKey<GrSurface>(key)) {
|
||||
tex = sk_ref_sp(surf->asTexture());
|
||||
SkASSERT(tex);
|
||||
} else {
|
||||
if ((tex = resourceProvider->wrapBackendTexture(
|
||||
backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
kRead_GrIOType))) {
|
||||
tex->resourcePriv().setUniqueKey(key);
|
||||
} else {
|
||||
static bool kDisableCaching = true;
|
||||
if (kDisableCaching) {
|
||||
tex = resourceProvider->wrapBackendTexture(backendTexture,
|
||||
kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kYes,
|
||||
kRead_GrIOType);
|
||||
if (!tex) {
|
||||
return {};
|
||||
}
|
||||
tex->setRelease(fReleaseHelper);
|
||||
} else {
|
||||
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
|
||||
GrUniqueKey key;
|
||||
GrUniqueKey::Builder builder(&key, kDomain, 1, "promise");
|
||||
builder[0] = promiseTexture->uniqueID();
|
||||
builder.finish();
|
||||
// A texture with this key may already exist from a different instance of this lazy
|
||||
// callback. This could happen if the client fulfills a promise image with a texture
|
||||
// that was previously used to fulfill a different promise image.
|
||||
if (auto surf = resourceProvider->findByUniqueKey<GrSurface>(key)) {
|
||||
tex = sk_ref_sp(surf->asTexture());
|
||||
SkASSERT(tex);
|
||||
} else {
|
||||
if ((tex = resourceProvider->wrapBackendTexture(
|
||||
backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
kRead_GrIOType))) {
|
||||
tex->resourcePriv().setUniqueKey(key);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
// Because we're caching the GrTextureObject we have to use this "idle proc"
|
||||
// mechanism to know when it's safe to delete the underlying backend texture.
|
||||
tex->addIdleProc(std::move(fReleaseHelper));
|
||||
promiseTexture->addKeyToInvalidate(tex->getContext()->priv().contextID(), key);
|
||||
}
|
||||
// Because we're caching the GrTextureObject we have to use this "idle proc" mechanism
|
||||
// to know when it's safe to delete the underlying backend texture.
|
||||
tex->addIdleProc(std::move(fReleaseHelper));
|
||||
promiseTexture->addKeyToInvalidate(tex->getContext()->priv().contextID(), key);
|
||||
fTexture = tex.get();
|
||||
// We need to hold on to the GrTexture in case our proxy gets reinstantiated. However,
|
||||
// we can't unref in our destructor because we may be on another thread then. So we
|
||||
|
Loading…
Reference in New Issue
Block a user