diff options
| author | 2017-02-22 01:46:16 +0000 | |
|---|---|---|
| committer | 2017-02-22 01:46:19 +0000 | |
| commit | 0df2b375a3a09077f036285dbf2d35aa9113e4e0 (patch) | |
| tree | b9377074e46058adda6a5d59dd36ec56ff35720d | |
| parent | f7d364d8202d0eb9811b4acb6b4fbcae7eff50a6 (diff) | |
| parent | 6c382572e3136b4017dc80b5d389c771798b401a (diff) | |
Merge "BitmapFactory: Leave the P3 color space on wide gamut bitmaps"
| -rw-r--r-- | core/jni/android/graphics/BitmapFactory.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 2aa16b281884..30d6337d3e24 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -455,10 +455,17 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding const SkImageInfo decodeInfo = SkImageInfo::Make(size.width(), size.height(), decodeColorType, decodeAlphaType, codec->computeOutputColorSpace(decodeColorType)); - // When supported by the colorType, we will decode to sRGB (or linear sRGB). However, - // we only want to mark the bitmap as sRGB when linear blending is enabled. - SkImageInfo bitmapInfo = decodeInfo.makeAlphaType(alphaType) - .makeColorSpace(GraphicsJNI::colorSpaceForType(decodeColorType)); + SkImageInfo bitmapInfo = decodeInfo.makeAlphaType(alphaType); + + // For wide gamut images, we will leave the color space on the SkBitmap. Otherwise, + // use the default. + sk_sp<SkColorSpace> srgb = + SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, + SkColorSpace::kSRGB_Gamut, + SkColorSpace::kNonLinearBlending_ColorSpaceFlag); + if (decodeInfo.colorSpace() == srgb.get()) { + bitmapInfo = bitmapInfo.makeColorSpace(GraphicsJNI::colorSpaceForType(decodeColorType)); + } if (decodeColorType == kGray_8_SkColorType) { // The legacy implementation of BitmapFactory used kAlpha8 for |