Revert "Revert "Tie vr flinger to persistent vr mode""
This reverts commit 7480c060cb3466d97ec3125d61bbace153f534c8.
Transfer display control to vr flinger when persistent vr mode is
entered, rather than when vr mode is entered. This allows cardboard
apps, which will invoke vr mode but not persistent vr mode, to work as
in N.
This activates vr flinger at device boot for Daydream ready devices,
which fixes an issue where an app would attempt to create a surface
before vr flinger was running, which would hang indefinitely.
The VrManager listener for persistent vr mode is put in vr flinger
instead of surface flinger. This is cleaner since the vr interaction
with the rest of the device is now consolidated in vr flinger.
While testing I encountered a problem where vr flinger was given control
of the display but vsync was turned off, causing vr flinger's post
thread to hang. I changed the vr flinger logic to give control over
vsync and other display settings to the post thread, and took the
opportunity to further simplify and improve vr flinger's thread
interactions.
Bug: 35885165
Test: Manually confirmed that when persistent vr mode is not invoked we
get the N-based render implementation, and when persistent vr mode is
invoked we get vr flinger.
Change-Id: I3b5ad599cc0748e38b861c714c4cc3118f854acf
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 921ecf6..e3637f5 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -84,7 +84,6 @@
class EventControlThread;
class VSyncSource;
class InjectVSyncSource;
-class VrStateCallbacks;
namespace dvr {
class VrFlinger;
@@ -211,7 +210,6 @@
friend class EventThread;
friend class Layer;
friend class MonitoredProducer;
- friend class VrStateCallbacks;
// This value is specified in number of frames. Log frame stats at most
// every half hour.
@@ -532,9 +530,8 @@
void clearHwcLayers(const LayerVector& layers);
void resetHwc();
- // Check to see if we should change to or from vr mode, and if so, perform
- // the handoff.
- void updateVrMode();
+ // Check to see if we should handoff to vr flinger.
+ void updateVrFlinger();
#endif
/* ------------------------------------------------------------------------
@@ -604,7 +601,6 @@
DefaultKeyedVector< wp<IBinder>, sp<DisplayDevice> > mDisplays;
// don't use a lock for these, we don't care
- int mVrModeSupported;
int mDebugRegion;
int mDebugDDMS;
int mDebugDisableHWC;
@@ -701,9 +697,8 @@
status_t CheckTransactCodeCredentials(uint32_t code);
#ifdef USE_HWC2
- sp<VrStateCallbacks> mVrStateCallbacks;
-
- std::atomic<bool> mEnterVrMode;
+ std::atomic<bool> mVrFlingerRequestsDisplay;
+ static bool useVrFlinger;
#endif
};
}; // namespace android