Skip to content

Commit

Permalink
feat: change the default for PREFERRED_COLOR_SPACE to be null
Browse files Browse the repository at this point in the history
  • Loading branch information
skyinu committed Mar 21, 2021
1 parent 7b27d5e commit ce6852d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
* Bitmap will actually use the requested color space.
*/
public enum PreferredColorSpace {
/** don't set prefer ColorSpace. */
NULL,
/** Prefers to decode images using {@link android.graphics.ColorSpace.Named#SRGB}. */
SRGB,
/** Prefers to decode images using {@link android.graphics.ColorSpace.Named#DISPLAY_P3}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,18 @@ public boolean onPartialImage(@NonNull DecodeException e) {
}

decoder.setTargetSize(resizeWidth, resizeHeight);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
boolean isP3Eligible =
preferredColorSpace == PreferredColorSpace.DISPLAY_P3
&& info.getColorSpace() != null
&& info.getColorSpace().isWideGamut();
decoder.setTargetColorSpace(
ColorSpace.get(
isP3Eligible ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
if (preferredColorSpace != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
boolean isP3Eligible =
preferredColorSpace == PreferredColorSpace.DISPLAY_P3
&& info.getColorSpace() != null
&& info.getColorSpace().isWideGamut();
decoder.setTargetColorSpace(
ColorSpace.get(
isP3Eligible ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ public final class Downsampler {
* limitations.
*/
public static final Option<PreferredColorSpace> PREFERRED_COLOR_SPACE =
Option.memory(
"com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace",
PreferredColorSpace.SRGB);
Option.memory("com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace");
/**
* Indicates the {@link com.bumptech.glide.load.resource.bitmap.DownsampleStrategy} option that
* will be used to calculate the sample size to use to downsample an image given the original and
Expand Down Expand Up @@ -376,7 +374,7 @@ private Bitmap decodeFromWrappedStreams(
}
}

if (preferredColorSpace != PreferredColorSpace.NULL) {
if (preferredColorSpace != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
boolean isP3Eligible =
preferredColorSpace == PreferredColorSpace.DISPLAY_P3
Expand Down

0 comments on commit ce6852d

Please sign in to comment.