Add support for overriding downsample mode per image request #2787
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fresco currently supports global configuration of downsampling modes via the
downsampleMode
setting inImagePipelineConfig
. However, it is not currently possible to support per-image downsample settings. Out of the box, the vast majority of images should be downsampled to avoid drawing images which are too large to be displayed on a canvas. Android will throw a runtime exception in such cases. Yet, there are some usages which warrant outright disabling of downsampling as detailed in great lengths in issues like this one and this one.This change introduces a new mechanism for overriding the globally-configured
downsampleMode
per image request by using a newdownsampleOverride
setting. If the override value gets set to a non-nullDownsampleMode
, theDecodeProducer
will use that override instead. If no override is set, the downsample mode configured from the pipeline is chosen.Examples
Here, you can see the subtle differences between two of the downsampling modes. These are applied via the new
downsampleOverride
setting. I have a follow-up PR that adds this to the showcase application.NEVER
ALWAYS
Differential Revision: D62393210