From 0a375db9a4c1dc96f9d5856526e074ab2802fb0e Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Thu, 1 Feb 2018 12:21:39 -0500 Subject: Have lazy proxies keep their callbacks around and clean up their lambdas in the dtor I believe after this CL we will be at a place where we just have to null out the fTarget of a lazy proxy and it will reinstantiate itself. Bug: skia: Change-Id: I88fdc70e149eba4514a0823da99383583394005c Reviewed-on: https://skia-review.googlesource.com/102021 Commit-Queue: Greg Daniel Reviewed-by: Robert Phillips --- src/gpu/GrProxyProvider.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gpu/GrProxyProvider.cpp') diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 604dd1bb32..ec05243d18 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -217,6 +217,8 @@ sk_sp GrProxyProvider::createTextureProxy(sk_sp srcImag [desc, budgeted, srcImage] (GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) { if (!resourceProvider) { + // Nothing to clean up here. Once the proxy (and thus lambda) is deleted the ref + // on srcImage will be released. return sk_sp(); } SkPixmap pixMap; @@ -396,9 +398,9 @@ sk_sp GrProxyProvider::createWrappedTextureProxy( [backendTex, ownership, releaseHelper] (GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) { if (!resourceProvider) { - // This lazy proxy was never initialized. If this had a releaseHelper it will - // get unrefed when we delete this lambda and will call the release proc so that - // the client knows they can free the underlying backend object. + // If this had a releaseHelper it will get unrefed when we delete this lambda + // and will call the release proc so that the client knows they can free the + // underlying backend object. return sk_sp(); } @@ -408,9 +410,8 @@ sk_sp GrProxyProvider::createWrappedTextureProxy( return sk_sp(); } if (releaseHelper) { - // DDL TODO: once we are reusing lazy proxies, remove this move and hold onto to - // the ref till the lambda goes away. - tex->setRelease(std::move(releaseHelper)); + // This gives the texture a ref on the releaseHelper + tex->setRelease(releaseHelper); } SkASSERT(!tex->asRenderTarget()); // Strictly a GrTexture // Make sure we match how we created the proxy with SkBudgeted::kNo @@ -491,7 +492,6 @@ sk_sp GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& mipMapped, fit, budgeted, flags) : new GrTextureProxy(std::move(callback), desc, mipMapped, fit, budgeted, flags)); - } sk_sp GrProxyProvider::createFullyLazyProxy(LazyInstantiateCallback&& callback, -- cgit v1.2.3