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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 webvr_right_viewport_.get()); | 493 webvr_right_viewport_.get()); |
494 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); | 494 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); |
495 | 495 |
496 browser_->GvrDelegateReady(); | 496 browser_->GvrDelegateReady(); |
497 } | 497 } |
498 | 498 |
499 void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) { | 499 void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) { |
500 controller_->UpdateState(head_direction); | 500 controller_->UpdateState(head_direction); |
501 pointer_start_ = controller_->GetPointerStart(); | 501 pointer_start_ = controller_->GetPointerStart(); |
502 | 502 |
503 browser_->UpdateGamepadData(controller_->GetGamepadData()); | 503 device::GvrGamepadData controller_data = controller_->GetGamepadData(); |
504 controller_data.is_screen_touching = currently_touched_; | |
505 browser_->UpdateGamepadData(controller_data); | |
504 } | 506 } |
505 | 507 |
506 void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) { | 508 void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) { |
507 if (ShouldDrawWebVr()) { | 509 if (ShouldDrawWebVr()) { |
508 // Process screen touch events for Cardboard button compatibility. | 510 // Process screen touch events for Cardboard button compatibility. |
509 // Also send tap events for controller "touchpad click" events. | 511 // Also send tap events for controller "touchpad click" events. |
510 if (touch_pending_ || | 512 if (touch_pending_ || |
511 controller_->ButtonUpHappened( | 513 controller_->ButtonUpHappened( |
512 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_CLICK)) { | 514 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_CLICK)) { |
513 touch_pending_ = false; | 515 touch_pending_ = false; |
514 std::unique_ptr<WebGestureEvent> gesture(new WebGestureEvent( | 516 std::unique_ptr<WebGestureEvent> gesture(new WebGestureEvent( |
515 WebInputEvent::kGestureTapDown, WebInputEvent::kNoModifiers, | 517 WebInputEvent::kGestureTapDown, WebInputEvent::kNoModifiers, |
516 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF())); | 518 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF())); |
519 | |
billorr1
2017/05/12 18:25:41
nit: remove this extra blank line
billorr1
2017/05/15 23:04:17
Done.
| |
517 gesture->source_device = blink::kWebGestureDeviceTouchpad; | 520 gesture->source_device = blink::kWebGestureDeviceTouchpad; |
518 gesture->x = 0; | 521 gesture->x = 0; |
519 gesture->y = 0; | 522 gesture->y = 0; |
520 SendGestureToContent(std::move(gesture)); | 523 SendGestureToContent(std::move(gesture)); |
521 DVLOG(1) << __FUNCTION__ << ": sent CLICK gesture"; | 524 DVLOG(1) << __FUNCTION__ << ": sent CLICK gesture"; |
522 } | 525 } |
523 } | 526 } |
524 | 527 |
525 gfx::Vector3dF ergo_neutral_pose; | 528 gfx::Vector3dF ergo_neutral_pose; |
526 if (!controller_->IsConnected()) { | 529 if (!controller_->IsConnected()) { |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 // we're done with the old content. TODO(klausw,crbug.com/700389): | 1187 // we're done with the old content. TODO(klausw,crbug.com/700389): |
1185 // investigate using glDiscardFramebufferEXT here since that's more | 1188 // investigate using glDiscardFramebufferEXT here since that's more |
1186 // efficient on desktop, but it would need a capability check since | 1189 // efficient on desktop, but it would need a capability check since |
1187 // it's not supported on older devices such as Nexus 5X. | 1190 // it's not supported on older devices such as Nexus 5X. |
1188 glClear(GL_COLOR_BUFFER_BIT); | 1191 glClear(GL_COLOR_BUFFER_BIT); |
1189 | 1192 |
1190 glViewport(0, 0, webvr_surface_size_.width(), webvr_surface_size_.height()); | 1193 glViewport(0, 0, webvr_surface_size_.width(), webvr_surface_size_.height()); |
1191 vr_shell_renderer_->GetWebVrRenderer()->Draw(webvr_texture_id_); | 1194 vr_shell_renderer_->GetWebVrRenderer()->Draw(webvr_texture_id_); |
1192 } | 1195 } |
1193 | 1196 |
1194 void VrShellGl::OnTriggerEvent() { | 1197 void VrShellGl::OnTriggerEvent(bool touching) { |
1195 // Set a flag to handle this on the render thread at the next frame. | 1198 // Set a flag to handle this on the render thread at the next frame. |
1196 touch_pending_ = true; | 1199 touch_pending_ = touch_pending_ || touching; |
1200 currently_touched_ = touching; | |
1197 } | 1201 } |
1198 | 1202 |
1199 void VrShellGl::OnPause() { | 1203 void VrShellGl::OnPause() { |
1200 vsync_task_.Cancel(); | 1204 vsync_task_.Cancel(); |
1201 controller_->OnPause(); | 1205 controller_->OnPause(); |
1202 gvr_api_->PauseTracking(); | 1206 gvr_api_->PauseTracking(); |
1203 } | 1207 } |
1204 | 1208 |
1205 void VrShellGl::OnResume() { | 1209 void VrShellGl::OnResume() { |
1206 gvr_api_->RefreshViewerProfile(); | 1210 gvr_api_->RefreshViewerProfile(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 // This assumes that the initial webvr_surface_size_ was set to the | 1341 // This assumes that the initial webvr_surface_size_ was set to the |
1338 // appropriate recommended render resolution as the default size during | 1342 // appropriate recommended render resolution as the default size during |
1339 // InitializeGl. Revisit if the initialization order changes. | 1343 // InitializeGl. Revisit if the initialization order changes. |
1340 device::mojom::VRDisplayInfoPtr info = | 1344 device::mojom::VRDisplayInfoPtr info = |
1341 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), | 1345 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), |
1342 webvr_surface_size_, device_id); | 1346 webvr_surface_size_, device_id); |
1343 browser_->RunVRDisplayInfoCallback(callback, &info); | 1347 browser_->RunVRDisplayInfoCallback(callback, &info); |
1344 } | 1348 } |
1345 | 1349 |
1346 } // namespace vr_shell | 1350 } // namespace vr_shell |
OLD | NEW |