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>
This commit is contained in:
Brian Salomon 2018-05-09 15:10:16 -04:00 committed by Skia Commit-Bot
parent b5d1f244b2
commit e0dc9432d8
4 changed files with 29 additions and 5 deletions

View File

@ -758,7 +758,8 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
SkScalar pad = 3.0f * xformedSigma;
rect.outset(pad, pad);
fp = GrRectBlurEffect::Make(proxyProvider, rect, xformedSigma);
fp = GrRectBlurEffect::Make(proxyProvider, *context->caps()->shaderCaps(), rect,
xformedSigma);
} else if (path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height())) {
fp = GrCircleBlurFragmentProcessor::Make(proxyProvider, rect, xformedSigma);
@ -811,7 +812,8 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
SkScalar pad = 3.0f * xformedSigma;
const SkRect dstCoverageRect = devRRect.rect().makeOutset(pad, pad);
fp = GrRectBlurEffect::Make(proxyProvider, dstCoverageRect, xformedSigma);
fp = GrRectBlurEffect::Make(proxyProvider, *context->caps()->shaderCaps(),
dstCoverageRect, xformedSigma);
} else {
fp = GrCircleBlurFragmentProcessor::Make(proxyProvider,
devRRect.rect(), xformedSigma);

View File

@ -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

View File

@ -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);
}

View File

@ -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()) {