Inset blur domain a tiny bit to prevent certain GPUs from sampling transparent black from scratch textures.

When running Skia GPU blur on an iPhone X, I noticed a bit a of transparency seeping into my clamped blur on the right and/or bottom edges of certain-sized rectangular blurs with large blur radii.

I could only repro this on an iPhone X; I couldn't repro on a retina Macbook Pro or a 1x external screen.

I think the iPhone X GPU is rounding the sampling coordinate a little differently than most other GPUs or there's some floating point error involved in the shader that makes it sample pixels outside of the desired blur domain. Since the blur source is inside a scratch texture filled with transparent black, some undesirable transparent black gets pulled in when we're decimating and blurring the source.

Bug: https://bugs.chromium.org/p/skia/issues/detail?id=8942

Change-Id: Iff28c3ee5d069c6999a831d4b156a650be3a9eb8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205208
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Max Vujovic 2019-04-01 11:35:28 -07:00 committed by Skia Commit-Bot
parent 215da624d1
commit 730c53ae3c

View File

@ -319,8 +319,8 @@ static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
: mode;
SkRect domain = SkRect::Make(*contentRect);
domain.inset((i < scaleFactorX) ? SK_ScalarHalf : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf : 0.0f);
domain.inset((i < scaleFactorX) ? SK_ScalarHalf + SK_ScalarNearlyZero : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf + SK_ScalarNearlyZero : 0.0f);
auto fp = GrTextureDomainEffect::Make(std::move(src),
SkMatrix::I(),
domain,