-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageFilter default tile mode automatic selection breaking change notice #11338
ImageFilter default tile mode automatic selection breaking change notice #11338
Conversation
Co-authored-by: Parker Lougheed <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for writing this, @jonahwilliams! I have one clarification question.
was specified. A value of `null` when passed to the filter's constructor | ||
specifies automatic selection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was specified. A value of `null` when passed to the filter's constructor | |
specifies automatic selection. | |
Passing a value of `null` to the filter's constructor specifies | |
automatic selection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
`Tilemode.repeated`, `TileMode.mirror`, and `TileMode.decal`. The default for | ||
ui.ImageFilter is `TileMode.clamp`. We've observed that the behavior of clamp | ||
does not match most developer's expections about filter operations. Instead, | ||
decal better matches the intuition for saveLayers, as edge pixels are left | ||
as transparent black. For backdrop filters, `mirror` is used which prevents | ||
falloff on blurs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So.... why are you giving this advice? Is the default behavior now decal
? I think you are saying how the automatic selection process works?
`Tilemode.repeated`, `TileMode.mirror`, and `TileMode.decal`. The default for | |
ui.ImageFilter is `TileMode.clamp`. We've observed that the behavior of clamp | |
does not match most developer's expections about filter operations. Instead, | |
decal better matches the intuition for saveLayers, as edge pixels are left | |
as transparent black. For backdrop filters, `mirror` is used which prevents | |
falloff on blurs. | |
`Tilemode.repeated`, `TileMode.mirror`, and `TileMode.decal`. | |
Previously, `ImageFilter` defaulted to `clamp` mode if the | |
behavior wasn't specified, which sometimes surprised developers | |
as it didn't always match expectations. | |
As of this change, the filter | |
automatically selects `decal` mode when using `saveLayers`, | |
which leave edge pixels as transparent black. | |
The filter selects `mirror` mode for backdrop filters because | |
falloff on blurs. |
When is the repeated mode used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks better to me too. Repeated is never a default, but can be selected by the developer by specifying it manually when constructing the blur.
There is also drawImage(and variants) that use a default of clamp. And all Canvas.draw methods other than the image (and Atlas) versions will also default to decal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced this with a list that described the automatic behavior, PTAL?
/gcbrun |
Was this PR in draft mode when I started reviewing it? I didn't notice that. :) |
No worries, i appreciate the review as always :) |
The tile mode of a `ImageFilter` declares what happens to edge pixels of | ||
the applied filter. There are four options, `TileMode.clamp`, | ||
`Tilemode.repeated`, `TileMode.mirror`, and `TileMode.decal`. The default for | ||
ui.ImageFilter is `TileMode.clamp`. We've observed that the behavior of clamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to be clamp, or has been clamp, or was previously clamp?
Code after migration: | ||
|
||
```dart | ||
// Set tile mode to old default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless the new defaults look better to you? This makes it sound like developers must specify clamp now, but they may not want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some non-blocking suggestions for completeness.
The `ui.ImageFilter.blur`'s default tile mode is now automatically selected | ||
by the backend. Previously `TileMode.clamp` was used unless a different tile | ||
mode was specified. Passing a value of `null` to the filter's constructor | ||
specifies automatic selection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this imply that you need to manually pass a null to get the behavior? How about:
"Previously the default was clamp
unless a different tile mode was specified. Now, the default is null
and specifies automatic selection unless a specific tile mode is specified."
|
||
## Background | ||
|
||
`ImageFilter`'s _tile mode_ specifies what happens to edge pixels for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add .blur
to mentions of ImageFilter?
As of this change, the filter automatically selects the following tile modes | ||
based on context: | ||
|
||
* `decal` with save layers and when applied to individual draws. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drawShape?
|
||
## Migration guide | ||
|
||
Only image filters that don't specify an explicit tile mode are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blur
Only image filters that don't specify an explicit tile mode are | ||
impacted by this change. In these cases, you can specify an explicit tile | ||
mode to retain the prior behavior. However, we believe the automatic | ||
selection of behavior will be a superior choice in most cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL @sfshaza2
|
||
```dart | ||
// Set tile mode to old default. | ||
var filter = ui.ImageFilter.blur(sigmaX: 4, sigmaY: 4, tileMode: TileMode.clamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be turned into a lint with a fix to maintain consistent behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want folks to use the automatic selection though and not provide a default. maybe this section isn't clear and we should just not include it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That intent wasn't obvious from my reading, nor was the work that has gone into creating this proposal. I'm happy to work with y'all to build a proposal that better communicates what you are attempting to achieve this, if that would be helpful. Otherwise I can suggest some minor edits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this confusion in an earlier comment. I think this part of the section needs to indicate that it is optional and only needed if the developer preferred the previous behavior. I think it might be worthwhile to include it if the comment in the "after" section made it clear that nothing needs to be done, but if you really want the old behavior then this is the way to restore it. There has to be a concise way to express that the change is optional and probably not desired, but here it is if you need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is better but still seems to cause some confusion. Can we land it?
I was waiting for some FYI that the website infra was working again. |
/gcbrun |
@jonahwilliams, the website build is working again! |
Visit the preview URL for this PR (updated for commit c24df86): https://flutter-docs-prod--pr11338-add-tile-mode-breaking-chan-skjvf1ad.web.app |
Breaking change notice for flutter/flutter#154935 . Engine PR should land shortly...
Presubmit checklist