| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 6 | 6 |
| 7 #include <chrono> | 7 #include <chrono> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 webvr_right_viewport_.get()); | 506 webvr_right_viewport_.get()); |
| 507 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); | 507 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); |
| 508 | 508 |
| 509 browser_->GvrDelegateReady(); | 509 browser_->GvrDelegateReady(); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) { | 512 void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) { |
| 513 controller_->UpdateState(head_direction); | 513 controller_->UpdateState(head_direction); |
| 514 pointer_start_ = controller_->GetPointerStart(); | 514 pointer_start_ = controller_->GetPointerStart(); |
| 515 | 515 |
| 516 browser_->UpdateGamepadData(controller_->GetGamepadData()); | 516 device::GvrGamepadData controller_data = controller_->GetGamepadData(); |
| 517 controller_data.is_screen_touching = currently_touched_; |
| 518 browser_->UpdateGamepadData(controller_data); |
| 517 } | 519 } |
| 518 | 520 |
| 519 void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) { | 521 void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) { |
| 520 HandleWebVrCompatibilityClick(); | 522 HandleWebVrCompatibilityClick(); |
| 521 | 523 |
| 522 gfx::Vector3dF ergo_neutral_pose; | 524 gfx::Vector3dF ergo_neutral_pose; |
| 523 if (!controller_->IsConnected()) { | 525 if (!controller_->IsConnected()) { |
| 524 // No controller detected, set up a gaze cursor that tracks the | 526 // No controller detected, set up a gaze cursor that tracks the |
| 525 // forward direction. | 527 // forward direction. |
| 526 ergo_neutral_pose = {0.0f, 0.0f, -1.0f}; | 528 ergo_neutral_pose = {0.0f, 0.0f, -1.0f}; |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 // we're done with the old content. TODO(klausw,crbug.com/700389): | 1310 // we're done with the old content. TODO(klausw,crbug.com/700389): |
| 1309 // investigate using glDiscardFramebufferEXT here since that's more | 1311 // investigate using glDiscardFramebufferEXT here since that's more |
| 1310 // efficient on desktop, but it would need a capability check since | 1312 // efficient on desktop, but it would need a capability check since |
| 1311 // it's not supported on older devices such as Nexus 5X. | 1313 // it's not supported on older devices such as Nexus 5X. |
| 1312 glClear(GL_COLOR_BUFFER_BIT); | 1314 glClear(GL_COLOR_BUFFER_BIT); |
| 1313 | 1315 |
| 1314 glViewport(0, 0, webvr_surface_size_.width(), webvr_surface_size_.height()); | 1316 glViewport(0, 0, webvr_surface_size_.width(), webvr_surface_size_.height()); |
| 1315 vr_shell_renderer_->GetWebVrRenderer()->Draw(webvr_texture_id_); | 1317 vr_shell_renderer_->GetWebVrRenderer()->Draw(webvr_texture_id_); |
| 1316 } | 1318 } |
| 1317 | 1319 |
| 1318 void VrShellGl::OnTriggerEvent() { | 1320 void VrShellGl::OnTriggerEvent(bool touching) { |
| 1319 // Set a flag to handle this on the render thread at the next frame. | 1321 // Set a flag to handle this on the render thread at the next frame. |
| 1320 touch_pending_ = true; | 1322 touch_pending_ = touch_pending_ || touching; |
| 1323 currently_touched_ = touching; |
| 1321 } | 1324 } |
| 1322 | 1325 |
| 1323 void VrShellGl::OnPause() { | 1326 void VrShellGl::OnPause() { |
| 1324 vsync_task_.Cancel(); | 1327 vsync_task_.Cancel(); |
| 1325 controller_->OnPause(); | 1328 controller_->OnPause(); |
| 1326 gvr_api_->PauseTracking(); | 1329 gvr_api_->PauseTracking(); |
| 1327 } | 1330 } |
| 1328 | 1331 |
| 1329 void VrShellGl::OnResume() { | 1332 void VrShellGl::OnResume() { |
| 1330 gvr_api_->RefreshViewerProfile(); | 1333 gvr_api_->RefreshViewerProfile(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 // This assumes that the initial webvr_surface_size_ was set to the | 1479 // This assumes that the initial webvr_surface_size_ was set to the |
| 1477 // appropriate recommended render resolution as the default size during | 1480 // appropriate recommended render resolution as the default size during |
| 1478 // InitializeGl. Revisit if the initialization order changes. | 1481 // InitializeGl. Revisit if the initialization order changes. |
| 1479 device::mojom::VRDisplayInfoPtr info = | 1482 device::mojom::VRDisplayInfoPtr info = |
| 1480 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), | 1483 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), |
| 1481 webvr_surface_size_, device_id); | 1484 webvr_surface_size_, device_id); |
| 1482 browser_->RunVRDisplayInfoCallback(callback, &info); | 1485 browser_->RunVRDisplayInfoCallback(callback, &info); |
| 1483 } | 1486 } |
| 1484 | 1487 |
| 1485 } // namespace vr_shell | 1488 } // namespace vr_shell |
| OLD | NEW |