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

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

Powered by Google App Engine
This is Rietveld 408576698