aboutsummaryrefslogtreecommitdiff
path: root/bufferinfo/BufferInfoGetter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bufferinfo/BufferInfoGetter.cpp')
-rw-r--r--bufferinfo/BufferInfoGetter.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/bufferinfo/BufferInfoGetter.cpp b/bufferinfo/BufferInfoGetter.cpp
index 0cfd7e5..95c1a23 100644
--- a/bufferinfo/BufferInfoGetter.cpp
+++ b/bufferinfo/BufferInfoGetter.cpp
@@ -22,9 +22,14 @@
#include "BufferInfoMapperMetadata.h"
#endif
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
+#include <mutex>
+
#include "utils/log.h"
#include "utils/properties.h"
@@ -48,17 +53,18 @@ BufferInfoGetter *BufferInfoGetter::GetInstance() {
return inst.get();
}
-bool BufferInfoGetter::IsHandleUsable(buffer_handle_t handle) {
- hwc_drm_bo_t bo;
- memset(&bo, 0, sizeof(hwc_drm_bo_t));
-
- if (ConvertBoInfo(handle, &bo) != 0) {
- return false;
+std::optional<BufferUniqueId> BufferInfoGetter::GetUniqueId(
+ buffer_handle_t handle) {
+ struct stat sb {};
+ if (fstat(handle->data[0], &sb) != 0) {
+ return {};
}
- if (bo.prime_fds[0] == 0) {
- return false;
+
+ if (sb.st_size == 0) {
+ return {};
}
- return true;
+
+ return static_cast<BufferUniqueId>(sb.st_ino);
}
int LegacyBufferInfoGetter::Init() {