summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-01-06 23:08:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-01-06 23:08:50 +0000
commit709933c1622e9672d895fe22c1db80c539b24df0 (patch)
tree9dcf7c16a39c00f96382d2f871673cca75d34fb4 /native
parent013e845762035c2b15b56b670752eee6e80c7c3d (diff)
parent139145be8082f0606045b89feebc9126a9a376d8 (diff)
Merge "Handle EXIF orientation in hwui/ImageDecoder"
Diffstat (limited to 'native')
-rw-r--r--native/graphics/jni/imagedecoder.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/native/graphics/jni/imagedecoder.cpp b/native/graphics/jni/imagedecoder.cpp
index ac4c16a4199b..4aeebe47f1ae 100644
--- a/native/graphics/jni/imagedecoder.cpp
+++ b/native/graphics/jni/imagedecoder.cpp
@@ -65,17 +65,18 @@ static int createFromStream(std::unique_ptr<SkStreamRewindable> stream, AImageDe
SkCodec::Result result;
auto codec = SkCodec::MakeFromStream(std::move(stream), &result, nullptr,
SkCodec::SelectionPolicy::kPreferAnimation);
- auto androidCodec = SkAndroidCodec::MakeFromCodec(std::move(codec),
- SkAndroidCodec::ExifOrientationBehavior::kRespect);
+ // These may be swapped due to the SkEncodedOrigin, but we're just checking
+ // them to make sure they fit in int32_t.
+ auto dimensions = codec->dimensions();
+ auto androidCodec = SkAndroidCodec::MakeFromCodec(std::move(codec));
if (!androidCodec) {
return ResultToErrorCode(result);
}
// AImageDecoderHeaderInfo_getWidth/Height return an int32_t. Ensure that
// the conversion is safe.
- const auto& info = androidCodec->getInfo();
- if (info.width() > std::numeric_limits<int32_t>::max()
- || info.height() > std::numeric_limits<int32_t>::max()) {
+ if (dimensions.width() > std::numeric_limits<int32_t>::max() ||
+ dimensions.height() > std::numeric_limits<int32_t>::max()) {
return ANDROID_IMAGE_DECODER_INVALID_INPUT;
}
@@ -200,14 +201,14 @@ int32_t AImageDecoderHeaderInfo_getWidth(const AImageDecoderHeaderInfo* info) {
if (!info) {
return 0;
}
- return toDecoder(info)->mCodec->getInfo().width();
+ return toDecoder(info)->width();
}
int32_t AImageDecoderHeaderInfo_getHeight(const AImageDecoderHeaderInfo* info) {
if (!info) {
return 0;
}
- return toDecoder(info)->mCodec->getInfo().height();
+ return toDecoder(info)->height();
}
const char* AImageDecoderHeaderInfo_getMimeType(const AImageDecoderHeaderInfo* info) {