diff options
author | Brian Osman <brianosman@google.com> | 2018-04-12 13:29:08 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-12 18:09:10 +0000 |
commit | 875f7851f6be2330c56be304bc78e07517a72d6f (patch) | |
tree | cc0f3661b5abae8716b53dbe516591c81e20edaf /src/gpu | |
parent | 6aab2ab762beb0d255529a914e181e927a8e6307 (diff) |
Fail fast when trying to make a texture that's too large
This saves us from doing lots of throwaway decoding work if the image
can't be uploaded.
This is based on -- but doesn't entirely fix --
https://github.com/flutter/flutter/issues/16454
Change-Id: I4025f31f1334b715a04b4503aeb4f857851b5772
Reviewed-on: https://skia-review.googlesource.com/121104
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrTextureAdjuster.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrTextureMaker.cpp | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp index 306ec59220..f30b0eb03d 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -75,6 +75,9 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxySafeForParams(const GrSa return nullptr; } + SkASSERT(this->width() <= fContext->caps()->maxTextureSize() && + this->height() <= fContext->caps()->maxTextureSize()); + if (!GrGpu::IsACopyNeededForTextureParams(fContext->caps(), proxy.get(), proxy->width(), proxy->height(), params, ©Params, scaleAdjust)) { diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp index 5db0b481b7..62eb04e7ad 100644 --- a/src/gpu/GrTextureMaker.cpp +++ b/src/gpu/GrTextureMaker.cpp @@ -17,6 +17,11 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerSt SkColorSpace* dstColorSpace, sk_sp<SkColorSpace>* texColorSpace, SkScalar scaleAdjust[2]) { + if (this->width() > fContext->caps()->maxTextureSize() || + this->height() > fContext->caps()->maxTextureSize()) { + return nullptr; + } + CopyParams copyParams; bool willBeMipped = params.filter() == GrSamplerState::Filter::kMipMap; |