From ff6a7cd4d2da9a8c992a20da01cd439bfb008b5c Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Thu, 10 May 2018 09:42:27 -0400 Subject: Revert "Revert "Don't use GrRRectBlurEffect for large rects when highp is not full float"" This reverts commit 729715298c8af1d2ecc4cbe887eeeb9a1c17c595. Changed std::abs() to SkScalarAbs() and #include "SkScalar.h" Change-Id: I9a02ca1a63eef748f9a11d324e8bb89e14571bc9 Reviewed-on: https://skia-review.googlesource.com/127320 Reviewed-by: Brian Salomon Commit-Queue: Brian Salomon --- src/gpu/effects/GrRectBlurEffect.cpp | 3 ++- src/gpu/effects/GrRectBlurEffect.fp | 14 +++++++++++++- src/gpu/effects/GrRectBlurEffect.h | 13 ++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) (limited to 'src/gpu') 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 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..814dedbafb 100644 --- a/src/gpu/effects/GrRectBlurEffect.fp +++ b/src/gpu/effects/GrRectBlurEffect.fp @@ -8,6 +8,7 @@ @header { #include "GrProxyProvider.h" #include "SkBlurMask.h" + #include "SkScalar.h" } in uniform float4 rect; @@ -84,7 +85,17 @@ uniform half profileSize; @make { static std::unique_ptr 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 (SkScalarAbs(rect.fLeft) > 16000.f || SkScalarAbs(rect.fTop) > 16000.f || + SkScalarAbs(rect.fRight) > 16000.f || SkScalarAbs(rect.fBottom) > 16000.f || + SkScalarAbs(rect.width()) > 16000.f || SkScalarAbs(rect.height()) > 16000.f) { + return nullptr; + } + } int doubleProfileSize = SkScalarCeilToInt(12*sigma); if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) { @@ -142,5 +153,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..8307a49bbe 100644 --- a/src/gpu/effects/GrRectBlurEffect.h +++ b/src/gpu/effects/GrRectBlurEffect.h @@ -14,6 +14,7 @@ #include "GrProxyProvider.h" #include "SkBlurMask.h" +#include "SkScalar.h" #include "GrFragmentProcessor.h" #include "GrCoordTransform.h" class GrRectBlurEffect : public GrFragmentProcessor { @@ -63,7 +64,17 @@ public: float sigma() const { return fSigma; } static std::unique_ptr 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 (SkScalarAbs(rect.fLeft) > 16000.f || SkScalarAbs(rect.fTop) > 16000.f || + SkScalarAbs(rect.fRight) > 16000.f || SkScalarAbs(rect.fBottom) > 16000.f || + SkScalarAbs(rect.width()) > 16000.f || SkScalarAbs(rect.height()) > 16000.f) { + return nullptr; + } + } int doubleProfileSize = SkScalarCeilToInt(12 * sigma); if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) { -- cgit v1.2.3