aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProxyProvider.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-01-23 16:38:14 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-24 15:12:30 +0000
commitf2336e4500769bc0ff6a208289d757581b0ea91a (patch)
tree097f306d11e48aea68f6e2df26f0e3d3ef031c1c /src/gpu/GrProxyProvider.cpp
parent4e69f14814d14fd44aa93404656280b388419265 (diff)
Add lazy proxy's for wrapping backend textures
Bug: skia: Change-Id: I3bb557cefc35312adc9515b5683d2ed747bb4eb3 Reviewed-on: https://skia-review.googlesource.com/96862 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrProxyProvider.cpp')
-rw-r--r--src/gpu/GrProxyProvider.cpp51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index c49f6b8ea0..1267750687 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -330,17 +330,46 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(
return nullptr;
}
- sk_sp<GrTexture> texture(fResourceProvider->wrapBackendTexture(backendTex, ownership));
- if (!texture) {
- return nullptr;
- }
- if (releaseProc) {
- texture->setRelease(releaseProc, releaseCtx);
- }
-
- SkASSERT(!texture->asRenderTarget()); // Strictly a GrTexture
-
- return this->createWrapped(std::move(texture), origin);
+ GrSurfaceDesc desc;
+ desc.fOrigin = origin;
+ desc.fWidth = backendTex.width();
+ desc.fHeight = backendTex.height();
+ desc.fConfig = backendTex.config();
+ GrMipMapped mipMapped = backendTex.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+
+ sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
+ [backendTex, ownership, releaseProc, releaseCtx]
+ (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);
+ }
+ return sk_sp<GrTexture>();
+ }
+
+ sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(backendTex,
+ ownership);
+ if (!tex) {
+ return sk_sp<GrTexture>();
+ }
+ if (releaseProc) {
+ tex->setRelease(releaseProc, releaseCtx);
+ }
+ SkASSERT(!tex->asRenderTarget()); // Strictly a GrTexture
+ // Make sure we match how we created the proxy with SkBudgeted::kNo
+ SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
+
+ return tex;
+ }, desc, mipMapped, SkBackingFit::kExact, SkBudgeted::kNo);
+
+ if (fResourceProvider) {
+ // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however,
+ // we're better off instantiating the proxy immediately here.
+ proxy->priv().doLazyInstantiation(fResourceProvider);
+ }
+ return proxy;
}
sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& tex,