drm_hwcomposer: Introduce SharedFd, use standard c++ RAII for UniqueFd
We use too much dup() system calls for present fence propagating.
Also when propagating acquire fence we use additional logic for
skipping such propagation for the validate/test cycle.
Both issues can be solved by introducing SharedFd, which will track
reference count of fd object.
After that the UniqueFd is used very rarely and can be simplified by
wrapping it into std::unique_ptr without caring too much of adding
an extra malloc/free operation.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h
index 4ad57b7..6cac60f 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -200,7 +200,7 @@
DrmHwcTwo *const hwc2_;
- UniqueFd present_fence_;
+ SharedFd present_fence_;
std::optional<DrmMode> staged_mode_;
int64_t staged_mode_change_time_{};