Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Issue 23011012: Implement correct clipping for image filters. (Closed)

Created:
7 years, 4 months ago by Stephen White
Modified:
6 years, 10 months ago
Reviewers:
robertphillips, reed1
CC:
skia-review_googlegroups.com, robertphillips
Visibility:
Public.

Description

Implement correct clipping for image filters. Image filters in Skia currently clip the size of the the offscreen bitmap used for filtering to the device clip bounds. This means that any pixel-moving filter (e.g., blur) has edge artifacts at the clip boundaries. This is problematic for tiling, where a single SkPicture is played back with a clip set to the tile boundaries. By implementing the onFilterBounds() traversal, and using it in saveLayer() when a filter is present, we can clip the layer to the expanded clip rect. Note that this requires that the traversal be performed in reverse as compared to computeFastBounds(). (It's also done in device space, unlike computeFastBounds()). New test imagefiltersclipped tests pixel-moving filters when clipped by various clip rects. New test imageblurtiled tests tiled (compositor-style) rendering of blurred text. There should be no artifacts at the tile boundaries. BUG=337831 R=reed@google.com Committed: https://code.google.com/p/skia/source/detail?r=13323

Patch Set 1 #

Patch Set 2 : Add filterBounds() support for all primitives which were computing fast bounds. #

Patch Set 3 : Add filterBounds() support for SkColorFilterImageFilter. #

Patch Set 4 : Updated to ToT #

Patch Set 5 : Updated to ToT; provided base class SkImageFilter::onFilterBounds() #

Patch Set 6 : implement onFilterBounds() for all filters; move its application to SkCanvas::clipRectBounds(); add… #

Patch Set 7 : Copyright hygiene #

Patch Set 8 : Cleanup #

Total comments: 8

Patch Set 9 : Changes re: review comments #

Patch Set 10 : Win build fixes; round -> ceil (pessimism) fixes #

Patch Set 11 : Add morphology to the list of ignored tests #

Unified diffs Side-by-side diffs Delta from patch set Stats (+246 lines, -78 lines) Patch
M expectations/gm/ignored-tests.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +15 lines, -1 line 0 comments Download
A gm/imageblurtiled.cpp View 1 2 3 4 5 6 1 chunk +76 lines, -0 lines 0 comments Download
A + gm/imagefiltersclipped.cpp View 1 2 3 4 5 6 4 chunks +19 lines, -26 lines 0 comments Download
M gm/imagefiltersscaled.cpp View 1 2 3 4 5 3 chunks +5 lines, -1 line 0 comments Download
M gyp/gmslides.gypi View 1 2 3 4 5 2 chunks +2 lines, -0 lines 0 comments Download
M include/core/SkCanvas.h View 1 2 3 4 5 6 7 8 1 chunk +4 lines, -1 line 0 comments Download
M include/core/SkImageFilter.h View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -3 lines 0 comments Download
M include/effects/SkBitmapSource.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M include/effects/SkBlurImageFilter.h View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M include/effects/SkComposeImageFilter.h View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M include/effects/SkDisplacementMapEffect.h View 1 2 3 4 5 1 chunk +3 lines, -0 lines 0 comments Download
M include/effects/SkDropShadowImageFilter.h View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M include/effects/SkMergeImageFilter.h View 1 2 3 4 5 1 chunk +0 lines, -2 lines 0 comments Download
M include/effects/SkMorphologyImageFilter.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M include/effects/SkOffsetImageFilter.h View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkCanvas.cpp View 1 2 3 4 5 3 chunks +11 lines, -4 lines 0 comments Download
M src/core/SkImageFilter.cpp View 1 2 3 4 5 2 chunks +23 lines, -3 lines 0 comments Download
M src/effects/SkBitmapSource.cpp View 1 2 3 4 5 1 chunk +6 lines, -0 lines 0 comments Download
M src/effects/SkBlurImageFilter.cpp View 1 2 3 4 5 1 chunk +15 lines, -0 lines 0 comments Download
M src/effects/SkComposeImageFilter.cpp View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/effects/SkDisplacementMapEffect.cpp View 1 2 3 4 5 1 chunk +9 lines, -0 lines 0 comments Download
M src/effects/SkDropShadowImageFilter.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +19 lines, -0 lines 0 comments Download
M src/effects/SkMergeImageFilter.cpp View 1 2 3 4 5 1 chunk +0 lines, -32 lines 0 comments Download
M src/effects/SkMorphologyImageFilter.cpp View 1 2 3 4 5 1 chunk +14 lines, -0 lines 0 comments Download
M src/effects/SkOffsetImageFilter.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +5 lines, -2 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
Stephen White
PTAL. Thanks!
6 years, 10 months ago (2014-02-03 23:59:37 UTC) #1
reed1
https://codereview.chromium.org/23011012/diff/156001/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/23011012/diff/156001/include/core/SkCanvas.h#newcode1029 include/core/SkCanvas.h:1029: // returns false if the entire rectangle is entirely ...
6 years, 10 months ago (2014-02-04 15:30:07 UTC) #2
Stephen White
Thanks for your review. New patch is up. https://codereview.chromium.org/23011012/diff/156001/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/23011012/diff/156001/include/core/SkCanvas.h#newcode1029 include/core/SkCanvas.h:1029: // ...
6 years, 10 months ago (2014-02-04 16:01:40 UTC) #3
Stephen White
Note to Robert: when this lands, the following Blink layout tests will need to be ...
6 years, 10 months ago (2014-02-04 18:05:26 UTC) #4
reed1
Still am curious if we're still right to (re)use saveLayer for filtering, but I agree ...
6 years, 10 months ago (2014-02-04 21:14:05 UTC) #5
Stephen White
Committed patchset #11 manually as r13323 (presubmit successful).
6 years, 10 months ago (2014-02-05 17:51:31 UTC) #6
robertphillips
From your suppression list, I also had to suppress: svg/batik/text/smallFonts.svg [ ImageOnlyFailure ] svg/batik/text/textFeatures.svg [ ...
6 years, 10 months ago (2014-02-06 13:41:39 UTC) #7
Stephen White
On 2014/02/06 13:41:39, robertphillips wrote: > From your suppression list, I also had to suppress: ...
6 years, 10 months ago (2014-02-06 13:45:07 UTC) #8
tomhudson
This patch brought in a 3x performance regression on blur_image_filter_{small,large}_80.00_80.00 Was that expected?
6 years, 10 months ago (2014-02-11 12:18:08 UTC) #9
Stephen White
6 years, 10 months ago (2014-02-11 15:02:33 UTC) #10
Message was sent while issue was closed.
On 2014/02/11 12:18:08, tomhudson wrote:
> This patch brought in a 3x performance regression on
> blur_image_filter_{small,large}_80.00_80.00
> 
> Was that expected?

Yes, that's expected. With no bounds set in the saveLayer() call, the blur is
not clipped in order to get the edges correct (see the corresponding changes in
the GMs), which means larger offscreens and more processing.

This is needed to avoid artifacts on tile boundaries in impl-side painting. If
the caller wants to constrain the offscreen size to the clip rect, they can
specify smaller bounds in saveLayer(), or use the blur filter's crop rect.

Powered by Google App Engine
This is Rietveld 408576698