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

Issue 1308703007: Fix filter primitive bounds computations. (Closed)

Created:
5 years, 3 months ago by Stephen White
Modified:
5 years ago
Reviewers:
mtklein, reed1
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@saveLayer-bounds-not-transformed
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Fix filter primitive bounds computations. Make each filter responsible for expanding its destination bounds. Previously, we were using a union of all intermediate bounds sizes via join() calls in many image filters' computeFastBounds(), due to the fact that those filters could only produce bitmaps the same size as their inputs. Now, we compute optimal bounds for each filter as follows: 1) Pass the (unmodified) clip bounds to the root node of the DAG in the first recursive call to onFilterImage() as the Context's fClipBounds. 2) Reverse-map the clip: when recursing up the DAG in filterInput[GPU](), apply filter-specific expansion to the clip by calling calling onFilterNodeBounds(... kReverse). This allows upstream nodes to have a clip that respects the current node's requirements. This is done via helper function mapContext(). 3) Forward-map the source bitmap: just prior to applying the crop rect in applyCropRect(), we determine the filter's preferred bounds by mapping the source bitmap bounds forwards via onFilterNodeBounds(..., kForward). NOTE: GMs affected by this change: fast_slow_blurimagefilter: fast and slow paths now produce the same result spritebitmap: drawSprite() and drawBitmap() paths now produce the same result filterfastbounds: fast bounds are optimized; all drop-shadow results now appear apply-filter: snug and not-snug cases give same results dropshadowimagefilter: drawSprite() results now show shadows draw-with-filter: no artifacts on erode edges; blur edges no longer clipped displacement, imagefiltersbase, imagefiltersclipped, imagefilterscropexpand, imagefiltersscaled, matriximagefilter, resizeimagefilter, localmatriximagefilter, testimagefilters: fixed incorrect clipping imagefilterstransformed, morphology: no artifacts on erode edges BUG=skia:1062, skia:3194, skia:3939, skia:4337, skia:4526 Committed: https://skia.googlesource.com/skia/+/db64af3b178a19ecb47d2b9a373113687d8921fd

Patch Set 1 #

Patch Set 2 : Intersect against transformed clip bounds in applyCropRect(). #

Patch Set 3 : Cleanup #

Patch Set 4 : Update to ToT #

Patch Set 5 : Implement mapContext(), and use it in filterInput(). #

Patch Set 6 : Implement mapContext(), and use it in filterInput (for realz) #

Patch Set 7 : Update to ToT #

Patch Set 8 : Update to ToT #

Patch Set 9 : onFilterBounds() cleanup #

Patch Set 10 : Simplify SkTileImageFilter::onFilterNodeBounds() #

Patch Set 11 : Update to ToT #

Patch Set 12 : Rebase #

Patch Set 13 : fix #

Patch Set 14 : Rebase #

Patch Set 15 : Set correct upstream #

Patch Set 16 : Fix bug in SkMergeImageFilter's crop rect application. #

Patch Set 17 : Don't abort SkMergeImageFilter processing on a cropped-out input #

Patch Set 18 : Update to ToT #

Patch Set 19 : Update to ToT #

Patch Set 20 : Fix SkTileImageFilter, fix SkRecordDraw #

Patch Set 21 : Fix offset, matrix, compose. #

