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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2879973002: Expose Gamepad API instance for Cardboard button (Closed)
Patch Set: fix crash in tests Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD: 447 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD:
448 viewerType = ViewerType::CARDBOARD; 448 viewerType = ViewerType::CARDBOARD;
449 break; 449 break;
450 default: 450 default:
451 NOTREACHED(); 451 NOTREACHED();
452 viewerType = ViewerType::UNKNOWN_TYPE; 452 viewerType = ViewerType::UNKNOWN_TYPE;
453 break; 453 break;
454 } 454 }
455 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType), 455 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType),
456 static_cast<int>(ViewerType::VIEWER_TYPE_MAX)); 456 static_cast<int>(ViewerType::VIEWER_TYPE_MAX));
457
458 cardboard_ = (viewerType == ViewerType::CARDBOARD);
459 if (cardboard_ && web_vr_mode_) {
460 browser_->ToggleCardboardGamepad(true);
461 }
457 } 462 }
458 463
459 void VrShellGl::InitializeRenderer() { 464 void VrShellGl::InitializeRenderer() {
460 gvr_api_->InitializeGl(); 465 gvr_api_->InitializeGl();
461 vr::Mat4f head_pose; 466 vr::Mat4f head_pose;
462 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose); 467 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose);
463 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose); 468 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose);
464 469
465 std::vector<gvr::BufferSpec> specs; 470 std::vector<gvr::BufferSpec> specs;
466 // For kFramePrimaryBuffer (primary VrShell and WebVR content) 471 // For kFramePrimaryBuffer (primary VrShell and WebVR content)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 webvr_right_viewport_.get()); 536 webvr_right_viewport_.get());
532 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); 537 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer);
533 538
534 browser_->GvrDelegateReady(); 539 browser_->GvrDelegateReady();
535 } 540 }
536 541
537 void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) { 542 void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) {
538 controller_->UpdateState(head_direction); 543 controller_->UpdateState(head_direction);
539 pointer_start_ = controller_->GetPointerStart(); 544 pointer_start_ = controller_->GetPointerStart();
540 545
541 browser_->UpdateGamepadData(controller_->GetGamepadData()); 546 device::GvrGamepadData controller_data = controller_->GetGamepadData();
547 browser_->UpdateGamepadData(controller_data);
542 } 548 }
543 549
544 void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) { 550 void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) {
545 if (scene_->is_exiting()) { 551 if (scene_->is_exiting()) {
546 // When we're exiting, we don't show the reticle and the only input 552 // When we're exiting, we don't show the reticle and the only input
547 // processing we do is to handle immediate exits. 553 // processing we do is to handle immediate exits.
548 SendImmediateExitRequestIfNecessary(); 554 SendImmediateExitRequestIfNecessary();
549 return; 555 return;
550 } 556 }
551 557
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 gvr_api_->ResumeTracking(); 1401 gvr_api_->ResumeTracking();
1396 controller_->OnResume(); 1402 controller_->OnResume();
1397 if (ready_to_draw_) { 1403 if (ready_to_draw_) {
1398 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this))); 1404 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this)));
1399 OnVSync(); 1405 OnVSync();
1400 } 1406 }
1401 } 1407 }
1402 1408
1403 void VrShellGl::SetWebVrMode(bool enabled) { 1409 void VrShellGl::SetWebVrMode(bool enabled) {
1404 web_vr_mode_ = enabled; 1410 web_vr_mode_ = enabled;
1411
1412 if (cardboard_) {
1413 browser_->ToggleCardboardGamepad(enabled);
1414 }
1415
1405 if (!enabled) { 1416 if (!enabled) {
1406 submit_client_.reset(); 1417 submit_client_.reset();
1407 } 1418 }
1408 } 1419 }
1409 1420
1410 void VrShellGl::UpdateWebVRTextureBounds(int16_t frame_index, 1421 void VrShellGl::UpdateWebVRTextureBounds(int16_t frame_index,
1411 const gfx::RectF& left_bounds, 1422 const gfx::RectF& left_bounds,
1412 const gfx::RectF& right_bounds, 1423 const gfx::RectF& right_bounds,
1413 const gfx::Size& source_size) { 1424 const gfx::Size& source_size) {
1414 if (frame_index < 0) { 1425 if (frame_index < 0) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 // This assumes that the initial webvr_surface_size_ was set to the 1539 // This assumes that the initial webvr_surface_size_ was set to the
1529 // appropriate recommended render resolution as the default size during 1540 // appropriate recommended render resolution as the default size during
1530 // InitializeGl. Revisit if the initialization order changes. 1541 // InitializeGl. Revisit if the initialization order changes.
1531 device::mojom::VRDisplayInfoPtr info = 1542 device::mojom::VRDisplayInfoPtr info =
1532 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1543 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1533 webvr_surface_size_, device_id); 1544 webvr_surface_size_, device_id);
1534 browser_->RunVRDisplayInfoCallback(callback, &info); 1545 browser_->RunVRDisplayInfoCallback(callback, &info);
1535 } 1546 }
1536 1547
1537 } // namespace vr_shell 1548 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | device/gamepad/gamepad_pad_state_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698