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>
This commit is contained in:
parent
aa59d61646
commit
6abda4357c
@ -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());
|
||||
|
||||
return this->createWrapped(std::move(texture), origin);
|
||||
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);
|
||||
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user