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
diff --git a/native/graphics/jni/imagedecoder.cpp b/native/graphics/jni/imagedecoder.cpp
index 7fe2735..cd6ed23 100644
--- a/native/graphics/jni/imagedecoder.cpp
+++ b/native/graphics/jni/imagedecoder.cpp
@@ -381,7 +381,7 @@
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;
}