Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5d156ad

Browse files
rphilliSkia Commit-Bot
authored and
Skia Commit-Bot
committed
Fix a bug in SkGpuBlurUtils::GaussianBlur
This fixes the remaining imageblurclampmode bug and a preexisting un-reported error in the imageblurrepeatmode GM. Bug: skia:7765 Change-Id: Ib7e8d21ea67e6b2d7088d5e57bec34e159a36fd2 Reviewed-on: https://skia-review.googlesource.com/125383 Reviewed-by: Greg Daniel <[email protected]> Commit-Queue: Robert Phillips <[email protected]>
1 parent 0b510fb commit 5d156ad

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/core/SkGpuBlurUtils.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static sk_sp<GrRenderTargetContext> convolve_gaussian(GrContext* context,
161161
Direction direction,
162162
int radius,
163163
float sigma,
164-
const SkIRect& srcBounds,
164+
SkIRect* contentRect,
165165
GrTextureDomain::Mode mode,
166166
const SkImageInfo& dstII,
167167
SkBackingFit fit) {
@@ -184,18 +184,19 @@ static sk_sp<GrRenderTargetContext> convolve_gaussian(GrContext* context,
184184
int bounds[2] = { 0, 0 };
185185
SkIRect dstRect = SkIRect::MakeWH(srcRect.width(), srcRect.height());
186186
if (GrTextureDomain::kIgnore_Mode == mode) {
187+
*contentRect = dstRect;
187188
convolve_gaussian_1d(dstRenderTargetContext.get(), clip, dstRect, srcOffset,
188189
std::move(proxy), direction, radius, sigma,
189190
GrTextureDomain::kIgnore_Mode, bounds);
190191
return dstRenderTargetContext;
191192
}
192193

193-
SkIRect midRect = srcBounds, leftRect, rightRect;
194+
SkIRect midRect = *contentRect, leftRect, rightRect;
194195
midRect.offset(srcOffset);
195196
SkIRect topRect, bottomRect;
196197
if (Direction::kX == direction) {
197-
bounds[0] = srcBounds.left();
198-
bounds[1] = srcBounds.right();
198+
bounds[0] = contentRect->left();
199+
bounds[1] = contentRect->right();
199200
topRect = SkIRect::MakeLTRB(0, 0, dstRect.right(), midRect.top());
200201
bottomRect = SkIRect::MakeLTRB(0, midRect.bottom(), dstRect.right(), dstRect.bottom());
201202
midRect.inset(radius, 0);
@@ -204,9 +205,14 @@ static sk_sp<GrRenderTargetContext> convolve_gaussian(GrContext* context,
204205
SkIRect::MakeLTRB(midRect.right(), midRect.top(), dstRect.width(), midRect.bottom());
205206
dstRect.fTop = midRect.top();
206207
dstRect.fBottom = midRect.bottom();
208+
209+
contentRect->fLeft = dstRect.fLeft;
210+
contentRect->fTop = midRect.fTop;
211+
contentRect->fRight = dstRect.fRight;
212+
contentRect->fBottom = midRect.fBottom;
207213
} else {
208-
bounds[0] = srcBounds.top();
209-
bounds[1] = srcBounds.bottom();
214+
bounds[0] = contentRect->top();
215+
bounds[1] = contentRect->bottom();
210216
topRect = SkIRect::MakeLTRB(0, 0, midRect.left(), dstRect.bottom());
211217
bottomRect = SkIRect::MakeLTRB(midRect.right(), 0, dstRect.right(), dstRect.bottom());
212218
midRect.inset(0, radius);
@@ -215,6 +221,11 @@ static sk_sp<GrRenderTargetContext> convolve_gaussian(GrContext* context,
215221
SkIRect::MakeLTRB(midRect.left(), midRect.bottom(), midRect.right(), dstRect.height());
216222
dstRect.fLeft = midRect.left();
217223
dstRect.fRight = midRect.right();
224+
225+
contentRect->fLeft = midRect.fLeft;
226+
contentRect->fTop = dstRect.fTop;
227+
contentRect->fRight = midRect.fRight;
228+
contentRect->fBottom = dstRect.fBottom;
218229
}
219230
if (!topRect.isEmpty()) {
220231
dstRenderTargetContext->clear(&topRect, 0, GrRenderTargetContext::CanClearFullscreen::kNo);
@@ -488,7 +499,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
488499
scale_irect_roundout(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
489500
if (sigmaX > 0.0f) {
490501
dstRenderTargetContext = convolve_gaussian(context, std::move(srcProxy), srcRect, srcOffset,
491-
Direction::kX, radiusX, sigmaX, localSrcBounds,
502+
Direction::kX, radiusX, sigmaX, &localSrcBounds,
492503
mode, finalDestII, xFit);
493504
if (!dstRenderTargetContext) {
494505
return nullptr;
@@ -508,17 +519,12 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
508519
}
509520

510521
srcRect.offsetTo(0, 0);
511-
localSrcBounds = srcRect;
512-
if (GrTextureDomain::kClamp_Mode == mode) {
513-
// We need to adjust bounds because we only fill part of the srcRect in x-pass.
514-
localSrcBounds.inset(0, radiusY);
515-
}
516522
srcOffset.set(0, 0);
517523
}
518524

519525
if (sigmaY > 0.0f) {
520526
dstRenderTargetContext = convolve_gaussian(context, std::move(srcProxy), srcRect, srcOffset,
521-
Direction::kY, radiusY, sigmaY, localSrcBounds,
527+
Direction::kY, radiusY, sigmaY, &localSrcBounds,
522528
mode, finalDestII, yFit);
523529
if (!dstRenderTargetContext) {
524530
return nullptr;

0 commit comments

Comments
 (0)