Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 964aa91

Browse files
bsalomonSkia Commit-Bot
authored andcommitted
Simplify adding key in SkImage_Lazy::lockTexturProxyView
Don't try to move listener from one key to another. Ease up on asserts (they're redundant with other asserts) Change-Id: I554e5e44b1b2fb027698cf4286b0f5ea206d93af Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274678 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
1 parent a624a53 commit 964aa91

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

src/image/SkImage_Lazy.cpp

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -414,33 +414,11 @@ GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(GrRecordingContext* ctx,
414414
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
415415
GrSurfaceProxyView view;
416416

417-
auto installKey = [&](const GrSurfaceProxyView& view,
418-
const GrSurfaceProxyView& previouslyKeyedView = {}) {
417+
auto installKey = [&](const GrSurfaceProxyView& view) {
419418
SkASSERT(view && view.asTextureProxy());
420419
if (key.isValid()) {
421-
if (!previouslyKeyedView) {
422-
// We will add an invalidator to the image so that if the path goes away we will
423-
// delete or recycle the mask texture.
424-
auto listener = GrMakeUniqueKeyInvalidationListener(&key, ctx->priv().contextID());
425-
this->addUniqueIDListener(std::move(listener));
426-
} else {
427-
auto previousProxy = previouslyKeyedView.asTextureProxy();
428-
SkASSERT(previousProxy->getUniqueKey() == key);
429-
SkASSERT(view.asTextureProxy()->mipMapped() == GrMipMapped::kYes &&
430-
previousProxy->mipMapped() == GrMipMapped::kNo);
431-
// If we had an previousProxy with a valid key, that means there already is a proxy
432-
// in the cache which matches the key, but it does not have mip levels and we
433-
// require them. Thus we must remove the unique key from that proxy.
434-
SkASSERT(previousProxy->getUniqueKey() == key);
435-
// We should have already put a listener invalidator on previousProxy's key. We
436-
// *may* have already put the listener on our local key. That depends on whether
437-
// previousProxy was created in this call or a previous call.
438-
SkASSERT(previousProxy->getUniqueKey().getCustomData());
439-
if (!key.getCustomData()) {
440-
key.setCustomData(sk_ref_sp(previousProxy->getUniqueKey().getCustomData()));
441-
}
442-
proxyProvider->removeUniqueKeyFromProxy(previousProxy);
443-
}
420+
auto listener = GrMakeUniqueKeyInvalidationListener(&key, ctx->priv().contextID());
421+
this->addUniqueIDListener(std::move(listener));
444422
proxyProvider->assignUniqueKeyToProxy(key, view.asTextureProxy());
445423
}
446424
};
@@ -534,7 +512,8 @@ GrSurfaceProxyView SkImage_Lazy::lockTextureProxyView(GrRecordingContext* ctx,
534512
GrSurfaceProxyView mippedView = GrCopyBaseMipMapToTextureProxy(
535513
ctx, view.proxy(), kTopLeft_GrSurfaceOrigin, srcColorType);
536514
if (mippedView) {
537-
installKey(mippedView, view);
515+
proxyProvider->removeUniqueKeyFromProxy(view.asTextureProxy());
516+
installKey(mippedView);
538517
return mippedView;
539518
}
540519
// We failed to make a mipped proxy with the base copied into it. This could have

0 commit comments

Comments
 (0)