summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Miao <ericymiao@google.com> 2025-03-19 10:53:17 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-19 10:53:17 -0700
commitc486d0bb2727f98ac38016aa38a640c214d90169 (patch)
tree6582248bad8c028846e4077ea0e4d36d28d83043
parente50dd9733f2ad64dadde0c8557734a526b7b9963 (diff)
parent86447050ec9beb3869843ee57ad2662681e94fae (diff)
Merge "Make bitmap ashmem filename unique" into main
-rw-r--r--libs/hwui/hwui/Bitmap.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp
index 3ef970830dc4..46dcc1f4c50b 100644
--- a/libs/hwui/hwui/Bitmap.cpp
+++ b/libs/hwui/hwui/Bitmap.cpp
@@ -164,8 +164,13 @@ std::string Bitmap::getAshmemId(const char* tag, uint64_t bitmapId,
android::base::ReadFileToString("/proc/self/cmdline", &temp);
return temp;
}();
- return std::format("bitmap/{}-id_{}-{}x{}-size_{}-{}",
- tag, bitmapId, width, height, size, sCmdline);
+ /* counter is to ensure the uniqueness of the ashmem filename,
+ * e.g. a bitmap with same mId could be sent multiple times, an
+ * ashmem region is created each time
+ */
+ static std::atomic<uint32_t> counter{0};
+ return std::format("bitmap/{}_{}_{}x{}_size-{}_id-{}_{}",
+ tag, counter.fetch_add(1), width, height, size, bitmapId, sCmdline);
}
sk_sp<Bitmap> Bitmap::allocateAshmemBitmap(SkBitmap* bitmap) {