Patch Set 22 : Rebased on top of matrix convolution fix (https://codereview.chromium.org/1500923004) and fix matrix conv and morphology tiling #

Patch Set 23 : Update to ToT #

Patch Set 24 : Fix ComposedImgeFilterOffset test #

Patch Set 25 : Update to ToT #

Total comments: 5

Patch Set 26 : SkIRect::makeOffset goodness; update to ToT #

Patch Set 27 : Moar makeOffset() goodness. #

Patch Set 28 : Hide pixel changes behind SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS ifdef and update to ToT #

Patch Set 29 : Make mapContext() protected; add some comments. #

Patch Set 30 : 100-col fixes #

Total comments: 4

Patch Set 31 : Fix comment style; remove useless param names #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+209 lines, -102 lines) Patch
M include/core/SkImageFilter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2 chunks +27 lines, -0 lines 0 comments Download
M include/effects/SkBlurImageFilter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +2 lines, -1 line 0 comments Download
M include/effects/SkDisplacementMapEffect.h View 5 1 chunk +1 line, -0 lines 0 comments Download
M include/effects/SkDropShadowImageFilter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +2 lines, -1 line 0 comments Download
M include/effects/SkMatrixConvolutionImageFilter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +1 line, -1 line 0 comments Download
M include/effects/SkMorphologyImageFilter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +2 lines, -1 line 0 comments Download
M include/effects/SkOffsetImageFilter.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M include/effects/SkTileImageFilter.h View 1 2 3 5 1 chunk +1 line, -0 lines 0 comments Download
M src/core/SkCanvas.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 3 chunks +8 lines, -2 lines 0 comments Download
M src/core/SkDevice.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +4 lines, -0 lines 0 comments Download
M src/core/SkImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 5 chunks +38 lines, -9 lines 0 comments Download
M src/core/SkMatrixImageFilter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +2 lines, -2 lines 0 comments Download
M src/core/SkMatrixImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +16 lines, -13 lines 0 comments Download
M src/core/SkRecordDraw.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 3 chunks +8 lines, -0 lines 6 comments Download
M src/effects/SkBlurImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 chunks +13 lines, -12 lines 0 comments Download
M src/effects/SkComposeImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +3 lines, -1 line 0 comments Download
M src/effects/SkDisplacementMapEffect.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +11 lines, -5 lines 0 comments Download
M src/effects/SkDropShadowImageFilter.cpp View 1 2 3 4 5 6 7 8 1 chunk +11 lines, -13 lines 0 comments Download
M src/effects/SkMatrixConvolutionImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 2 chunks +11 lines, -11 lines 0 comments Download
M src/effects/SkMorphologyImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 chunks +6 lines, -11 lines 0 comments Download
M src/effects/SkOffsetImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +14 lines, -10 lines 0 comments Download
M src/effects/SkTileImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +15 lines, -6 lines 0 comments Download
M src/gpu/SkGpuDevice.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2 chunks +8 lines, -0 lines 0 comments Download
M tests/ImageFilterTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 chunk +4 lines, -2 lines 0 comments Download

Messages

Total messages: 62 (32 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/400001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/400001
5 years ago (2015-12-01 22:55:50 UTC) #3
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared-Trybot on client.skia (JOB_FAILED, http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared-Trybot/builds/4477)
5 years ago (2015-12-01 22:59:24 UTC) #5
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/460001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/460001
5 years ago (2015-12-07 18:02:47 UTC) #8
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-07 18:18:26 UTC) #10
reed1
just applied it locally, it it does seem to fix a lot of artifacts. Awesome!
5 years ago (2015-12-07 19:56:08 UTC) #21
reed1
https://codereview.chromium.org/1308703007/diff/480001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/480001/src/core/SkRecordDraw.cpp#newcode572 src/core/SkRecordDraw.cpp:572: inverse.mapRect(rect); Is this change a fix in its own ...
5 years ago (2015-12-07 20:24:11 UTC) #24
reed1
https://codereview.chromium.org/1308703007/diff/480001/src/gpu/SkGpuDevice.cpp File src/gpu/SkGpuDevice.cpp (right): https://codereview.chromium.org/1308703007/diff/480001/src/gpu/SkGpuDevice.cpp#newcode1166 src/gpu/SkGpuDevice.cpp:1166: SkIRect clipBounds = draw.fClip->getBounds(); option: could use (your pref) ...
5 years ago (2015-12-07 20:26:20 UTC) #25
Stephen White
https://codereview.chromium.org/1308703007/diff/480001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/480001/src/core/SkRecordDraw.cpp#newcode572 src/core/SkRecordDraw.cpp:572: inverse.mapRect(rect); On 2015/12/07 20:24:11, reed1 wrote: > Is this ...
5 years ago (2015-12-07 20:29:40 UTC) #26
Stephen White
https://codereview.chromium.org/1308703007/diff/480001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/480001/src/core/SkRecordDraw.cpp#newcode572 src/core/SkRecordDraw.cpp:572: inverse.mapRect(rect); On 2015/12/07 20:29:40, Stephen White wrote: > On ...
5 years ago (2015-12-07 20:51:15 UTC) #27
reed1
Gotcha.
5 years ago (2015-12-07 21:17:23 UTC) #28
Stephen White
https://codereview.chromium.org/1308703007/diff/480001/src/gpu/SkGpuDevice.cpp File src/gpu/SkGpuDevice.cpp (right): https://codereview.chromium.org/1308703007/diff/480001/src/gpu/SkGpuDevice.cpp#newcode1166 src/gpu/SkGpuDevice.cpp:1166: SkIRect clipBounds = draw.fClip->getBounds(); On 2015/12/07 20:26:20, reed1 wrote: ...
5 years ago (2015-12-07 21:34:23 UTC) #29
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/520001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/520001
5 years ago (2015-12-07 21:39:06 UTC) #31
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-07 21:53:21 UTC) #34
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/540001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/540001
5 years ago (2015-12-09 15:02:42 UTC) #36
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/580001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/580001
5 years ago (2015-12-09 15:41:48 UTC) #38
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-09 15:55:19 UTC) #41
Stephen White
reed@, mtklein@: PTAL. Thanks!
5 years ago (2015-12-09 16:03:38 UTC) #44
reed1
landing this will make me very happy. congrats on a big fix. lgtm https://codereview.chromium.org/1308703007/diff/580001/include/core/SkImageFilter.h File ...
5 years ago (2015-12-09 16:11:41 UTC) #45
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/600001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/600001
5 years ago (2015-12-09 16:52:51 UTC) #47
mtklein
I'm on board! https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 src/core/SkRecordDraw.cpp:576: fSaveStack[i].ctm.mapRect(rect); Is it important that we ...
5 years ago (2015-12-09 16:59:41 UTC) #48
mtklein
https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 src/core/SkRecordDraw.cpp:576: fSaveStack[i].ctm.mapRect(rect); On 2015/12/09 at 16:59:41, mtklein wrote: > Is ...
5 years ago (2015-12-09 17:00:53 UTC) #49
Stephen White
https://codereview.chromium.org/1308703007/diff/580001/include/core/SkImageFilter.h File include/core/SkImageFilter.h (right): https://codereview.chromium.org/1308703007/diff/580001/include/core/SkImageFilter.h#newcode354 include/core/SkImageFilter.h:354: // Performs a forwards or reverse mapping of the ...
5 years ago (2015-12-09 17:02:57 UTC) #50
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years ago (2015-12-09 17:03:48 UTC) #52
mtklein
https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 src/core/SkRecordDraw.cpp:576: fSaveStack[i].ctm.mapRect(rect); So, (*rect at line 577) != (*rect at ...
5 years ago (2015-12-09 17:06:04 UTC) #53
Stephen White
https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 src/core/SkRecordDraw.cpp:576: fSaveStack[i].ctm.mapRect(rect); On 2015/12/09 17:06:04, mtklein wrote: > So, (*rect ...
5 years ago (2015-12-09 17:10:52 UTC) #54
mtklein
https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp File src/core/SkRecordDraw.cpp (right): https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 src/core/SkRecordDraw.cpp:576: fSaveStack[i].ctm.mapRect(rect); On 2015/12/09 at 17:10:52, Stephen White wrote: > ...
5 years ago (2015-12-09 17:15:25 UTC) #55
reed1
On 2015/12/09 17:15:25, mtklein wrote: > https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp > File src/core/SkRecordDraw.cpp (right): > > https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 > ...
5 years ago (2015-12-09 17:17:40 UTC) #56
mtklein
On 2015/12/09 at 17:15:25, mtklein wrote: > https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp > File src/core/SkRecordDraw.cpp (right): > > https://codereview.chromium.org/1308703007/diff/600001/src/core/SkRecordDraw.cpp#newcode576 ...
5 years ago (2015-12-09 17:18:59 UTC) #57
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1308703007/600001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1308703007/600001
5 years ago (2015-12-09 18:11:02 UTC) #60
commit-bot: I haz the power
5 years ago (2015-12-09 18:11:46 UTC) #62
Message was sent while issue was closed.
Committed patchset #31 (id:600001) as
https://skia.googlesource.com/skia/+/db64af3b178a19ecb47d2b9a373113687d8921fd

Powered by Google App Engine
This is Rietveld 408576698