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

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: 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
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/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "chrome/browser/android/vr_shell/fps_meter.h" 16 #include "chrome/browser/android/vr_shell/fps_meter.h"
17 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h" 17 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h"
18 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 18 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
19 #include "chrome/browser/android/vr_shell/ui_interface.h" 19 #include "chrome/browser/android/vr_shell/ui_interface.h"
20 #include "chrome/browser/android/vr_shell/ui_scene.h" 20 #include "chrome/browser/android/vr_shell/ui_scene.h"
21 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" 21 #include "chrome/browser/android/vr_shell/ui_scene_manager.h"
22 #include "chrome/browser/android/vr_shell/vr_controller.h" 22 #include "chrome/browser/android/vr_shell/vr_controller.h"
23 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 23 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
24 #include "chrome/browser/android/vr_shell/vr_shell.h" 24 #include "chrome/browser/android/vr_shell/vr_shell.h"
25 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 25 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
26 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h"
26 #include "device/vr/android/gvr/gvr_delegate.h" 27 #include "device/vr/android/gvr/gvr_delegate.h"
27 #include "device/vr/android/gvr/gvr_device.h" 28 #include "device/vr/android/gvr/gvr_device.h"
28 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" 29 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
29 #include "device/vr/vr_math.h" 30 #include "device/vr/vr_math.h"
30 #include "third_party/WebKit/public/platform/WebInputEvent.h" 31 #include "third_party/WebKit/public/platform/WebInputEvent.h"
31 #include "third_party/WebKit/public/platform/WebMouseEvent.h" 32 #include "third_party/WebKit/public/platform/WebMouseEvent.h"
32 #include "ui/gl/android/scoped_java_surface.h" 33 #include "ui/gl/android/scoped_java_surface.h"
33 #include "ui/gl/android/surface_texture.h" 34 #include "ui/gl/android/surface_texture.h"
34 #include "ui/gl/gl_bindings.h" 35 #include "ui/gl/gl_bindings.h"
35 #include "ui/gl/gl_context.h" 36 #include "ui/gl/gl_context.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 float y) { 143 float y) {
143 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent( 144 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent(
144 type, blink::WebInputEvent::kNoModifiers, timestamp)); 145 type, blink::WebInputEvent::kNoModifiers, timestamp));
145 mouse_event->pointer_type = blink::WebPointerProperties::PointerType::kMouse; 146 mouse_event->pointer_type = blink::WebPointerProperties::PointerType::kMouse;
146 mouse_event->SetPositionInWidget(x, y); 147 mouse_event->SetPositionInWidget(x, y);
147 mouse_event->click_count = 1; 148 mouse_event->click_count = 1;
148 149
149 return mouse_event; 150 return mouse_event;
150 } 151 }
151 152
152 enum class ViewerType {
153 UNKNOWN_TYPE = 0,
154 CARDBOARD = 1,
155 DAYDREAM = 2,
156 VIEWER_TYPE_MAX,
157 };
158
159 void RunVRDisplayInfoCallback( 153 void RunVRDisplayInfoCallback(
160 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, 154 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback,
161 device::mojom::VRDisplayInfoPtr info) { 155 device::mojom::VRDisplayInfoPtr info) {
162 callback.Run(std::move(info)); 156 callback.Run(std::move(info));
163 } 157 }
164 158
165 void MatfToGvrMat(const vr::Mat4f& in, gvr::Mat4f* out) { 159 void MatfToGvrMat(const vr::Mat4f& in, gvr::Mat4f* out) {
166 // If our std::array implementation doesn't have any non-data members, we can 160 // If our std::array implementation doesn't have any non-data members, we can
167 // just cast the gvr matrix to an std::array. 161 // just cast the gvr matrix to an std::array.
168 static_assert(sizeof(in) == sizeof(*out), 162 static_assert(sizeof(in) == sizeof(*out),
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 399
406 submit_client_->OnSubmitFrameRendered(); 400 submit_client_->OnSubmitFrameRendered();
407 401
408 DrawFrame(frame_index); 402 DrawFrame(frame_index);
409 } 403 }
410 404
411 void VrShellGl::GvrInit(gvr_context* gvr_api) { 405 void VrShellGl::GvrInit(gvr_context* gvr_api) {
412 gvr_api_ = gvr::GvrApi::WrapNonOwned(gvr_api); 406 gvr_api_ = gvr::GvrApi::WrapNonOwned(gvr_api);
413 controller_.reset(new VrController(gvr_api)); 407 controller_.reset(new VrController(gvr_api));
414 408
415 ViewerType viewerType; 409 VrMetricsHelper::LogVrViewerType(gvr_api);
billorr 2017/05/05 17:48:40 VrMetricsHelper doesn't need to be the only thing
tiborg 2017/05/05 19:03:34 Agreed. I was moving the function to VrMetricsHelp
416 switch (gvr_api_->GetViewerType()) {
417 case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM:
418 viewerType = ViewerType::DAYDREAM;
419 break;
420 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD:
421 viewerType = ViewerType::CARDBOARD;
422 break;
423 default:
424 NOTREACHED();
425 viewerType = ViewerType::UNKNOWN_TYPE;
426 break;
427 }
428 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType),
429 static_cast<int>(ViewerType::VIEWER_TYPE_MAX));
430 } 410 }
431 411
432 void VrShellGl::InitializeRenderer() { 412 void VrShellGl::InitializeRenderer() {
433 gvr_api_->InitializeGl(); 413 gvr_api_->InitializeGl();
434 vr::Mat4f head_pose; 414 vr::Mat4f head_pose;
435 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose); 415 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose);
436 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose); 416 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose);
437 417
438 std::vector<gvr::BufferSpec> specs; 418 std::vector<gvr::BufferSpec> specs;
439 // For kFramePrimaryBuffer (primary VrShell and WebVR content) 419 // For kFramePrimaryBuffer (primary VrShell and WebVR content)
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 // InitializeGl. Revisit if the initialization order changes. 1338 // InitializeGl. Revisit if the initialization order changes.
1359 device::mojom::VRDisplayInfoPtr info = 1339 device::mojom::VRDisplayInfoPtr info =
1360 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1340 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1361 webvr_surface_size_, device_id); 1341 webvr_surface_size_, device_id);
1362 main_thread_task_runner_->PostTask( 1342 main_thread_task_runner_->PostTask(
1363 FROM_HERE, 1343 FROM_HERE,
1364 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); 1344 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info)));
1365 } 1345 }
1366 1346
1367 } // namespace vr_shell 1347 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698