Handle EXIF orientation in hwui/ImageDecoder
Bug: 160984428
Test: AImageDecoderTest#testRespectOrientation
ImageDecoderTest#testRespectOrientation
Ieda439910ae52e609f0710d424503616d99ae5c7
I23caef26b4c82173c758dd0ce7fb6f04e4154588
I345a13d20776a007052d32e74fa42865b42f726d
It is possible to create an animated image with an exif orientation.
Using kRespect, there is no clean way to handle the orientation plus
compositing frames. Switch ImageDecoder to use kIgnore (the default).
Depends on a change in Skia (https://review.skia.org/344762) to make
SkAnimatedImage handle the orientation even with kIgnore.
Change-Id: Ib93b0ced09fa3cca4a6681745406355c48158fae
diff --git a/libs/hwui/jni/ImageDecoder.cpp b/libs/hwui/jni/ImageDecoder.cpp
index da91d46..96e912f 100644
--- a/libs/hwui/jni/ImageDecoder.cpp
+++ b/libs/hwui/jni/ImageDecoder.cpp
@@ -135,19 +135,15 @@
return throw_exception(env, kSourceException, "", jexception, source);
}
- auto androidCodec = SkAndroidCodec::MakeFromCodec(std::move(codec),
- SkAndroidCodec::ExifOrientationBehavior::kRespect);
+ auto androidCodec = SkAndroidCodec::MakeFromCodec(std::move(codec));
if (!androidCodec.get()) {
return throw_exception(env, kSourceMalformedData, "", nullptr, source);
}
- const auto& info = androidCodec->getInfo();
- const int width = info.width();
- const int height = info.height();
const bool isNinePatch = peeker->mPatch != nullptr;
ImageDecoder* decoder = new ImageDecoder(std::move(androidCodec), std::move(peeker));
return env->NewObject(gImageDecoder_class, gImageDecoder_constructorMethodID,
- reinterpret_cast<jlong>(decoder), width, height,
+ reinterpret_cast<jlong>(decoder), decoder->width(), decoder->height(),
animated, isNinePatch);
}