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/drm/DrmDevice.h b/drm/DrmDevice.h
index bb515e0..39d0c88 100644
--- a/drm/DrmDevice.h
+++ b/drm/DrmDevice.h
@@ -23,7 +23,7 @@
#include "DrmConnector.h"
#include "DrmCrtc.h"
#include "DrmEncoder.h"
-#include "utils/UniqueFd.h"
+#include "utils/fd.h"
namespace android {
@@ -38,8 +38,8 @@
static auto CreateInstance(std::string const &path, ResourceManager *res_man)
-> std::unique_ptr<DrmDevice>;
- auto GetFd() const {
- return fd_.Get();
+ auto &GetFd() const {
+ return fd_;
}
auto &GetResMan() {
@@ -101,7 +101,7 @@
static auto IsKMSDev(const char *path) -> bool;
- UniqueFd fd_;
+ SharedFd fd_;
std::vector<std::unique_ptr<DrmConnector>> connectors_;
std::vector<std::unique_ptr<DrmConnector>> writeback_connectors_;