Loading services/vr/vr_window_manager/aidl/android/service/vr/IVrWindowManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,5 +24,6 @@ interface IVrWindowManager { void enterVrMode() = 2; void exitVrMode() = 3; void setDebugMode(int mode) = 4; void set2DMode(int mode) = 5; } services/vr/vr_window_manager/display_view.cpp +21 −7 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ namespace dvr { namespace { constexpr float kLayerScaleFactor = 3.0f; constexpr unsigned int kVRAppLayerCount = 2; constexpr unsigned int kMaximumPendingFrames = 8; // clang-format off Loading Loading @@ -99,7 +98,7 @@ mat4 GetLayerTransform(const TextureLayer& texture_layer, float display_width, // Determine if ths frame should be shown or hidden. ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame, uint32_t vr_app) { uint32_t *appid) { auto& layers = frame.layers(); // TODO(achaulk): Figure out how to identify the current VR app for 2D app Loading @@ -120,6 +119,11 @@ ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame, return ViewMode::Hidden; } if(layers[index].appid != *appid) { *appid = layers[index].appid; return ViewMode::App; } // This is the VR app, ignore it. index++; Loading @@ -136,6 +140,7 @@ ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame, if (!layers[i].should_skip_layer()) return ViewMode::VR; } return ViewMode::Hidden; } Loading Loading @@ -198,16 +203,25 @@ void DisplayView::OnDrawFrame(SurfaceFlingerView* surface_flinger_view, base::unique_fd DisplayView::OnFrame(std::unique_ptr<HwcCallback::Frame> frame, bool debug_mode, bool* showing) { ViewMode visibility = CalculateVisibilityFromLayerConfig(*frame.get(), current_vr_app_); uint32_t app = current_vr_app_; ViewMode visibility = CalculateVisibilityFromLayerConfig(*frame.get(), &app); if (visibility == ViewMode::Hidden && debug_mode) visibility = ViewMode::VR; if (frame->layers().empty()) if (frame->layers().empty()) { current_vr_app_ = 0; else current_vr_app_ = frame->layers().front().appid; } else if (visibility == ViewMode::App) { // This is either a VR app switch or a 2D app launching. // If we can have VR apps, update if it's 0. if (!always_2d_ && (current_vr_app_ == 0 || !use_2dmode_)) { visibility = ViewMode::Hidden; current_vr_app_ = app; } } else if (!current_vr_app_) { // The VR app is running. current_vr_app_ = app; } pending_frames_.emplace_back(std::move(frame), visibility); Loading services/vr/vr_window_manager/display_view.h +5 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ class DisplayView { uint32_t id() const { return id_; } int touchpad_id() const { return touchpad_id_; } void set_2dmode(bool mode) { use_2dmode_ = mode; } void set_always_2d(bool mode) { always_2d_ = mode; } private: bool IsHit(const vec3& view_location, const vec3& view_direction, vec3* hit_location, vec2* hit_location_in_window_coord, Loading Loading @@ -79,6 +82,8 @@ class DisplayView { vec2 ime_top_left_; vec2 ime_size_; bool has_ime_ = false; bool use_2dmode_ = false; bool always_2d_ = false; struct PendingFrame { PendingFrame() = default; Loading services/vr/vr_window_manager/shell_view.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ namespace dvr { namespace { constexpr uint32_t kPrimaryDisplayId = 1; const std::string kVertexShader = SHADER0([]() { layout(location = 0) in vec4 aPosition; layout(location = 1) in vec4 aTexCoord; Loading Loading @@ -96,7 +98,7 @@ mat4 GetHorizontallyAlignedMatrixFromPose(const Posef& pose) { } int GetTouchIdForDisplay(uint32_t display) { return display == 1 ? DVR_VIRTUAL_TOUCHPAD_PRIMARY return display == kPrimaryDisplayId ? DVR_VIRTUAL_TOUCHPAD_PRIMARY : DVR_VIRTUAL_TOUCHPAD_VIRTUAL; } Loading Loading @@ -190,6 +192,11 @@ void ShellView::dumpInternal(String8& result) { result.append("\n"); } void ShellView::Set2DMode(bool mode) { if (!displays_.empty()) displays_[0]->set_2dmode(mode); } void ShellView::OnDrawFrame() { bool visible = false; Loading Loading @@ -253,6 +260,9 @@ DisplayView* ShellView::FindOrCreateDisplay(uint32_t id) { } auto display = new DisplayView(id, GetTouchIdForDisplay(id)); // Virtual displays only ever have 2D apps so force it. if (id != kPrimaryDisplayId) display->set_always_2d(true); new_displays_.emplace_back(display); return display; } Loading services/vr/vr_window_manager/shell_view.h +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ class ShellView : public Application, void EnableDebug(bool debug) override; void VrMode(bool mode) override; void dumpInternal(String8& result) override; void Set2DMode(bool mode) override; protected: void DrawEye(EyeType eye, const mat4& perspective, const mat4& eye_matrix, Loading Loading
services/vr/vr_window_manager/aidl/android/service/vr/IVrWindowManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,5 +24,6 @@ interface IVrWindowManager { void enterVrMode() = 2; void exitVrMode() = 3; void setDebugMode(int mode) = 4; void set2DMode(int mode) = 5; }
services/vr/vr_window_manager/display_view.cpp +21 −7 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ namespace dvr { namespace { constexpr float kLayerScaleFactor = 3.0f; constexpr unsigned int kVRAppLayerCount = 2; constexpr unsigned int kMaximumPendingFrames = 8; // clang-format off Loading Loading @@ -99,7 +98,7 @@ mat4 GetLayerTransform(const TextureLayer& texture_layer, float display_width, // Determine if ths frame should be shown or hidden. ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame, uint32_t vr_app) { uint32_t *appid) { auto& layers = frame.layers(); // TODO(achaulk): Figure out how to identify the current VR app for 2D app Loading @@ -120,6 +119,11 @@ ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame, return ViewMode::Hidden; } if(layers[index].appid != *appid) { *appid = layers[index].appid; return ViewMode::App; } // This is the VR app, ignore it. index++; Loading @@ -136,6 +140,7 @@ ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame, if (!layers[i].should_skip_layer()) return ViewMode::VR; } return ViewMode::Hidden; } Loading Loading @@ -198,16 +203,25 @@ void DisplayView::OnDrawFrame(SurfaceFlingerView* surface_flinger_view, base::unique_fd DisplayView::OnFrame(std::unique_ptr<HwcCallback::Frame> frame, bool debug_mode, bool* showing) { ViewMode visibility = CalculateVisibilityFromLayerConfig(*frame.get(), current_vr_app_); uint32_t app = current_vr_app_; ViewMode visibility = CalculateVisibilityFromLayerConfig(*frame.get(), &app); if (visibility == ViewMode::Hidden && debug_mode) visibility = ViewMode::VR; if (frame->layers().empty()) if (frame->layers().empty()) { current_vr_app_ = 0; else current_vr_app_ = frame->layers().front().appid; } else if (visibility == ViewMode::App) { // This is either a VR app switch or a 2D app launching. // If we can have VR apps, update if it's 0. if (!always_2d_ && (current_vr_app_ == 0 || !use_2dmode_)) { visibility = ViewMode::Hidden; current_vr_app_ = app; } } else if (!current_vr_app_) { // The VR app is running. current_vr_app_ = app; } pending_frames_.emplace_back(std::move(frame), visibility); Loading
services/vr/vr_window_manager/display_view.h +5 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ class DisplayView { uint32_t id() const { return id_; } int touchpad_id() const { return touchpad_id_; } void set_2dmode(bool mode) { use_2dmode_ = mode; } void set_always_2d(bool mode) { always_2d_ = mode; } private: bool IsHit(const vec3& view_location, const vec3& view_direction, vec3* hit_location, vec2* hit_location_in_window_coord, Loading Loading @@ -79,6 +82,8 @@ class DisplayView { vec2 ime_top_left_; vec2 ime_size_; bool has_ime_ = false; bool use_2dmode_ = false; bool always_2d_ = false; struct PendingFrame { PendingFrame() = default; Loading
services/vr/vr_window_manager/shell_view.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ namespace dvr { namespace { constexpr uint32_t kPrimaryDisplayId = 1; const std::string kVertexShader = SHADER0([]() { layout(location = 0) in vec4 aPosition; layout(location = 1) in vec4 aTexCoord; Loading Loading @@ -96,7 +98,7 @@ mat4 GetHorizontallyAlignedMatrixFromPose(const Posef& pose) { } int GetTouchIdForDisplay(uint32_t display) { return display == 1 ? DVR_VIRTUAL_TOUCHPAD_PRIMARY return display == kPrimaryDisplayId ? DVR_VIRTUAL_TOUCHPAD_PRIMARY : DVR_VIRTUAL_TOUCHPAD_VIRTUAL; } Loading Loading @@ -190,6 +192,11 @@ void ShellView::dumpInternal(String8& result) { result.append("\n"); } void ShellView::Set2DMode(bool mode) { if (!displays_.empty()) displays_[0]->set_2dmode(mode); } void ShellView::OnDrawFrame() { bool visible = false; Loading Loading @@ -253,6 +260,9 @@ DisplayView* ShellView::FindOrCreateDisplay(uint32_t id) { } auto display = new DisplayView(id, GetTouchIdForDisplay(id)); // Virtual displays only ever have 2D apps so force it. if (id != kPrimaryDisplayId) display->set_always_2d(true); new_displays_.emplace_back(display); return display; } Loading
services/vr/vr_window_manager/shell_view.h +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ class ShellView : public Application, void EnableDebug(bool debug) override; void VrMode(bool mode) override; void dumpInternal(String8& result) override; void Set2DMode(bool mode) override; protected: void DrawEye(EyeType eye, const mat4& perspective, const mat4& eye_matrix, Loading