Loading libs/hwui/hwui/ImageDecoder.cpp +14 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,19 @@ using namespace android; sk_sp<SkColorSpace> ImageDecoder::getDefaultColorSpace() const { const skcms_ICCProfile* encodedProfile = mCodec->getICCProfile(); if (encodedProfile) { // If the profile maps directly to an SkColorSpace, that SkColorSpace // will be returned. Otherwise, nullptr will be returned. In either // case, using this SkColorSpace results in doing no color correction. return SkColorSpace::Make(*encodedProfile); } // The image has no embedded color profile, and should be treated as SRGB. return SkColorSpace::MakeSRGB(); } ImageDecoder::ImageDecoder(std::unique_ptr<SkAndroidCodec> codec, sk_sp<SkPngChunkReader> peeker) : mCodec(std::move(codec)) , mPeeker(std::move(peeker)) Loading @@ -31,7 +44,7 @@ ImageDecoder::ImageDecoder(std::unique_ptr<SkAndroidCodec> codec, sk_sp<SkPngChu , mDecodeSize(mTargetSize) , mOutColorType(mCodec->computeOutputColorType(kN32_SkColorType)) , mUnpremultipliedRequired(false) , mOutColorSpace(mCodec->computeOutputColorSpace(mOutColorType, nullptr)) , mOutColorSpace(getDefaultColorSpace()) , mSampleSize(1) { } Loading libs/hwui/hwui/ImageDecoder.h +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ public: bool setUnpremultipliedRequired(bool unpremultipliedRequired); sk_sp<SkColorSpace> getDefaultColorSpace() const; void setOutColorSpace(sk_sp<SkColorSpace> cs); // The size is the final size after scaling and cropping. Loading native/graphics/jni/imagedecoder.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -213,12 +213,12 @@ int32_t AImageDecoderHeaderInfo_getDataSpace(const AImageDecoderHeaderInfo* info return ANDROID_IMAGE_DECODER_BAD_PARAMETER; } // Note: This recomputes the data space because it's possible the client has // changed the output color space, so we cannot rely on it. Alternatively, // Note: This recomputes the color type because it's possible the client has // changed the output color type, so we cannot rely on it. Alternatively, // we could store the ADataSpace in the ImageDecoder. const ImageDecoder* imageDecoder = toDecoder(info); SkColorType colorType = imageDecoder->mCodec->computeOutputColorType(kN32_SkColorType); sk_sp<SkColorSpace> colorSpace = imageDecoder->mCodec->computeOutputColorSpace(colorType); sk_sp<SkColorSpace> colorSpace = imageDecoder->getDefaultColorSpace(); return uirenderer::ColorSpaceToADataSpace(colorSpace.get(), colorType); } Loading Loading
libs/hwui/hwui/ImageDecoder.cpp +14 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,19 @@ using namespace android; sk_sp<SkColorSpace> ImageDecoder::getDefaultColorSpace() const { const skcms_ICCProfile* encodedProfile = mCodec->getICCProfile(); if (encodedProfile) { // If the profile maps directly to an SkColorSpace, that SkColorSpace // will be returned. Otherwise, nullptr will be returned. In either // case, using this SkColorSpace results in doing no color correction. return SkColorSpace::Make(*encodedProfile); } // The image has no embedded color profile, and should be treated as SRGB. return SkColorSpace::MakeSRGB(); } ImageDecoder::ImageDecoder(std::unique_ptr<SkAndroidCodec> codec, sk_sp<SkPngChunkReader> peeker) : mCodec(std::move(codec)) , mPeeker(std::move(peeker)) Loading @@ -31,7 +44,7 @@ ImageDecoder::ImageDecoder(std::unique_ptr<SkAndroidCodec> codec, sk_sp<SkPngChu , mDecodeSize(mTargetSize) , mOutColorType(mCodec->computeOutputColorType(kN32_SkColorType)) , mUnpremultipliedRequired(false) , mOutColorSpace(mCodec->computeOutputColorSpace(mOutColorType, nullptr)) , mOutColorSpace(getDefaultColorSpace()) , mSampleSize(1) { } Loading
libs/hwui/hwui/ImageDecoder.h +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ public: bool setUnpremultipliedRequired(bool unpremultipliedRequired); sk_sp<SkColorSpace> getDefaultColorSpace() const; void setOutColorSpace(sk_sp<SkColorSpace> cs); // The size is the final size after scaling and cropping. Loading
native/graphics/jni/imagedecoder.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -213,12 +213,12 @@ int32_t AImageDecoderHeaderInfo_getDataSpace(const AImageDecoderHeaderInfo* info return ANDROID_IMAGE_DECODER_BAD_PARAMETER; } // Note: This recomputes the data space because it's possible the client has // changed the output color space, so we cannot rely on it. Alternatively, // Note: This recomputes the color type because it's possible the client has // changed the output color type, so we cannot rely on it. Alternatively, // we could store the ADataSpace in the ImageDecoder. const ImageDecoder* imageDecoder = toDecoder(info); SkColorType colorType = imageDecoder->mCodec->computeOutputColorType(kN32_SkColorType); sk_sp<SkColorSpace> colorSpace = imageDecoder->mCodec->computeOutputColorSpace(colorType); sk_sp<SkColorSpace> colorSpace = imageDecoder->getDefaultColorSpace(); return uirenderer::ColorSpaceToADataSpace(colorSpace.get(), colorType); } Loading