Expand FilterQuality API docs#24582
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 in Chat. 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 the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
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. |
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. |
|
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. |
|
Yeah, so a more advanced API for picking a sampling matrix and/or mipmapping can be provided separately from the |
|
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.
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.) See https://html.spec.whatwg.org/multipage/images.html#alt
There was a problem hiding this comment.
I followed the other examples in our code and rephrased the text to not refer to the example.
|
I turned the discussion about actually changing the API into a separate feature request: flutter/flutter#76737 |
|
Ping @Hixie for followup. |
|
See also #24797 |
Hixie
left a comment
There was a problem hiding this comment.
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?
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 and as of today backed by |
|
OpenGL and Metal have concepts of min and mag filters, but I don't see them exposed in Skia unless I'm missing something. |
|
I meant in Skia, yes. |
Document more precisely the effects of the
FilterQualityenum values with a focus on relative quality when scaling images up vs scaling them down. It turns out that the algorithm used forhighis frequently worse thanmediumwhen scaling down. Only when scaling images up do you get increase in quality as you go none => low => medium => high.This PR depends on flutter/assets-for-api-docs#134.
Fixes flutter/flutter#76187