Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2570553004: Clean up some VrShell threading issues and remove unnecessary WeakPtr types. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_shell_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index a2ac61588d22344527cf9a215cd35587f0e756c6..2f4daab5b06f5caa1f950066e869b5a4e50118da 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -8,7 +8,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/android/vr_shell/ui_elements.h"
-#include "chrome/browser/android/vr_shell/ui_interface.h"
#include "chrome/browser/android/vr_shell/ui_scene.h"
#include "chrome/browser/android/vr_shell/vr_controller.h"
#include "chrome/browser/android/vr_shell/vr_gl_util.h"
@@ -172,14 +171,14 @@ int GetPixelEncodedPoseIndexByte() {
} // namespace
VrShellGl::VrShellGl(
- VrShell* vr_shell,
const base::WeakPtr<VrShell>& weak_vr_shell,
const base::WeakPtr<VrInputManager>& content_input_manager,
const base::WeakPtr<VrInputManager>& ui_input_manager,
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
- gvr_context* gvr_api)
- : task_runner_(base::ThreadTaskRunnerHandle::Get()),
- vr_shell_(vr_shell),
+ gvr_context* gvr_api,
+ bool initially_web_vr)
+ : web_vr_mode_(initially_web_vr),
+ task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_vr_shell_(weak_vr_shell),
content_input_manager_(content_input_manager),
ui_input_manager_(ui_input_manager),
@@ -383,28 +382,16 @@ void VrShellGl::InitializeRenderer() {
void VrShellGl::UpdateController(const gvr::Vec3f& forward_vector) {
controller_->UpdateState();
-#if defined(ENABLE_VR_SHELL)
- // TODO(mthiesse): Fix menu button handling, which should be posted to the UI
- // thread instead of handled here.
// Note that button up/down state is transient, so ButtonUpHappened only
// returns true for a single frame (and we're guaranteed not to miss it).
if (controller_->ButtonUpHappened(
gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP)) {
-// html_interface_->SetMenuMode(!html_interface_->GetMenuMode());
-
- // TODO(mthiesse): The page is no longer visible when in menu mode. We
- // should unfocus or otherwise let it know it's hidden.
-// if (html_interface_->GetMode() == UiInterface::Mode::WEB_VR) {
-// const auto&& task = html_interface_->GetMenuMode() ?
-// &device::GvrDeviceProvider::OnDisplayBlur :
-// &device::GvrDeviceProvider::OnDisplayFocus;
-// main_thread_task_runner_->PostTask(
-// FROM_HERE, base::Bind(task, delegate_->GetDeviceProvider()));
-// }
+ main_thread_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&VrShell::AppButtonPressed, weak_vr_shell_));
}
-#endif
- if (vr_shell_->GetUiInterface()->GetMode() == UiInterface::Mode::WEB_VR) {
+
+ if (web_vr_mode_) {
// Process screen touch events for Cardboard button compatibility.
// Also send tap events for controller "touchpad click" events.
if (touch_pending_ || controller_->ButtonUpHappened(
@@ -612,7 +599,7 @@ void VrShellGl::DrawFrame() {
// TODO(klausw): Fix this. Resizing buffers here leads to webVR mode showing
// nothing but a black screen.
-// if (vr_shell_->GetUiInterface()->GetMode() == UiInterface::Mode::WEB_VR) {
+// if (web_vr_mode_) {
// // If needed, resize the primary buffer for use with WebVR.
// if (render_size_primary_ != render_size_primary_webvr_) {
// if (!render_size_primary_webvr_.width) {
@@ -654,7 +641,7 @@ void VrShellGl::DrawFrame() {
UpdateController(GetForwardVector(head_pose));
- if (vr_shell_->GetUiInterface()->GetMode() == UiInterface::Mode::WEB_VR) {
+ if (web_vr_mode_) {
DrawWebVr();
// When using async reprojection, we need to know which pose was used in
@@ -712,7 +699,7 @@ void VrShellGl::DrawVrShell(const gvr::Mat4f& head_pose,
}
}
- if (vr_shell_->GetUiInterface()->GetMode() == UiInterface::Mode::WEB_VR) {
+ if (web_vr_mode_) {
// WebVR is incompatible with 3D world compositing since the
// depth buffer was already populated with unknown scaling - the
// WebVR app has full control over zNear/zFar. Just leave the
@@ -795,8 +782,7 @@ void VrShellGl::DrawUiView(const gvr::Mat4f* head_pose,
view_matrix);
DrawElements(render_matrix, elements);
- if (head_pose != nullptr &&
- vr_shell_->GetUiInterface()->GetMode() != UiInterface::Mode::WEB_VR) {
+ if (head_pose != nullptr && !web_vr_mode_) {
DrawCursor(render_matrix);
}
}
@@ -938,11 +924,7 @@ void VrShellGl::OnResume() {
}
void VrShellGl::SetWebVrMode(bool enabled) {
bshe 2016/12/14 16:06:46 Is this function ever being called?
mthiesse 2016/12/14 16:20:43 Yes, VrShell::SetWebVrMode posts to it.
bshe 2016/12/14 17:36:51 dooh. Missed that...
- if (enabled) {
- vr_shell_->GetUiInterface()->SetMode(UiInterface::Mode::WEB_VR);
- } else {
- vr_shell_->GetUiInterface()->SetMode(UiInterface::Mode::STANDARD);
- }
+ web_vr_mode_ = enabled;
}
void VrShellGl::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,

Powered by Google App Engine
This is Rietveld 408576698