- Notifications
You must be signed in to change notification settings - Fork6k
Expand FilterQuality API docs#24582
Uh oh!
There was an error while loading.Please reload this page.
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel inChat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read theTree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
flar commentedFeb 24, 2021
I feel like these clarifications are more of a report card for the implementation rather than documentation of the intention. The way they are phrased could end up cementing the expectation of the results in lieu of fixing the underlying problems. |
yjbanov commentedFeb 24, 2021
I think it's still better to have them than not, but...
...I agree that we should fix it eventually. Based on the cases I've seen so far, I would just remove
Implicitly, the current algorithm used by For advanced use-cases the Skia team tells me we can provide an explicit sampler. This way users can have a high degree of control. That would require an extension in our It would be a breaking change, so I wouldn't rush just yet. |
flar commentedFeb 24, 2021
We have the following possible techniques that can be applied at a quality vs performance tradeoff: nearest neighbor (none) The last 2 aren't mutually exclusive since you could apply nn/bilinear/bicubic even while doing mipmapping. There are also other filter algorighms, but we don't really embrace those. Also, mipmap is targeted at improving quality while reducing and just looks like bilinear (or bicubic potentially) while enlarging. If I'd get rid of any of the names I'd probably get rid of "none" as it is just such a bad name. It implies that nothing will happen if taken out of context and it falls out of the spectrum of "low/med/hi". I might have named it "fastest" or "lowest" originally, ignoring whether 3 or 4 constants are useful for Flutter apps. |
yjbanov commentedFeb 24, 2021
Yeah, so a more advanced API for picking a sampling matrix and/or mipmapping can be provided separately from the |
flar commentedFeb 24, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
To that end, Skia is moving to SkSamplingOptions, of which SkFilterQuality is just a legacy value with which to construct the sampling options. https://api.skia.org/SkSamplingOptions_8h.html Cubic is its own sampling method which does not appear to use mipmaps. The SkFilterQuality options now map to:
which is essentially as it was before |
| /// | ||
| /// Example: | ||
| /// | ||
| ///  |
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 should offer some alternative text that can take the place of (be an alternative to) the image for when people don't have images enabled. (Or, alternatively, rephrase the text to not refer to the example, such that it reads naturally with or without the image.) Seehttps://html.spec.whatwg.org/multipage/images.html#alt
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 followed the other examples in our code and rephrased the text to not refer to the example.
yjbanov commentedFeb 24, 2021
I turned the discussion about actually changing the API into a separate feature request:flutter/flutter#76737 |
chinmaygarde commentedMar 4, 2021
Ping@Hixie for followup. |
flar commentedMar 5, 2021
See also#24797 |
Hixie left a comment
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 guess LGTM since accurate documentation is better than inaccurate documentation, but I agree that it seems the real fix here is fixing the implementation.
Can't we just make the implementation of "high" act like "medium" when shrinking, if that's really better?
yjbanov commentedMar 10, 2021
This may be doable in Skia, but it's probably quite difficult to do on the Flutter side (engine or framework). The issue is that we don't have a way to tell if we're shrinking the image or magnifying it. It depends on the aggregate transform matrix that includes all layers as well as transforms inside the picture. Pictures are opaque andas of today backed by |
flar commentedMar 10, 2021
OpenGL and Metal have concepts of min and mag filters, but I don't see them exposed in Skia unless I'm missing something. |
Hixie commentedMar 12, 2021
I meant in Skia, yes. |
Document more precisely the effects of the
FilterQualityenum values with a focus on relative quality when scaling imagesup vs scaling themdown. It turns out that the algorithm used forhighis frequentlyworse thanmediumwhen scaling down. Only when scaling images up do you get increase in quality as you go none => low => medium => high.This PR depends onflutter/assets-for-api-docs#134.
Fixesflutter/flutter#76187