Chromium Code Reviews| Index: chrome/browser/android/vr_shell/vr_shell.cc |
| diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc |
| index d14efcd68f02ea36aea729138e461273752b26ee..7f134358762c92b75bd118dbdbcef1be23dfeb48 100644 |
| --- a/chrome/browser/android/vr_shell/vr_shell.cc |
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc |
| @@ -21,6 +21,7 @@ |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/referrer.h" |
| #include "content/public/common/screen_info.h" |
| +#include "device/vr/android/gvr/gvr_device_provider.h" |
| #include "jni/VrShellImpl_jni.h" |
| #include "ui/android/view_android.h" |
| #include "ui/android/window_android.h" |
| @@ -183,8 +184,7 @@ void VrShell::SetDelegate(JNIEnv* env, |
| delegate_ = VrShellDelegate::getNativeDelegate(env, delegate); |
| } |
| -enum class ViewerType |
| -{ |
| +enum class ViewerType { |
| UNKNOWN_TYPE = 0, |
| CARDBOARD = 1, |
| DAYDREAM = 2, |
| @@ -205,8 +205,7 @@ void VrShell::GvrInit(JNIEnv* env, |
| ui_input_manager_ = new VrInputManager(ui_contents_); |
| ViewerType viewerType; |
| - switch (gvr_api_->GetViewerType()) |
| - { |
| + switch (gvr_api_->GetViewerType()) { |
| case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM: |
| viewerType = ViewerType::DAYDREAM; |
| break; |
| @@ -268,7 +267,31 @@ void VrShell::InitializeGl(JNIEnv* env, |
| void VrShell::UpdateController(const gvr::Vec3f& forward_vector) { |
| controller_->UpdateState(); |
| std::unique_ptr<WebGestureEvent> gesture = controller_->DetectGesture(); |
| - |
| +#if defined(ENABLE_VR_SHELL) |
| + // Note that button up/down state is transient, so IsButtonUp only returns |
| + // true for a single frame (and we're guaranteed not to miss it). |
| + if (controller_->IsButtonUp( |
| + gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP)) { |
| + if (html_interface_->GetMode() == UiInterface::Mode::MENU) { |
| + // Temporary: Hit app button a second time to exit menu mode. |
| + if (webvr_mode_) { |
| + html_interface_->SetMode(UiInterface::Mode::WEB_VR); |
| + delegate_->GetDeviceProvider()->ResumePresent(); |
| + } else { |
| + html_interface_->SetMode(UiInterface::Mode::STANDARD); |
| + } |
| + } else { |
| + if (html_interface_->GetMode() == UiInterface::Mode::WEB_VR) { |
| + delegate_->GetDeviceProvider()->PausePresent(); |
| + } |
| + html_interface_->SetMode(UiInterface::Mode::MENU); |
| + // TODO(mthiesse): Also pause tracking for all webvr pages. |
|
bajones
2016/11/01 18:11:31
Is this comment accurate? Seems like we're already
mthiesse
2016/11/02 14:39:02
As discussed offline, we're going to ignore the no
bshe
2016/11/02 14:58:40
Does this mean magic window mode won't ship in nor
mthiesse
2016/11/02 15:03:32
It doesn't mean either of those things. It means w
|
| + } |
| + } |
| +#endif |
| + if (html_interface_->GetMode() == UiInterface::Mode::WEB_VR) { |
| + return; |
| + } |
| // TODO(asimjour) for now, scroll is sent to the main content. |
| if (gesture->type == WebInputEvent::GestureScrollBegin || |
| gesture->type == WebInputEvent::GestureScrollUpdate || |
| @@ -408,7 +431,7 @@ uint32_t GetPixelEncodedPoseIndex() { |
| // encodes the pose index, and device/vr/android/gvr/gvr_device.cc |
| // which tracks poses. |
| uint8_t pixels[4]; |
| - // Assume we're reading from the frambebuffer we just wrote to. |
| + // Assume we're reading from the framebuffer we just wrote to. |
| // That's true currently, we may need to use glReadBuffer(GL_BACK) |
| // or equivalent if the rendering setup changes in the future. |
| glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |