OSDN Git Service

Separate code for finishing commit and handling requests.
authorRafael Antognolli <rafael.antognolli@intel.com>
Tue, 14 Mar 2017 07:32:11 +0000 (00:32 -0700)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Wed, 15 Mar 2017 06:10:05 +0000 (23:10 -0700)
This makes the main DisplayQueue::HandleRoutine function smaller and
cleaner, so it's easier to understand its logic.

Jira: None.
Test: No regressions on Linux and Android.

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Android.mk
common/display/displayqueue.cpp
common/display/displayqueue.h

index 0ba6145..ed4793f 100644 (file)
@@ -60,6 +60,7 @@ LOCAL_SRC_FILES := \
        common/display/pageflipeventhandler.cpp \
        common/display/virtualdisplay.cpp \
        common/utils/drmscopedtypes.cpp \
+       common/utils/fdhandler.cpp \
        common/utils/hwcevent.cpp \
        common/utils/hwcthread.cpp \
        common/utils/disjoint_layers.cpp \
index d9e14a3..20af5bf 100644 (file)
@@ -299,26 +299,19 @@ void DisplayQueue::HandleUpdateRequest(DisplayQueueItem& queue_item) {
   if (fence > 0) {
     compositor_.InsertFence(dup(fence));
     fd_handler_.AddFd(fence);
-    commit_pending_ = true;
     out_fence_.Reset(fence);
   }
 #endif
 
-  previous_sync_.reset(current_sync_.release());
   current_sync_.reset(queue_item.sync_object_.release());
 }
 
-void DisplayQueue::HandleRoutine() {
-  if (commit_pending_ && fd_handler_.IsReady(out_fence_.get())) {
-    fd_handler_.RemoveFd(out_fence_.get());
-    commit_pending_ = false;
-    out_fence_.Reset(-1);
-    previous_sync_.reset(nullptr);
-  }
-
-  if (commit_pending_)
-    return;
+void DisplayQueue::CommitFinished() {
+  fd_handler_.RemoveFd(out_fence_.get());
+  out_fence_.Reset(-1);
+}
 
+void DisplayQueue::ProcessRequests() {
   display_queue_.lock();
   size_t size = queue_.size();
 
@@ -335,6 +328,22 @@ void DisplayQueue::HandleRoutine() {
   HandleUpdateRequest(item);
 }
 
+void DisplayQueue::HandleRoutine() {
+  // If we have a commit pending and the out_fence_ is ready, we can process
+  // the end of the last commit.
+  int fd = out_fence_.get();
+  if (fd > 0 && fd_handler_.IsReady(fd))
+    CommitFinished();
+
+  // Do not submit another commit while there is one still pending.
+  if (out_fence_.get() > 0)
+    return;
+
+  // Check whether there are more requests to process, and commit the first
+  // one.
+  ProcessRequests();
+}
+
 void DisplayQueue::Flush() {
   ScopedSpinLock lock(display_queue_);
 
@@ -367,7 +376,6 @@ void DisplayQueue::HandleExit() {
   previous_layers_.clear();
   previous_plane_state_.clear();
   std::queue<DisplayQueueItem>().swap(queue_);
-  previous_sync_.reset(nullptr);
   current_sync_.reset(nullptr);
   compositor_.Reset();
 }
index 28f57e6..3fb738f 100644 (file)
@@ -71,6 +71,8 @@ class DisplayQueue : public HWCThread {
   void GetDrmObjectProperty(const char* name,
                             const ScopedDrmObjectPropertyPtr& props,
                             uint32_t* id) const;
+  void CommitFinished();
+  void ProcessRequests();
 
   Compositor compositor_;
   drmModeModeInfo mode_;
@@ -87,11 +89,9 @@ class DisplayQueue : public HWCThread {
   uint32_t old_blob_id_ = 0;
   uint32_t gpu_fd_;
   bool needs_modeset_ = false;
-  bool commit_pending_ = false;
   std::unique_ptr<PageFlipEventHandler> flip_handler_;
   std::unique_ptr<DisplayPlaneManager> display_plane_manager_;
   std::unique_ptr<NativeSync> current_sync_;
-  std::unique_ptr<NativeSync> previous_sync_;
   SpinLock spin_lock_;
   SpinLock display_queue_;
   std::queue<DisplayQueueItem> queue_;