Add ability for lazy proxy callback to free captured resources
This will be needed for DDLs that get recorded, but then deleted before
the proxies actually get instantiated.
Bug: skia:
Change-Id: I745366fc7a7edbcd43bc617220d3d4997baa8319
Reviewed-on: https://skia-review.googlesource.com/95101
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index c9da6ce..0408b79 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -83,6 +83,11 @@
}
GrSurfaceProxy::~GrSurfaceProxy() {
+ if (fLazyInstantiateCallback) {
+ // We have an uninstantiated lazy proxy. Call fLazyInstantiateCallback with a nullptr for
+ // the GrResourceProvider to signal the callback should clean itself up.
+ this->fLazyInstantiateCallback(nullptr, nullptr);
+ }
// For this to be deleted the opList that held a ref on it (if there was one) must have been
// deleted. Which would have cleared out this back pointer.
SkASSERT(!fLastOpList);
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index 67098cc..1e0bb29 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -227,6 +227,9 @@
fAtlasLazyProxy = GrSurfaceProxy::MakeFullyLazy(
[this](GrResourceProvider* resourceProvider, GrSurfaceOrigin* outOrigin) {
+ if (!resourceProvider) {
+ return sk_sp<GrTexture>();
+ }
SkASSERT(fHasAtlas);
SkASSERT(!fHasAtlasTransform);