diff options
author | Brian Salomon <bsalomon@google.com> | 2018-05-09 15:10:16 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-09 19:43:01 +0000 |
commit | e0dc9432d8836ec34a3ef90eabc39eadc3d1db90 (patch) | |
tree | e1a80c212be072dcd3f780278d5bf36423e28e26 /src/gpu/effects | |
parent | b5d1f244b2d7a73217a03742d4fffd25ad1427f4 (diff) |
Don't use GrRRectBlurEffect for large rects when highp is not full float
Change-Id: Idf12e0a1fba2d9bd2fab8100bd9319c6ec6115b9
Reviewed-on: https://skia-review.googlesource.com/127049
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrRectBlurEffect.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrRectBlurEffect.fp | 13 | ||||
-rw-r--r-- | src/gpu/effects/GrRectBlurEffect.h | 12 |
3 files changed, 25 insertions, 3 deletions
diff --git a/src/gpu/effects/GrRectBlurEffect.cpp b/src/gpu/effects/GrRectBlurEffect.cpp index f537361cad..219fefa713 100644 --- a/src/gpu/effects/GrRectBlurEffect.cpp +++ b/src/gpu/effects/GrRectBlurEffect.cpp @@ -160,6 +160,7 @@ std::unique_ptr<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTes float sigma = data->fRandom->nextRangeF(3, 8); float width = data->fRandom->nextRangeF(200, 300); float height = data->fRandom->nextRangeF(200, 300); - return GrRectBlurEffect::Make(data->proxyProvider(), SkRect::MakeWH(width, height), sigma); + return GrRectBlurEffect::Make(data->proxyProvider(), *data->caps()->shaderCaps(), + SkRect::MakeWH(width, height), sigma); } #endif diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp index ed9a1e715f..e5a5aad75c 100644 --- a/src/gpu/effects/GrRectBlurEffect.fp +++ b/src/gpu/effects/GrRectBlurEffect.fp @@ -84,7 +84,17 @@ uniform half profileSize; @make { static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider* proxyProvider, + const GrShaderCaps& caps, const SkRect& rect, float sigma) { + if (!caps.floatIs32Bits()) { + // We promote the rect uniform from half to float when it has large values for + // precision. If we don't have full float then fail. + if (abs(rect.fLeft) > 16000 || abs(rect.fTop) > 16000 || + abs(rect.fRight) > 16000 || abs(rect.fBottom) > 16000 || + abs(rect.width()) > 16000 || abs(rect.height()) > 16000) { + return nullptr; + } + } int doubleProfileSize = SkScalarCeilToInt(12*sigma); if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) { @@ -142,5 +152,6 @@ void main() { float sigma = data->fRandom->nextRangeF(3,8); float width = data->fRandom->nextRangeF(200,300); float height = data->fRandom->nextRangeF(200,300); - return GrRectBlurEffect::Make(data->proxyProvider(), SkRect::MakeWH(width, height), sigma); + return GrRectBlurEffect::Make(data->proxyProvider(), *data->caps()->shaderCaps(), + SkRect::MakeWH(width, height), sigma); } diff --git a/src/gpu/effects/GrRectBlurEffect.h b/src/gpu/effects/GrRectBlurEffect.h index 47e9dc3851..42c2829d6d 100644 --- a/src/gpu/effects/GrRectBlurEffect.h +++ b/src/gpu/effects/GrRectBlurEffect.h @@ -63,7 +63,17 @@ public: float sigma() const { return fSigma; } static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider* proxyProvider, - const SkRect& rect, float sigma) { + const GrShaderCaps& caps, const SkRect& rect, + float sigma) { + if (!caps.floatIs32Bits()) { + // We promote the rect uniform from half to float when it has large values for + // precision. If we don't have full float then fail. + if (abs(rect.fLeft) > 16000 || abs(rect.fTop) > 16000 || abs(rect.fRight) > 16000 || + abs(rect.fBottom) > 16000 || abs(rect.width()) > 16000 || + abs(rect.height()) > 16000) { + return nullptr; + } + } int doubleProfileSize = SkScalarCeilToInt(12 * sigma); if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) { |