diff options
Diffstat (limited to 'src/gpu/GrResourceProvider.cpp')
-rw-r--r-- | src/gpu/GrResourceProvider.cpp | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index 3800383581..ec94968e21 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -46,28 +46,6 @@ GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSin fQuadIndexBufferKey = gQuadIndexBufferKey; } -bool validate_desc(const GrSurfaceDesc& desc, const GrCaps& caps, int levelCount = 0) { - if (desc.fWidth <= 0 || desc.fHeight <= 0) { - return false; - } - if (!caps.isConfigTexturable(desc.fConfig)) { - return false; - } - if (desc.fFlags & kRenderTarget_GrSurfaceFlag) { - if (!caps.isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { - return false; - } - } else { - if (desc.fSampleCnt) { - return false; - } - } - if (levelCount > 1 && (GrPixelConfigIsSint(desc.fConfig) || !caps.mipMapSupport())) { - return false; - } - return true; -} - sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const GrMipLevel texels[], int mipLevelCount, SkDestinationSurfaceColorMode mipColorMode) { @@ -79,7 +57,8 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk return nullptr; } - if (!validate_desc(desc, *fCaps, mipLevelCount)) { + GrMipMapped mipMapped = mipLevelCount > 1 ? GrMipMapped::kYes : GrMipMapped::kNo; + if (!fCaps->validateSurfaceDesc(desc, mipMapped)) { return nullptr; } @@ -125,7 +104,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, return nullptr; } - if (!validate_desc(desc, *fCaps)) { + if (!fCaps->validateSurfaceDesc(desc, GrMipMapped::kNo)) { return nullptr; } @@ -157,12 +136,11 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, uint32_t flags) { ASSERT_SINGLE_OWNER - if (this->isAbandoned()) { return nullptr; } - if (!validate_desc(desc, *fCaps)) { + if (!fCaps->validateSurfaceDesc(desc, GrMipMapped::kNo)) { return nullptr; } @@ -183,7 +161,7 @@ sk_sp<GrTexture> GrResourceProvider::createApproxTexture(const GrSurfaceDesc& de return nullptr; } - if (!validate_desc(desc, *fCaps)) { + if (!fCaps->validateSurfaceDesc(desc, GrMipMapped::kNo)) { return nullptr; } @@ -212,7 +190,7 @@ sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc uint32_t flags) { ASSERT_SINGLE_OWNER SkASSERT(!this->isAbandoned()); - SkASSERT(validate_desc(desc, *fCaps)); + SkASSERT(fCaps->validateSurfaceDesc(desc, GrMipMapped::kNo)); // We could make initial clears work with scratch textures but it is a rare case so we just opt // to fall back to making a new texture. |