Reland "Revert "Fix tile modes in SkGpuBlurUtils.""
This reverts commit e5865f6f10d969aefbec2dcb6975fbe5c3c6059e.
Reason for revert: some async GMs on some configs look like they are
reading from edges of approx textures.
Original change's description:
> Revert "Revert "Fix tile modes in SkGpuBlurUtils.""
>
> This reverts commit 88d04cb51acfb7d8b92895270fa58e266d9522c6.
>
> Change-Id: I3ca403bb9631a273b5cbe2304c6c3ff9dd01fa89
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289625
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,michaelludwig@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: If6f5917982b8c865161e7f4a566df49cb772989b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290036
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index 8437d54..da7d950 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -140,23 +140,29 @@
int halfWidth,
float gaussianSigma,
GrSamplerState::WrapMode wm,
- const SkIRect& subset,
- const SkIRect* pixelDomain,
+ const int bounds[2],
const GrCaps& caps) {
std::unique_ptr<GrFragmentProcessor> child;
- GrSamplerState sampler(wm, GrSamplerState::Filter::kNearest);
- if (pixelDomain) {
- // Inset because we expect to be invoked at pixel centers.
- SkRect domain = SkRect::Make(*pixelDomain).makeInset(0.5, 0.5f);
+ GrSamplerState sampler;
+ switch (dir) {
+ case Direction::kX: sampler.setWrapModeX(wm); break;
+ case Direction::kY: sampler.setWrapModeY(wm); break;
+ }
+ if (bounds) {
+ SkASSERT(bounds[0] < bounds[1]);
+ SkRect subset;
switch (dir) {
- case Direction::kX: domain.outset(halfWidth, 0); break;
- case Direction::kY: domain.outset(0, halfWidth); break;
+ case Direction::kX:
+ subset = SkRect::MakeLTRB(bounds[0], 0, bounds[1], view.height());
+ break;
+ case Direction::kY:
+ subset = SkRect::MakeLTRB(0, bounds[0], view.width(), bounds[1]);
+ break;
}
child = GrTextureEffect::MakeSubset(std::move(view), alphaType, SkMatrix::I(), sampler,
- SkRect::Make(subset), domain, caps);
+ subset, caps);
} else {
- child = GrTextureEffect::MakeSubset(std::move(view), alphaType, SkMatrix::I(), sampler,
- SkRect::Make(subset), caps);
+ child = GrTextureEffect::Make(std::move(view), alphaType, SkMatrix::I(), sampler, caps);
}
return std::unique_ptr<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(
std::move(child), dir, halfWidth, gaussianSigma));
@@ -214,33 +220,27 @@
GrProcessorTestData* d) {
auto [view, ct, at] = d->randomView();
- Direction dir = d->fRandom->nextBool() ? Direction::kY : Direction::kX;
- SkIRect subset{
- static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)),
- static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)),
- static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)),
- static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)),
- };
- subset.sort();
+ Direction dir;
+ int bounds[2];
+ do {
+ if (d->fRandom->nextBool()) {
+ dir = Direction::kX;
+ bounds[0] = d->fRandom->nextRangeU(0, view.width() - 1);
+ bounds[1] = d->fRandom->nextRangeU(0, view.width() - 1);
+ } else {
+ dir = Direction::kY;
+ bounds[0] = d->fRandom->nextRangeU(0, view.height() - 1);
+ bounds[1] = d->fRandom->nextRangeU(0, view.height() - 1);
+ }
+ } while (bounds[0] == bounds[1]);
+ std::sort(bounds, bounds + 2);
auto wm = static_cast<GrSamplerState::WrapMode>(
d->fRandom->nextULessThan(GrSamplerState::kWrapModeCount));
int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
float sigma = radius / 3.f;
- SkIRect temp;
- SkIRect* domain = nullptr;
- if (d->fRandom->nextBool()) {
- temp = {
- static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)),
- static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)),
- static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)),
- static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)),
- };
- temp.sort();
- domain = &temp;
- }
return GrGaussianConvolutionFragmentProcessor::Make(std::move(view), at, dir, radius, sigma, wm,
- subset, domain, *d->caps());
+ bounds, *d->caps());
}
#endif