aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProxyProvider.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-01-30 09:28:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-30 14:50:00 +0000
commit6a0176bf033c780bb92396220db8140f30948345 (patch)
treee1ddcf9e3ca552d5063542d18ce30028e1ca0ca7 /src/gpu/GrProxyProvider.cpp
parentaa71c899fdf55e0a6cce60a2aed1ad904d23646d (diff)
Add ref counted wrapped around GrTexture ReleaseProc
Bug: skia: Change-Id: I0cd11a539fd6b16d4b3f9512694f84e0a429518c Reviewed-on: https://skia-review.googlesource.com/101341 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrProxyProvider.cpp')
-rw-r--r--src/gpu/GrProxyProvider.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index c492062196..5bb58af36f 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -383,15 +383,18 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(
desc.fConfig = backendTex.config();
GrMipMapped mipMapped = backendTex.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+ sk_sp<GrReleaseProcHelper> releaseHelper;
+ if (releaseProc) {
+ releaseHelper.reset(new GrReleaseProcHelper(releaseProc, releaseCtx));
+ }
+
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
- [backendTex, ownership, releaseProc, releaseCtx]
+ [backendTex, ownership, releaseHelper]
(GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) {
if (!resourceProvider) {
- // This lazy proxy was never initialized. If it has a releaseProc we must call
- // it now so that the client knows they can free the underlying backend object.
- if (releaseProc) {
- releaseProc(releaseCtx);
- }
+ // 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.
return sk_sp<GrTexture>();
}
@@ -400,8 +403,10 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(
if (!tex) {
return sk_sp<GrTexture>();
}
- if (releaseProc) {
- tex->setRelease(releaseProc, releaseCtx);
+ 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));
}
SkASSERT(!tex->asRenderTarget()); // Strictly a GrTexture
// Make sure we match how we created the proxy with SkBudgeted::kNo