summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Sakhartchouk <alexst@google.com> 2017-01-28 10:44:15 -0500
committer Alex Vakulenko <avakulenko@google.com> 2017-02-01 18:26:33 -0800
commit897a186b0f887e858e39d8c04b017662854dd09f (patch)
treebbb253602c0cf26afb7fd2d6f5b4c56c6e240e5f
parent6f2a0f7a791def75bb5deaf113a550ee2b72d55d (diff)
Make VrWindowManager system service again.
WIP, For now just build a parallel target until controller data comes from shared memory. Bug: None Test: None Change-Id: I3aa808a4ac6f774f113abadfa76056d350f2a338
-rw-r--r--services/vr/vr_window_manager/Android.mk_disable29
-rw-r--r--services/vr/vr_window_manager/application.cpp25
-rw-r--r--services/vr/vr_window_manager/application.h2
-rw-r--r--services/vr/vr_window_manager/shell_view.cpp5
-rw-r--r--services/vr/vr_window_manager/vr_window_manager.cpp23
-rw-r--r--services/vr/vr_window_manager/vr_wm.rc9
6 files changed, 87 insertions, 6 deletions
diff --git a/services/vr/vr_window_manager/Android.mk_disable b/services/vr/vr_window_manager/Android.mk_disable
index adce4b91c9..d7d98b3d52 100644
--- a/services/vr/vr_window_manager/Android.mk_disable
+++ b/services/vr/vr_window_manager/Android.mk_disable
@@ -14,6 +14,19 @@
LOCAL_PATH := $(call my-dir)
+native_src := \
+ application.cpp \
+ controller_mesh.cpp \
+ elbow_model.cpp \
+ hwc_callback.cpp \
+ reticle.cpp \
+ render_thread.cpp \
+ shell_view.cpp \
+ surface_flinger_view.cpp \
+ texture.cpp \
+ vr_window_manager.cpp \
+ ../virtual_touchpad/aidl/android/dvr/VirtualTouchpadService.aidl \
+
src := \
vr_window_manager_jni.cpp \
application.cpp \
@@ -80,6 +93,22 @@ LOCAL_CXX_STL := libc++_static
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(native_src)
+LOCAL_C_INCLUDES := hardware/qcom/display/msm8996/libgralloc
+LOCAL_STATIC_LIBRARIES := $(static_libs)
+LOCAL_SHARED_LIBRARIES := $(shared_libs)
+LOCAL_SHARED_LIBRARIES += libgvr
+LOCAL_STATIC_LIBRARIES += libgvr_ext
+LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
+LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CFLAGS += -DLOG_TAG=\"VrWindowManager\"
+LOCAL_LDLIBS := -llog
+LOCAL_MODULE := vr_wm
+LOCAL_MODULE_TAGS := optional
+LOCAL_INIT_RC := vr_wm.rc
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := VrWindowManager
# We need to be priveleged to run as the system user, which is necessary for
diff --git a/services/vr/vr_window_manager/application.cpp b/services/vr/vr_window_manager/application.cpp
index f84a0d1060..081de74fa4 100644
--- a/services/vr/vr_window_manager/application.cpp
+++ b/services/vr/vr_window_manager/application.cpp
@@ -100,6 +100,16 @@ int Application::AllocateResources() {
fov_[1] = FieldOfView(lens_info.right_fov[0], lens_info.right_fov[1],
lens_info.right_fov[2], lens_info.right_fov[3]);
+ if (java_env_) {
+ int ret = InitializeController();
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+int Application::InitializeController() {
gvr_context_ = gvr::GvrApi::Create(java_env_, app_context_, class_loader_);
if (gvr_context_ == nullptr) {
ALOGE("Gvr context creation failed");
@@ -170,7 +180,7 @@ void Application::DrawFrame() {
// Thread should block if we are invisible or not fully initialized.
std::unique_lock<std::mutex> lock(mutex_);
wake_up_init_and_render_.wait(lock, [this]() {
- return is_visible_ && initialized_ || !main_thread_tasks_.empty();
+ return (is_visible_ && initialized_) || !main_thread_tasks_.empty();
});
// Process main thread tasks if there are any.
@@ -245,6 +255,9 @@ void Application::DrawFrame() {
}
void Application::ProcessControllerInput() {
+ if (!controller_)
+ return;
+
controller_state_->Update(*controller_);
gvr::ControllerApiStatus new_api_status = controller_state_->GetApiStatus();
gvr::ControllerConnectionState new_connection_state =
@@ -286,10 +299,12 @@ void Application::SetVisibility(bool visible) {
if (changed) {
is_visible_ = visible;
dvrGraphicsSurfaceSetVisible(graphics_context_, is_visible_);
- if (is_visible_)
- controller_->Resume();
- else
- controller_->Pause();
+ if (controller_) {
+ if (is_visible_)
+ controller_->Resume();
+ else
+ controller_->Pause();
+ }
OnVisibilityChanged(is_visible_);
}
}
diff --git a/services/vr/vr_window_manager/application.h b/services/vr/vr_window_manager/application.h
index 332168232c..47a0927273 100644
--- a/services/vr/vr_window_manager/application.h
+++ b/services/vr/vr_window_manager/application.h
@@ -54,6 +54,8 @@ class Application {
void QueueTask(MainThreadTask task);
+ int InitializeController();
+
DvrGraphicsContext* graphics_context_ = nullptr;
DvrPose* pose_client_ = nullptr;
diff --git a/services/vr/vr_window_manager/shell_view.cpp b/services/vr/vr_window_manager/shell_view.cpp
index b9a4f860f8..3b18f7410c 100644
--- a/services/vr/vr_window_manager/shell_view.cpp
+++ b/services/vr/vr_window_manager/shell_view.cpp
@@ -573,7 +573,7 @@ void ShellView::DrawReticle(const mat4& perspective, const mat4& eye_matrix,
vec3 pointer_location = last_pose_.GetPosition();
quat view_quaternion = last_pose_.GetRotation();
- if (controller_api_status_ == gvr::kControllerApiOk) {
+ if (controller_ && controller_api_status_ == gvr::kControllerApiOk) {
view_quaternion = FromGvrQuatf(controller_orientation_);
vec4 controller_location = controller_translate_ * vec4(0, 0, 0, 1);
pointer_location = vec3(controller_location.x(), controller_location.y(),
@@ -618,6 +618,9 @@ void ShellView::DrawReticle(const mat4& perspective, const mat4& eye_matrix,
void ShellView::DrawController(const mat4& perspective, const mat4& eye_matrix,
const mat4& head_matrix) {
+ if (!controller_)
+ return;
+
controller_program_->Use();
mat4 mvp = perspective * eye_matrix * head_matrix;
diff --git a/services/vr/vr_window_manager/vr_window_manager.cpp b/services/vr/vr_window_manager/vr_window_manager.cpp
new file mode 100644
index 0000000000..736a14f1ea
--- /dev/null
+++ b/services/vr/vr_window_manager/vr_window_manager.cpp
@@ -0,0 +1,23 @@
+#include <binder/ProcessState.h>
+
+#include "shell_view.h"
+
+int main(int /* argc */, char** /* argv */) {
+ android::ProcessState::self()->startThreadPool();
+
+ android::dvr::ShellView app;
+ if (app.Initialize(nullptr, nullptr, nullptr)) {
+ ALOGE("Failed to initialize");
+ return 1;
+ }
+
+ if (app.AllocateResources()) {
+ ALOGE("Failed to allocate resources");
+ return 1;
+ }
+
+ while (true)
+ app.DrawFrame();
+
+ return 0;
+}
diff --git a/services/vr/vr_window_manager/vr_wm.rc b/services/vr/vr_window_manager/vr_wm.rc
new file mode 100644
index 0000000000..143b91609a
--- /dev/null
+++ b/services/vr/vr_window_manager/vr_wm.rc
@@ -0,0 +1,9 @@
+service vr_wm /system/bin/vr_wm
+ class core
+ user system
+ group system graphics input
+ cpuset /system
+ disabled
+
+on property:persist.daydream.vr_wm=1
+ enable vr_wm