-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
[framework] FilterQualiy.low is poor default for the Image widget. #148253
Comments
+1, the naming is very wrong right now - misleading at best. Not only should we change the default, we ideally should have names that actually coincide with what the engine is doing (ideally using industry standard terminology). |
Closes flutter/flutter#147259. Changes: - Make sure the default of `kNearest` is used consistently - Partial revert of #40491, re-adding `kBase` - Added some documentation about relevant enums, and why the default is `kNearest` - Wired up `kBase` in the Metal, Vulkan, and OpenGLES backends Expecting an update to the `dart_ui_filter_quality_none` golden file: > ![Screenshot 2024-05-13 at 2 47 49�PM](https://github.com/flutter/engine/assets/168174/68df4c1a-9b2b-4201-9a6c-f78361a5aa30) For breadcrumbs around the mapping, see flutter/flutter#148253.
Some notes from talking to @jonahwilliams: We should make Long-term: The fact that the naming suggests an order here is misleading. We could turn none -> pixelated (nearest neighbor, no mips) |
Or some potentially more descriptive names:
My preference would be to use these descriptive names that also do not imply any order. They'd have to go with some detailed docs describing the pros/cons of each. |
@yjbanov @eyebrowsoffire Are there any potential concerns on the web (e.g. w.r.t. performance) with switching the default to |
I think the only concern here is that both CanvasKit and Skwasm don't produce mipmaps for certain images. For those images, the request for mipmapped sampling may be ignored. I think one of the things that is sort of wrong with our API is that you need to make a decision about whether you're going to use mipmapping at image creation time, but the filter quality is specified at draw time. The way |
Thank you! Could you qualify what the "certain" images are for which mipmaps are not produced? Is this more of an edge case or something that's gonna be fairly common? |
I would say it's the common case on the web that doesn't populate mipmaps. The |
I'd be surprised if generating mips was a substantial % of the cost of decoding or allocating large images. Whereas the performance hit you can take from not having them will be felt on every subsequent frame. |
Unless canvaskit is generating mips on the CPU? |
I think that's a reasonable hypothesis. I am not in principle against generating mipmaps for all images.
For the images in question, no mipmaps are being generated at all right now, and it is more-or-less up to the bindings layer to generate them at the moment of texture creation. It might be as simple as calling |
You could also choose to not honor the filter quality setting if you don't have mips. Also, if the backend knows that the texture would be sampled from the 1st mip level anyway, you could defer generating them. |
Thanks for this change @jonahwilliams and @goderbauer. I think we missed part of the engine that is intended to stay in sync, though perhaps it's not important and the default actually doesn't come up (if so, we should delete the TODO). |
we didn't miss it, its just not done yet: flutter/engine#53161 ;) |
The changes to switch the defaults to |
Sounds good, thanks @goderbauer ! |
The |
…le mode. (#53161) Match DL/Skia sampling defaults. This does not change the default SamplerDescriptor value, but that is irrelevant as any draws from the framework will pass through DL conversion. The SamplerDescriptor default of nearest is generally a good idea. Fixes flutter/flutter#148253
FilterQuality.low corresponds to linear sampling with the base mip level only (with Skia). Flutter's image widget uses this as the default filter quality for rendering. Unfortunately this has major fidelity/performance problems if the image is substantially larger than the destination rectangle (a common issue).
Avoiding mipmaps will impact image quality, as entire rows/columns of pixels will be entirely dropped.
Avoiding mipmaps will slow down rendering. While a small image will sample fewer pixels from the larger image, these pixels will necessarily be more spread out causing increased L1/L2 cache misses.
Mips solve both of these problems.
Impeller initially implemented FilterQuality.low incorrectly and gave it mip levels. We do not plan to fix this until the framework is fixed, as it will have a negative impact on all Flutter applications.
The text was updated successfully, but these errors were encountered: