OSDN Git Service

libvrflinger: Move display request to avoid duplicate calls.
authorCorey Tabaka <eieio@google.com>
Tue, 6 Jun 2017 23:33:31 +0000 (16:33 -0700)
committerCorey Tabaka <eieio@google.com>
Wed, 7 Jun 2017 01:30:28 +0000 (18:30 -0700)
Move the request display call to avoid duplicate calls when direct
surfaces change but the current VrFlinger mode does not change.

Bug: 62389162
Test: build; flash; VrFlinger mode works.
Change-Id: I1348ada93e2992306cba7e319f9b20726fb97cb7

libs/vr/libvrflinger/hardware_composer.cpp

index 599017f..00172a1 100644 (file)
@@ -210,6 +210,9 @@ void HardwareComposer::UpdatePostThreadState(PostThreadStateType state,
 }
 
 void HardwareComposer::OnPostThreadResumed() {
+  if (request_display_callback_)
+    request_display_callback_(true);
+
   hwc2_hidl_->resetCommands();
 
   // HIDL HWC seems to have an internal race condition. If we submit a frame too
@@ -246,6 +249,9 @@ void HardwareComposer::OnPostThreadPaused() {
 
   // Trigger target-specific performance mode change.
   property_set(kDvrPerformanceProperty, "idle");
+
+  if (request_display_callback_)
+    request_display_callback_(false);
 }
 
 HWC::Error HardwareComposer::Validate(hwc2_display_t display) {
@@ -475,17 +481,6 @@ void HardwareComposer::SetDisplaySurfaces(
 
   // Set idle state based on whether there are any surfaces to handle.
   UpdatePostThreadState(PostThreadState::Idle, display_idle);
-
-  // XXX: TEMPORARY
-  // Request control of the display based on whether there are any surfaces to
-  // handle. This callback sets the post thread active state once the transition
-  // is complete in SurfaceFlinger.
-  // TODO(eieio): Unify the control signal used to move SurfaceFlinger into VR
-  // mode. Currently this is hooked up to persistent VR mode, but perhaps this
-  // makes more sense to control it from VrCore, which could in turn base its
-  // decision on persistent VR mode.
-  if (request_display_callback_)
-    request_display_callback_(!display_idle);
 }
 
 int HardwareComposer::OnNewGlobalBuffer(DvrGlobalBufferKey key,