summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Ludwig <michaelludwig@google.com> 2025-03-04 12:24:29 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-04 12:24:29 -0800
commit350141e1a78f52ae4af53c6e0f323a490196ebdd (patch)
tree78fc370bf4a60180d7ab63723b6e0a562f40376d
parente4d969c1ff5da1e5c4a8646735a9cef1086430ea (diff)
parentdc1f09b81a1b1aaa7d7e1bc9ea23cf95d58cb22f (diff)
Merge "Check return value of SkRect::intersect()" into main
-rw-r--r--libs/hwui/jni/Graphics.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/libs/hwui/jni/Graphics.cpp b/libs/hwui/jni/Graphics.cpp
index a210ddf54b2e..7d227f793817 100644
--- a/libs/hwui/jni/Graphics.cpp
+++ b/libs/hwui/jni/Graphics.cpp
@@ -722,10 +722,15 @@ void RecyclingClippingPixelAllocator::copyIfNecessary() {
auto canvas = SkCanvas(recycledPixels->getSkBitmap());
SkRect destination = SkRect::Make(recycledPixels->info().bounds());
- destination.intersect(SkRect::Make(mSkiaBitmap->info().bounds()));
- canvas.drawImageRect(mSkiaBitmap->asImage(), *mDesiredSubset, destination,
- SkSamplingOptions(SkFilterMode::kLinear), nullptr,
- SkCanvas::kFast_SrcRectConstraint);
+ if (destination.intersect(SkRect::Make(mSkiaBitmap->info().bounds()))) {
+ canvas.drawImageRect(mSkiaBitmap->asImage(), *mDesiredSubset, destination,
+ SkSamplingOptions(SkFilterMode::kLinear), nullptr,
+ SkCanvas::kFast_SrcRectConstraint);
+ } else {
+ // The canvas would have discarded the draw operation automatically, but
+ // this case should have been detected before getting to this point.
+ ALOGE("Copy destination does not intersect image bounds");
+ }
} else {
void* dst = recycledPixels->pixels();
const size_t dstRowBytes = mRecycledBitmap->rowBytes();