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

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: Incorporated review feedback 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_thread.h" 23 #include "chrome/browser/android/vr_shell/vr_gl_thread.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/WebInputEvent.h" 33 #include "third_party/WebKit/public/platform/WebInputEvent.h"
32 #include "third_party/WebKit/public/platform/WebMouseEvent.h" 34 #include "third_party/WebKit/public/platform/WebMouseEvent.h"
33 #include "ui/gl/android/scoped_java_surface.h" 35 #include "ui/gl/android/scoped_java_surface.h"
34 #include "ui/gl/android/surface_texture.h" 36 #include "ui/gl/android/surface_texture.h"
35 #include "ui/gl/gl_bindings.h" 37 #include "ui/gl/gl_bindings.h"
36 #include "ui/gl/gl_context.h" 38 #include "ui/gl/gl_context.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 float y) { 145 float y) {
144 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent( 146 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent(
145 type, blink::WebInputEvent::kNoModifiers, timestamp)); 147 type, blink::WebInputEvent::kNoModifiers, timestamp));
146 mouse_event->pointer_type = blink::WebPointerProperties::PointerType::kMouse; 148 mouse_event->pointer_type = blink::WebPointerProperties::PointerType::kMouse;
147 mouse_event->SetPositionInWidget(x, y); 149 mouse_event->SetPositionInWidget(x, y);
148 mouse_event->click_count = 1; 150 mouse_event->click_count = 1;
149 151
150 return mouse_event; 152 return mouse_event;
151 } 153 }
152 154
153 enum class ViewerType {
154 UNKNOWN_TYPE = 0,
155 CARDBOARD = 1,
156 DAYDREAM = 2,
157 VIEWER_TYPE_MAX,
158 };
159 155
160 void MatfToGvrMat(const vr::Mat4f& in, gvr::Mat4f* out) { 156 void MatfToGvrMat(const vr::Mat4f& in, gvr::Mat4f* out) {
161 // If our std::array implementation doesn't have any non-data members, we can 157 // If our std::array implementation doesn't have any non-data members, we can
162 // just cast the gvr matrix to an std::array. 158 // just cast the gvr matrix to an std::array.
163 static_assert(sizeof(in) == sizeof(*out), 159 static_assert(sizeof(in) == sizeof(*out),
164 "Cannot reinterpret gvr::Mat4f as vr::Matf"); 160 "Cannot reinterpret gvr::Mat4f as vr::Matf");
165 *out = *reinterpret_cast<gvr::Mat4f*>(const_cast<vr::Mat4f*>(&in)); 161 *out = *reinterpret_cast<gvr::Mat4f*>(const_cast<vr::Mat4f*>(&in));
166 } 162 }
167 163
168 void GvrMatToMatf(const gvr::Mat4f& in, vr::Mat4f* out) { 164 void GvrMatToMatf(const gvr::Mat4f& in, vr::Mat4f* out) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 submit_client_->OnSubmitFrameRendered(); 394 submit_client_->OnSubmitFrameRendered();
399 } 395 }
400 396
401 DrawFrame(frame_index); 397 DrawFrame(frame_index);
402 } 398 }
403 399
404 void VrShellGl::GvrInit(gvr_context* gvr_api) { 400 void VrShellGl::GvrInit(gvr_context* gvr_api) {
405 gvr_api_ = gvr::GvrApi::WrapNonOwned(gvr_api); 401 gvr_api_ = gvr::GvrApi::WrapNonOwned(gvr_api);
406 controller_.reset(new VrController(gvr_api)); 402 controller_.reset(new VrController(gvr_api));
407 403
408 ViewerType viewerType; 404 VrMetricsUtil::LogVrViewerType(gvr_api);
409 switch (gvr_api_->GetViewerType()) {
410 case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM:
411 viewerType = ViewerType::DAYDREAM;
412 break;
413 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD:
414 viewerType = ViewerType::CARDBOARD;
415 break;
416 default:
417 NOTREACHED();
418 viewerType = ViewerType::UNKNOWN_TYPE;
419 break;
420 }
421 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType),
422 static_cast<int>(ViewerType::VIEWER_TYPE_MAX));
423 } 405 }
424 406
425 void VrShellGl::InitializeRenderer() { 407 void VrShellGl::InitializeRenderer() {
426 gvr_api_->InitializeGl(); 408 gvr_api_->InitializeGl();
427 vr::Mat4f head_pose; 409 vr::Mat4f head_pose;
428 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose); 410 device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose);
429 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose); 411 webvr_head_pose_.assign(kPoseRingBufferSize, head_pose);
430 412
431 std::vector<gvr::BufferSpec> specs; 413 std::vector<gvr::BufferSpec> specs;
432 // For kFramePrimaryBuffer (primary VrShell and WebVR content) 414 // For kFramePrimaryBuffer (primary VrShell and WebVR content)
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 // This assumes that the initial webvr_surface_size_ was set to the 1325 // This assumes that the initial webvr_surface_size_ was set to the
1344 // appropriate recommended render resolution as the default size during 1326 // appropriate recommended render resolution as the default size during
1345 // InitializeGl. Revisit if the initialization order changes. 1327 // InitializeGl. Revisit if the initialization order changes.
1346 device::mojom::VRDisplayInfoPtr info = 1328 device::mojom::VRDisplayInfoPtr info =
1347 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1329 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1348 webvr_surface_size_, device_id); 1330 webvr_surface_size_, device_id);
1349 browser_->RunVRDisplayInfoCallback(callback, &info); 1331 browser_->RunVRDisplayInfoCallback(callback, &info);
1350 } 1332 }
1351 1333
1352 } // namespace vr_shell 1334 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698