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

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

Issue 2865463003: Tracks GVR version crossed with headset type using UMA. (Closed)
Patch Set: Fixed comments Created 3 years, 6 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
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/task_scheduler/post_task.h" 15 #include "base/task_scheduler/post_task.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/browser/android/vr_shell/fps_meter.h" 17 #include "chrome/browser/android/vr_shell/fps_meter.h"
18 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h" 18 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h"
19 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 19 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
20 #include "chrome/browser/android/vr_shell/ui_interface.h" 20 #include "chrome/browser/android/vr_shell/ui_interface.h"
21 #include "chrome/browser/android/vr_shell/ui_scene.h" 21 #include "chrome/browser/android/vr_shell/ui_scene.h"
22 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" 22 #include "chrome/browser/android/vr_shell/vr_browser_interface.h"
23 #include "chrome/browser/android/vr_shell/vr_controller.h" 23 #include "chrome/browser/android/vr_shell/vr_controller.h"
24 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 24 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
25 #include "chrome/browser/android/vr_shell/vr_metrics_util.h"
25 #include "chrome/browser/android/vr_shell/vr_shell.h" 26 #include "chrome/browser/android/vr_shell/vr_shell.h"
26 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 27 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
28 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h"
27 #include "device/vr/android/gvr/gvr_delegate.h" 29 #include "device/vr/android/gvr/gvr_delegate.h"
28 #include "device/vr/android/gvr/gvr_device.h" 30 #include "device/vr/android/gvr/gvr_device.h"
29 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" 31 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
30 #include "device/vr/vr_math.h" 32 #include "device/vr/vr_math.h"
31 #include "third_party/WebKit/public/platform/WebGestureEvent.h" 33 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
32 #include "third_party/WebKit/public/platform/WebInputEvent.h" 34 #include "third_party/WebKit/public/platform/WebInputEvent.h"
33 #include "third_party/WebKit/public/platform/WebMouseEvent.h" 35 #include "third_party/WebKit/public/platform/WebMouseEvent.h"
34 #include "ui/gl/android/scoped_java_surface.h" 36 #include "ui/gl/android/scoped_java_surface.h"
35 #include "ui/gl/android/surface_texture.h" 37 #include "ui/gl/android/surface_texture.h"
36 #include "ui/gl/gl_bindings.h" 38 #include "ui/gl/gl_bindings.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const gfx::Point& loc) { 166 const gfx::Point& loc) {
165 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent( 167 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent(
166 type, blink::WebInputEvent::kNoModifiers, timestamp)); 168 type, blink::WebInputEvent::kNoModifiers, timestamp));
167 mouse_event->pointer_type = blink::WebPointerProperties::PointerType::kMouse; 169 mouse_event->pointer_type = blink::WebPointerProperties::PointerType::kMouse;
168 mouse_event->SetPositionInWidget(loc.x(), loc.y()); 170 mouse_event->SetPositionInWidget(loc.x(), loc.y());
169 mouse_event->click_count = 1; 171 mouse_event->click_count = 1;
170 172
171 return mouse_event; 173 return mouse_event;
172 } 174 }
173 175
174 enum class ViewerType {
175 UNKNOWN_TYPE = 0,
176 CARDBOARD = 1,
177 DAYDREAM = 2,
178 VIEWER_TYPE_MAX,
179 };
180 176
181 void MatfToGvrMat(const vr::Mat4f& in, gvr::Mat4f* out) { 177 void MatfToGvrMat(const vr::Mat4f& in, gvr::Mat4f* out) {
182 // If our std::array implementation doesn't have any non-data members, we can 178 // If our std::array implementation doesn't have any non-data members, we can
183 // just cast the gvr matrix to an std::array. 179 // just cast the gvr matrix to an std::array.
184 static_assert(sizeof(in) == sizeof(*out), 180 static_assert(sizeof(in) == sizeof(*out),
185 "Cannot reinterpret gvr::Mat4f as vr::Matf"); 181 "Cannot reinterpret gvr::Mat4f as vr::Matf");
186 *out = *reinterpret_cast<gvr::Mat4f*>(const_cast<vr::Mat4f*>(&in)); 182 *out = *reinterpret_cast<gvr::Mat4f*>(const_cast<vr::Mat4f*>(&in));
187 } 183 }
188 184
189 void GvrMatToMatf(const gvr::Mat4f& in, vr::Mat4f* out) { 185 void GvrMatToMatf(const gvr::Mat4f& in, vr::Mat4f* out) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 TRACE_EVENT1("gpu", "VrShellGl::OnWebVRFrameAvailable", "frame", frame_index); 424 TRACE_EVENT1("gpu", "VrShellGl::OnWebVRFrameAvailable", "frame", frame_index);
429 pending_frames_.pop(); 425 pending_frames_.pop();
430 426
431 DrawFrame(frame_index); 427 DrawFrame(frame_index);
432 } 428 }
433 429
434 void VrShellGl::GvrInit(gvr_context* gvr_api) { 430 void VrShellGl::GvrInit(gvr_context* gvr_api) {
435 gvr_api_ = gvr::GvrApi::WrapNonOwned(gvr_api); 431 gvr_api_ = gvr::GvrApi::WrapNonOwned(gvr_api);
436 controller_.reset(new VrController(gvr_api)); 432 controller_.reset(new VrController(gvr_api));
437 433
438 ViewerType viewerType; 434 VrMetricsUtil::LogVrViewerType(gvr_api);
439 switch (gvr_api_->GetViewerType()) {
440 case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM:
441 viewerType = ViewerType::DAYDREAM;
442 break;
443 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD:
444 viewerType = ViewerType::CARDBOARD;
445 break;
446 default:
447 NOTREACHED();
448 viewerType = ViewerType::UNKNOWN_TYPE;
449 break;
450 }
451 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType),
452 static_cast<int>(ViewerType::VIEWER_TYPE_MAX));
453 435
454 cardboard_ = (viewerType == ViewerType::CARDBOARD); 436 cardboard_ =
437 (gvr_api_->GetViewerType() == gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD);
455 if (cardboard_ && web_vr_mode_) { 438 if (cardboard_ && web_vr_mode_) {
456 browser_->ToggleCardboardGamepad(true); 439 browser_->ToggleCardboardGamepad(true);
457 } 440 }
458 } 441 }
459 442
460 void VrShellGl::InitializeRenderer() { 443 void VrShellGl::InitializeRenderer() {
461 gvr_api_->InitializeGl(); 444 gvr_api_->InitializeGl();
462 vr::Mat4f head_pose; 445 vr::Mat4f head_pose;
463 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose); 446 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose);
464 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose); 447 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose);
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 // This assumes that the initial webvr_surface_size_ was set to the 1581 // This assumes that the initial webvr_surface_size_ was set to the
1599 // appropriate recommended render resolution as the default size during 1582 // appropriate recommended render resolution as the default size during
1600 // InitializeGl. Revisit if the initialization order changes. 1583 // InitializeGl. Revisit if the initialization order changes.
1601 device::mojom::VRDisplayInfoPtr info = 1584 device::mojom::VRDisplayInfoPtr info =
1602 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1585 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1603 webvr_surface_size_, device_id); 1586 webvr_surface_size_, device_id);
1604 browser_->RunVRDisplayInfoCallback(callback, &info); 1587 browser_->RunVRDisplayInfoCallback(callback, &info);
1605 } 1588 }
1606 1589
1607 } // namespace vr_shell 1590 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_delegate.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698