diff options
author | 2018-04-12 16:50:17 -0400 | |
---|---|---|
committer | 2018-04-12 21:40:11 +0000 | |
commit | 92cbf3fc0112c99ec4aea9d8b7550a2573463262 (patch) | |
tree | 5dcec51815cd729db1f917b13dc5d185c1899a09 /src | |
parent | 5f3ce3e43a56d9739ef5c2c12e889efd8e120659 (diff) |
Don't create lazy proxys if their width/height is greater than max tex size
Bug: skia:
Change-Id: I53508c4e3bbd4c315be4b29a66716e0c5e7f25bf
Reviewed-on: https://skia-review.googlesource.com/121161
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 18 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 7 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 4 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index b65c3dfe17..a4b8d61cf3 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -257,6 +257,10 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag }, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, surfaceFlags, fit, budgeted); + if (!proxy) { + return nullptr; + } + 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. @@ -354,6 +358,10 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, SkBackingFit::kExact, SkBudgeted::kYes); + if (!proxy) { + return nullptr; + } + 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. @@ -539,6 +547,11 @@ sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& LazyInstantiationType lazyType) { SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) || (desc.fWidth > 0 && desc.fHeight > 0)); + + if (desc.fWidth > fCaps->maxTextureSize() || desc.fHeight > fCaps->maxTextureSize()) { + return nullptr; + } + surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO; #ifdef SK_DEBUG @@ -566,6 +579,11 @@ sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy( SkBackingFit fit, SkBudgeted budgeted) { SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) || (desc.fWidth > 0 && desc.fHeight > 0)); + + if (desc.fWidth > fCaps->maxRenderTargetSize() || desc.fHeight > fCaps->maxRenderTargetSize()) { + return nullptr; + } + SkASSERT(SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags)); surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index e162d83f3f..1cf60d8ffd 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4346,6 +4346,10 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in return GrBackendTexture(); // invalid } + if (w > this->caps()->maxTextureSize() || h > this->caps()->maxTextureSize()) { + return GrBackendTexture(); // invalid + } + // Currently we don't support uploading pixel data when mipped. if (pixels && GrMipMapped::kYes == mipMapped) { return GrBackendTexture(); // invalid @@ -4433,6 +4437,9 @@ void GrGLGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) { GrBackendRenderTarget GrGLGpu::createTestingOnlyBackendRenderTarget(int w, int h, GrColorType colorType, GrSRGBEncoded srgbEncoded) { + if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) { + return GrBackendRenderTarget(); // invalid + } this->handleDirtyContext(); auto config = GrColorTypeToPixelConfig(colorType, srgbEncoded); GrGLenum colorBufferFormat; diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 0011a78552..481232ebda 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1555,6 +1555,10 @@ void GrVkGpu::deleteTestingOnlyBackendTexture(const GrBackendTexture& tex) { GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h, GrColorType ct, GrSRGBEncoded srgbEncoded) { + if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) { + return GrBackendRenderTarget(); + } + this->handleDirtyContext(); GrVkImageInfo info; auto config = GrColorTypeToPixelConfig(ct, srgbEncoded); |