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/VSyncWorker.cpp b/drm/VSyncWorker.cpp
index 77b9d98..8a251c7 100644
--- a/drm/VSyncWorker.cpp
+++ b/drm/VSyncWorker.cpp
@@ -40,7 +40,7 @@
   if (pipe != nullptr) {
     vsw->high_crtc_ = pipe->crtc->Get()->GetIndexInResArray()
                       << DRM_VBLANK_HIGH_CRTC_SHIFT;
-    vsw->drm_fd_ = UniqueFd::Dup(pipe->device->GetFd());
+    vsw->drm_fd_ = pipe->device->GetFd();
   }
 
   std::thread(&VSyncWorker::ThreadFn, vsw.get(), vsw).detach();
@@ -143,7 +143,7 @@
                                                 DRM_VBLANK_HIGH_CRTC_MASK));
       vblank.request.sequence = 1;
 
-      ret = drmWaitVBlank(drm_fd_.Get(), &vblank);
+      ret = drmWaitVBlank(*drm_fd_, &vblank);
       if (ret == -EINTR)
         continue;
     }