OSDN Git Service

Re-enable default display when switching to VR mode.
authorAlex Sakhartchouk <alexst@google.com>
Mon, 5 Jun 2017 14:37:57 +0000 (10:37 -0400)
committerAlex Sakhartchouk <alexst@google.com>
Thu, 8 Jun 2017 18:17:35 +0000 (14:17 -0400)
Previously, in an attempt to minimize the number of changes that got
reset during VR mode transitions, the primary display was not turned back
on.

Bug: 62215749
Test: Switch device into VR mode, observe primary display invalidations.

Change-Id: Idd883e1522f519a0db06fdd88b071007487b6e70

services/surfaceflinger/SurfaceFlinger.cpp

index 78579a5..1bc9cec 100644 (file)
@@ -1315,11 +1315,21 @@ void SurfaceFlinger::updateVrFlinger() {
     // parts of this class rely on the primary display always being available.
     createDefaultDisplayDevice();
 
-    // Reset the timing values to account for the period of the swapped in HWC
-    const auto& activeConfig = mHwc->getActiveConfig(HWC_DISPLAY_PRIMARY);
-    const nsecs_t period = activeConfig->getVsyncPeriod();
-    mAnimFrameTracker.setDisplayRefreshPeriod(period);
-    setCompositorTimingSnapped(0, period, 0);
+    // Re-enable default display.
+    sp<LambdaMessage> requestMessage = new LambdaMessage([&]() {
+        sp<DisplayDevice> hw(getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]));
+        setPowerModeInternal(hw, HWC_POWER_MODE_NORMAL);
+
+        // Reset the timing values to account for the period of the swapped in HWC
+        const auto& activeConfig = mHwc->getActiveConfig(HWC_DISPLAY_PRIMARY);
+        const nsecs_t period = activeConfig->getVsyncPeriod();
+        mAnimFrameTracker.setDisplayRefreshPeriod(period);
+
+        // Use phase of 0 since phase is not known.
+        // Use latency of 0, which will snap to the ideal latency.
+        setCompositorTimingSnapped(0, period, 0);
+    });
+    postMessageAsync(requestMessage);
 
     android_atomic_or(1, &mRepaintEverything);
     setTransactionFlags(eDisplayTransactionNeeded);