Skip to content

Commit ce6852d

Browse files
committed
feat: change the default for PREFERRED_COLOR_SPACE to be null
1 parent 7b27d5e commit ce6852d

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

library/src/main/java/com/bumptech/glide/load/PreferredColorSpace.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
* Bitmap will actually use the requested color space.
3030
*/
3131
public enum PreferredColorSpace {
32-
/** don't set prefer ColorSpace. */
33-
NULL,
3432
/** Prefers to decode images using {@link android.graphics.ColorSpace.Named#SRGB}. */
3533
SRGB,
3634
/** Prefers to decode images using {@link android.graphics.ColorSpace.Named#DISPLAY_P3}. */

library/src/main/java/com/bumptech/glide/load/resource/ImageDecoderResourceDecoder.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,18 @@ public boolean onPartialImage(@NonNull DecodeException e) {
129129
}
130130

131131
decoder.setTargetSize(resizeWidth, resizeHeight);
132-
133-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
134-
boolean isP3Eligible =
135-
preferredColorSpace == PreferredColorSpace.DISPLAY_P3
136-
&& info.getColorSpace() != null
137-
&& info.getColorSpace().isWideGamut();
138-
decoder.setTargetColorSpace(
139-
ColorSpace.get(
140-
isP3Eligible ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
141-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
142-
decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
132+
if (preferredColorSpace != null) {
133+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
134+
boolean isP3Eligible =
135+
preferredColorSpace == PreferredColorSpace.DISPLAY_P3
136+
&& info.getColorSpace() != null
137+
&& info.getColorSpace().isWideGamut();
138+
decoder.setTargetColorSpace(
139+
ColorSpace.get(
140+
isP3Eligible ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB));
141+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
142+
decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
143+
}
143144
}
144145
}
145146
});

library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public final class Downsampler {
6262
* limitations.
6363
*/
6464
public static final Option<PreferredColorSpace> PREFERRED_COLOR_SPACE =
65-
Option.memory(
66-
"com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace",
67-
PreferredColorSpace.SRGB);
65+
Option.memory("com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace");
6866
/**
6967
* Indicates the {@link com.bumptech.glide.load.resource.bitmap.DownsampleStrategy} option that
7068
* will be used to calculate the sample size to use to downsample an image given the original and
@@ -376,7 +374,7 @@ private Bitmap decodeFromWrappedStreams(
376374
}
377375
}
378376

379-
if (preferredColorSpace != PreferredColorSpace.NULL) {
377+
if (preferredColorSpace != null) {
380378
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
381379
boolean isP3Eligible =
382380
preferredColorSpace == PreferredColorSpace.DISPLAY_P3

0 commit comments

Comments
 (0)