Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 897a186b authored by Alex Sakhartchouk's avatar Alex Sakhartchouk Committed by Alex Vakulenko
Browse files

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
parent 6f2a0f7a
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -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 \
@@ -79,6 +92,22 @@ LOCAL_MULTILIB := 64
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

+20 −5
Original line number Diff line number Diff line
@@ -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 (controller_) {
      if (is_visible_)
        controller_->Resume();
      else
        controller_->Pause();
    }
    OnVisibilityChanged(is_visible_);
  }
}
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ class Application {

  void QueueTask(MainThreadTask task);

  int InitializeController();

  DvrGraphicsContext* graphics_context_ = nullptr;
  DvrPose* pose_client_ = nullptr;

+4 −1
Original line number Diff line number Diff line
@@ -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;

+23 −0
Original line number Diff line number Diff line
#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;
}
Loading