Merge "Create VR HWComposer without locks held"
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2781e8c..60c71b3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -176,8 +176,10 @@
mFrameBuckets(),
mTotalTime(0),
mLastSwapTime(0),
- mNumLayers(0),
- mEnterVrMode(false)
+ mNumLayers(0)
+#ifdef USE_HWC2
+ ,mEnterVrMode(false)
+#endif
{
ALOGI("SurfaceFlinger is starting");
@@ -1204,12 +1206,17 @@
}
void SurfaceFlinger::updateVrMode() {
+ bool enteringVrMode = mEnterVrMode;
+ if (enteringVrMode == mHwc->isUsingVrComposer()) {
+ return;
+ }
+ if (enteringVrMode && !mVrHwc) {
+ // Construct new HWComposer without holding any locks.
+ mVrHwc = new HWComposer(true);
+ ALOGV("Vr HWC created");
+ }
{
Mutex::Autolock _l(mStateLock);
- bool enteringVrMode = mEnterVrMode;
- if (enteringVrMode == mHwc->isUsingVrComposer()) {
- return;
- }
if (enteringVrMode) {
// Start vrflinger thread, if it hasn't been started already.
@@ -1224,11 +1231,6 @@
}
}
- if (!mVrHwc) {
- mVrHwc = new HWComposer(true);
- ALOGV("Vr HWC created");
- }
-
resetHwc();
mHwc = mVrHwc;