diff options
Diffstat (limited to 'src/gpu/GrProxyProvider.cpp')
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 6641bcf9a8..e453246b62 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -315,15 +315,38 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc, uint32_t flags) { SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags); - if (!this->caps()->validateSurfaceDesc(desc, GrMipMapped::kNo)) { + const GrCaps* caps = this->caps(); + + // TODO: move this logic into GrResourceProvider! + // TODO: share this testing code with check_texture_creation_params + if (!caps->isConfigTexturable(desc.fConfig)) { return nullptr; } - GrSurfaceDesc copyDesc = desc; - if (desc.fFlags & kRenderTarget_GrSurfaceFlag) { - copyDesc.fSampleCnt = - this->caps()->getRenderTargetSampleCount(desc.fSampleCnt, desc.fConfig); + + bool willBeRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); + if (willBeRT && !caps->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { + return nullptr; } + // We currently do not support multisampled textures + if (!willBeRT && desc.fSampleCnt > 0) { + return nullptr; + } + + int maxSize; + if (willBeRT) { + maxSize = caps->maxRenderTargetSize(); + } else { + maxSize = caps->maxTextureSize(); + } + + if (desc.fWidth > maxSize || desc.fHeight > maxSize || desc.fWidth <= 0 || desc.fHeight <= 0) { + return nullptr; + } + + GrSurfaceDesc copyDesc = desc; + copyDesc.fSampleCnt = caps->getSampleCount(desc.fSampleCnt, desc.fConfig); + #ifdef SK_DISABLE_DEFERRED_PROXIES // Temporarily force instantiation for crbug.com/769760 and crbug.com/769898 sk_sp<GrTexture> tex; @@ -340,11 +363,11 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc, return GrSurfaceProxy::MakeWrapped(std::move(tex), copyDesc.fOrigin); #else - if (copyDesc.fFlags & kRenderTarget_GrSurfaceFlag) { + if (willBeRT) { // We know anything we instantiate later from this deferred path will be // both texturable and renderable - return sk_sp<GrTextureProxy>( - new GrTextureRenderTargetProxy(*this->caps(), copyDesc, fit, budgeted, flags)); + return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*caps, copyDesc, fit, + budgeted, flags)); } return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags)); @@ -484,7 +507,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createFullyLazyProxy(LazyInstantiateCallb desc.fWidth = -1; desc.fHeight = -1; desc.fConfig = config; - desc.fSampleCnt = 1; + desc.fSampleCnt = 0; return this->createLazyProxy(std::move(callback), desc, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes); |