From ad70c8a7f8344bcefdb3ba842241c16dd265c4f9 Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Mon, 29 Aug 2022 16:02:02 +0000 Subject: [PATCH] Revert "Call isEmpty() instead of constructing a new object to compare" This reverts commit ff37ce9727daf09ff83eb0f96bc499a473bb7aa1. Reason for revert: Breaks tests The motivation for this CL was that patch set 1 of https://skia-review.googlesource.com/c/skia/+/573636 moved operator== out of SkRect.h, and this file no longer had access to it. isEmpty will return true for more values than {0, 0, 0, 0}, though, which changes the behavior for AImageDecoder_setCrop. Instead of returning ANDROID_IMAGE_DECODER_BAD_PARAMETER, the bad rect will be ignored. Tests caught this change in behavior. Restore the old behavior of returning an error. The final version of the Skia change that landed restored an inline version of SkIRect::operator==, so the old behavior is fine with the new code. Bug: b/243964535 Test: AImageDecoderTest Change-Id: Iba267a14e7e0ba084384bb1bbb293eda2311b8de --- native/graphics/jni/imagedecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/graphics/jni/imagedecoder.cpp b/native/graphics/jni/imagedecoder.cpp index 7fe2735c9ad62..cd6ed23916083 100644 --- a/native/graphics/jni/imagedecoder.cpp +++ b/native/graphics/jni/imagedecoder.cpp @@ -381,7 +381,7 @@ int AImageDecoder_setCrop(AImageDecoder* decoder, ARect crop) { SkIRect cropIRect; cropIRect.setLTRB(crop.left, crop.top, crop.right, crop.bottom); - SkIRect* cropPtr = cropIRect.isEmpty() ? nullptr : &cropIRect; + SkIRect* cropPtr = cropIRect == SkIRect::MakeEmpty() ? nullptr : &cropIRect; return imageDecoder->setCropRect(cropPtr) ? ANDROID_IMAGE_DECODER_SUCCESS : ANDROID_IMAGE_DECODER_BAD_PARAMETER; }