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

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

Issue 2804943003: [vr] Add a frame rate counter for the vr UI (Closed)
Patch Set: () Created 3 years, 8 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/mailbox_to_surface_bridge.h" 17 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h"
17 #include "chrome/browser/android/vr_shell/ui_elements.h" 18 #include "chrome/browser/android/vr_shell/ui_elements.h"
18 #include "chrome/browser/android/vr_shell/ui_interface.h" 19 #include "chrome/browser/android/vr_shell/ui_interface.h"
19 #include "chrome/browser/android/vr_shell/ui_scene.h" 20 #include "chrome/browser/android/vr_shell/ui_scene.h"
20 #include "chrome/browser/android/vr_shell/vr_controller.h" 21 #include "chrome/browser/android/vr_shell/vr_controller.h"
21 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 22 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
22 #include "chrome/browser/android/vr_shell/vr_math.h" 23 #include "chrome/browser/android/vr_shell/vr_math.h"
23 #include "chrome/browser/android/vr_shell/vr_shell.h" 24 #include "chrome/browser/android/vr_shell/vr_shell.h"
24 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 25 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
25 #include "device/vr/android/gvr/gvr_delegate.h" 26 #include "device/vr/android/gvr/gvr_delegate.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 141 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
141 gvr_context* gvr_api, 142 gvr_context* gvr_api,
142 bool initially_web_vr, 143 bool initially_web_vr,
143 bool reprojected_rendering) 144 bool reprojected_rendering)
144 : web_vr_mode_(initially_web_vr), 145 : web_vr_mode_(initially_web_vr),
145 surfaceless_rendering_(reprojected_rendering), 146 surfaceless_rendering_(reprojected_rendering),
146 task_runner_(base::ThreadTaskRunnerHandle::Get()), 147 task_runner_(base::ThreadTaskRunnerHandle::Get()),
147 binding_(this), 148 binding_(this),
148 weak_vr_shell_(weak_vr_shell), 149 weak_vr_shell_(weak_vr_shell),
149 main_thread_task_runner_(std::move(main_thread_task_runner)), 150 main_thread_task_runner_(std::move(main_thread_task_runner)),
151 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
mthiesse 2017/04/12 02:39:00 Oops, I meant to suggest DCHECK_IS_ON. Then you do
152 fps_meter_(new FPSMeter()),
153 #endif
150 weak_ptr_factory_(this) { 154 weak_ptr_factory_(this) {
151 GvrInit(gvr_api); 155 GvrInit(gvr_api);
152 } 156 }
153 157
154 VrShellGl::~VrShellGl() { 158 VrShellGl::~VrShellGl() {
155 vsync_task_.Cancel(); 159 vsync_task_.Cancel();
156 // TODO(mthiesse): Can we omit the Close() here? Concern is that if 160 // TODO(mthiesse): Can we omit the Close() here? Concern is that if
157 // both ends of the connection ever live in the same process for 161 // both ends of the connection ever live in the same process for
158 // some reason, we could receive another VSync request in response 162 // some reason, we could receive another VSync request in response
159 // to the closing message in the destructor but fail to respond to 163 // to the closing message in the destructor but fail to respond to
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 TRACE_EVENT0("gpu", "VrShellGl::Submit"); 833 TRACE_EVENT0("gpu", "VrShellGl::Submit");
830 frame.Submit(*buffer_viewport_list_, head_pose); 834 frame.Submit(*buffer_viewport_list_, head_pose);
831 } 835 }
832 836
833 // No need to swap buffers for surfaceless rendering. 837 // No need to swap buffers for surfaceless rendering.
834 if (!surfaceless_rendering_) { 838 if (!surfaceless_rendering_) {
835 // TODO(mthiesse): Support asynchronous SwapBuffers. 839 // TODO(mthiesse): Support asynchronous SwapBuffers.
836 TRACE_EVENT0("gpu", "VrShellGl::SwapBuffers"); 840 TRACE_EVENT0("gpu", "VrShellGl::SwapBuffers");
837 surface_->SwapBuffers(); 841 surface_->SwapBuffers();
838 } 842 }
843
844 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
845 // After saving the timestamp, fps will be available via GetFPS().
846 // TODO(vollick): enable rendering of this framerate in a HUD.
847 fps_meter_->AddFrame(current_time);
848 LOG(ERROR) << "fps: " << fps_meter_->GetFPS();
849 #endif
839 } 850 }
840 851
841 void VrShellGl::DrawWorldElements(const gvr::Mat4f& head_pose) { 852 void VrShellGl::DrawWorldElements(const gvr::Mat4f& head_pose) {
842 TRACE_EVENT0("gpu", "VrShellGl::DrawWorldElements"); 853 TRACE_EVENT0("gpu", "VrShellGl::DrawWorldElements");
843 854
844 if (ShouldDrawWebVr()) { 855 if (ShouldDrawWebVr()) {
845 // WebVR is incompatible with 3D world compositing since the 856 // WebVR is incompatible with 3D world compositing since the
846 // depth buffer was already populated with unknown scaling - the 857 // depth buffer was already populated with unknown scaling - the
847 // WebVR app has full control over zNear/zFar. Just leave the 858 // WebVR app has full control over zNear/zFar. Just leave the
848 // existing content in place in the primary buffer without 859 // existing content in place in the primary buffer without
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // InitializeGl. Revisit if the initialization order changes. 1287 // InitializeGl. Revisit if the initialization order changes.
1277 device::mojom::VRDisplayInfoPtr info = 1288 device::mojom::VRDisplayInfoPtr info =
1278 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1289 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1279 webvr_surface_size_, device_id); 1290 webvr_surface_size_, device_id);
1280 main_thread_task_runner_->PostTask( 1291 main_thread_task_runner_->PostTask(
1281 FROM_HERE, 1292 FROM_HERE,
1282 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); 1293 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info)));
1283 } 1294 }
1284 1295
1285 } // namespace vr_shell 1296 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698