diff options
author | 2018-02-15 14:55:00 -0500 | |
---|---|---|
committer | 2018-02-20 14:21:43 +0000 | |
commit | 6abda4357ce694a692b5e697b7ac49ec3676b5eb (patch) | |
tree | 55d706cd11f5cf72bb29ca79ab3d939a2448b5f7 /src | |
parent | aa59d61646afa5f90ac2ffd7b022b7979e4e3ed1 (diff) |
Change createWrappedTextureProxy for render targets to use lazy proxies.
Bug: skia:
Change-Id: If5e5e4716dceeedb4c5ad0e8c621f72799d11eb2
Reviewed-on: https://skia-review.googlesource.com/107261
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index e520046e7c..0e72850c96 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -433,20 +433,50 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy( return proxy; } -sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& tex, +sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& backendTex, GrSurfaceOrigin origin, int sampleCnt) { if (this->isAbandoned()) { return nullptr; } - sk_sp<GrTexture> texture(fResourceProvider->wrapRenderableBackendTexture(tex, sampleCnt)); - if (!texture) { - return nullptr; - } - SkASSERT(texture->asRenderTarget()); // A GrTextureRenderTarget + sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, backendTex.config()); + + GrSurfaceDesc desc; + desc.fOrigin = origin; + desc.fWidth = backendTex.width(); + desc.fHeight = backendTex.height(); + desc.fConfig = backendTex.config(); + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fSampleCnt = sampleCnt; + GrMipMapped mipMapped = backendTex.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo; + + sk_sp<GrTextureProxy> proxy = this->createLazyProxy( + [backendTex, sampleCnt] (GrResourceProvider* resourceProvider) { + if (!resourceProvider) { + return sk_sp<GrTexture>(); + } + + sk_sp<GrTexture> tex = resourceProvider->wrapRenderableBackendTexture(backendTex, + sampleCnt); + if (!tex) { + return sk_sp<GrTexture>(); + } + SkASSERT(tex->asRenderTarget()); // A GrTextureRenderTarget + // 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); - return this->createWrapped(std::move(texture), origin); + 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. + if (!proxy->priv().doLazyInstantiation(fResourceProvider)) { + return nullptr; + } + } + return proxy; } sk_sp<GrSurfaceProxy> GrProxyProvider::createWrappedRenderTargetProxy( |