Start VR WindowManager in a headless mode.
Only allocate resources when we need to show ourselves
and draw something.
Bug: None
Test: None
Change-Id: Ied48f024b145ee6f574484883375b939e7814e53
diff --git a/services/vr/vr_window_manager/application.cpp b/services/vr/vr_window_manager/application.cpp
index b4568b8..62db639 100644
--- a/services/vr/vr_window_manager/application.cpp
+++ b/services/vr/vr_window_manager/application.cpp
@@ -161,8 +161,10 @@
}
break;
case MainThreadTask::EnteringVrMode:
- if (!initialized_)
- AllocateResources();
+ if (!initialized_) {
+ if (AllocateResources())
+ ALOGE("Failed to allocate resources");
+ }
break;
case MainThreadTask::ExitingVrMode:
if (initialized_)
diff --git a/services/vr/vr_window_manager/render_thread.cpp b/services/vr/vr_window_manager/render_thread.cpp
index 5f777e3..b67a051 100644
--- a/services/vr/vr_window_manager/render_thread.cpp
+++ b/services/vr/vr_window_manager/render_thread.cpp
@@ -75,7 +75,6 @@
jobject android_context = env->NewLocalRef(android_context_global_ref_);
int init_result = shell_view_.Initialize(env, android_context, class_loader);
- init_result += shell_view_.AllocateResources();
init_result_promise->set_value(init_result);
if (init_result == 0) {
while (!quit_)
diff --git a/services/vr/vr_window_manager/shell_view.cpp b/services/vr/vr_window_manager/shell_view.cpp
index 52925cf..72a9c1a 100644
--- a/services/vr/vr_window_manager/shell_view.cpp
+++ b/services/vr/vr_window_manager/shell_view.cpp
@@ -395,8 +395,10 @@
// If we are showing ourselves the main thread is not processing anything,
// so give it a kick.
- if (visibility && !current_frame_.visibility)
+ if (visibility && !current_frame_.visibility) {
+ QueueTask(MainThreadTask::EnteringVrMode);
QueueTask(MainThreadTask::Show);
+ }
}
bool ShellView::IsHit(const vec3& view_location, const vec3& view_direction,
diff --git a/services/vr/vr_window_manager/vr_window_manager.cpp b/services/vr/vr_window_manager/vr_window_manager.cpp
index 736a14f..8d9ad79 100644
--- a/services/vr/vr_window_manager/vr_window_manager.cpp
+++ b/services/vr/vr_window_manager/vr_window_manager.cpp
@@ -11,11 +11,6 @@
return 1;
}
- if (app.AllocateResources()) {
- ALOGE("Failed to allocate resources");
- return 1;
- }
-
while (true)
app.DrawFrame();