Using fixed value to count gralloc buffer offset
Gralloc module may be used by CameraHal(32bit) and Apk(64bit).
Counting offset with int_ptr results in different values.
Bug: 73485161
Test: run cts -m CtsCameraTestCases
Change-Id: I7d8d3f20652107df1fd7812d30c01e4546ac4a22
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 7423a1e..fc68f4e 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -52,6 +52,8 @@
#define DBG_FUNC DBG("%s\n", __FUNCTION__)
+#define GOLDFISH_OFFSET_UNIT 8
+
#ifdef GOLDFISH_HIDL_GRALLOC
static bool isHidlGralloc = true;
#else
@@ -64,8 +66,8 @@
uint32_t getAshmemColorOffset(cb_handle_t* cb) {
uint32_t res = 0;
- if (cb->canBePosted()) res = sizeof(intptr_t);
- if (isHidlGralloc) res = sizeof(intptr_t) * 2;
+ if (cb->canBePosted()) res = GOLDFISH_OFFSET_UNIT;
+ if (isHidlGralloc) res = GOLDFISH_OFFSET_UNIT * 2;
return res;
}
@@ -633,12 +635,12 @@
if (needHostCb || (usage & GRALLOC_USAGE_HW_FB)) {
// keep space for postCounter
// AND openCounter for all host cb
- ashmem_size += sizeof(uint32_t) * 2;
+ ashmem_size += GOLDFISH_OFFSET_UNIT * 2;
}
} else {
if (usage & GRALLOC_USAGE_HW_FB) {
// keep space for postCounter
- ashmem_size += sizeof(uint32_t) * 1;
+ ashmem_size += GOLDFISH_OFFSET_UNIT * 1;
}
}