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

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

Issue 2891243002: VR: Loading DD controller model after GL is initialized (Closed)
Patch Set: doing texture patching on background task 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/task_scheduler/post_task.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "chrome/browser/android/vr_shell/fps_meter.h" 17 #include "chrome/browser/android/vr_shell/fps_meter.h"
17 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h" 18 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h"
18 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 19 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
19 #include "chrome/browser/android/vr_shell/ui_interface.h" 20 #include "chrome/browser/android/vr_shell/ui_interface.h"
20 #include "chrome/browser/android/vr_shell/ui_scene.h" 21 #include "chrome/browser/android/vr_shell/ui_scene.h"
21 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" 22 #include "chrome/browser/android/vr_shell/vr_browser_interface.h"
22 #include "chrome/browser/android/vr_shell/vr_controller.h" 23 #include "chrome/browser/android/vr_shell/vr_controller.h"
23 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 24 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
24 #include "chrome/browser/android/vr_shell/vr_shell.h" 25 #include "chrome/browser/android/vr_shell/vr_shell.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 190
190 gfx::RectF GfxRectFromUV(gvr::Rectf rect) { 191 gfx::RectF GfxRectFromUV(gvr::Rectf rect) {
191 return gfx::RectF(rect.left, 1.0 - rect.top, rect.right - rect.left, 192 return gfx::RectF(rect.left, 1.0 - rect.top, rect.right - rect.left,
192 rect.top - rect.bottom); 193 rect.top - rect.bottom);
193 } 194 }
194 195
195 double NowSeconds() { 196 double NowSeconds() {
196 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 197 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
197 } 198 }
198 199
200 void LoadControllerModelTask(
201 base::WeakPtr<VrShellGl> weak_vr_shell_gl,
202 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
203 auto controller_model = VrControllerModel::LoadFromResources();
204 if (controller_model) {
205 task_runner->PostTask(
206 FROM_HERE, base::Bind(&VrShellGl::SetControllerModel, weak_vr_shell_gl,
207 base::Passed(&controller_model)));
208 }
209 }
210
199 } // namespace 211 } // namespace
200 212
201 VrShellGl::VrShellGl(VrBrowserInterface* browser, 213 VrShellGl::VrShellGl(VrBrowserInterface* browser,
202 gvr_context* gvr_api, 214 gvr_context* gvr_api,
203 bool initially_web_vr, 215 bool initially_web_vr,
204 bool reprojected_rendering, 216 bool reprojected_rendering,
217 bool daydream_support,
205 UiScene* scene) 218 UiScene* scene)
206 : web_vr_mode_(initially_web_vr), 219 : web_vr_mode_(initially_web_vr),
207 surfaceless_rendering_(reprojected_rendering), 220 surfaceless_rendering_(reprojected_rendering),
221 daydream_support_(daydream_support),
208 task_runner_(base::ThreadTaskRunnerHandle::Get()), 222 task_runner_(base::ThreadTaskRunnerHandle::Get()),
209 binding_(this), 223 binding_(this),
210 browser_(browser), 224 browser_(browser),
211 scene_(scene), 225 scene_(scene),
212 #if DCHECK_IS_ON() 226 #if DCHECK_IS_ON()
213 fps_meter_(new FPSMeter()), 227 fps_meter_(new FPSMeter()),
214 #endif 228 #endif
215 weak_ptr_factory_(this) { 229 weak_ptr_factory_(this) {
216 GvrInit(gvr_api); 230 GvrInit(gvr_api);
217 } 231 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 device::GvrDelegate::GetRecommendedWebVrSize(gvr_api_.get()); 312 device::GvrDelegate::GetRecommendedWebVrSize(gvr_api_.get());
299 DVLOG(1) << __FUNCTION__ << ": resize initial to " << webvr_size.width() 313 DVLOG(1) << __FUNCTION__ << ": resize initial to " << webvr_size.width()
300 << "x" << webvr_size.height(); 314 << "x" << webvr_size.height();
301 315
302 CreateOrResizeWebVRSurface(webvr_size); 316 CreateOrResizeWebVRSurface(webvr_size);
303 317
304 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this))); 318 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this)));
305 OnVSync(); 319 OnVSync();
306 320
307 ready_to_draw_ = true; 321 ready_to_draw_ = true;
322
323 if (daydream_support_) {
324 base::PostTaskWithTraits(
325 FROM_HERE, {base::TaskPriority::BACKGROUND},
326 base::Bind(LoadControllerModelTask, weak_ptr_factory_.GetWeakPtr(),
327 task_runner_));
328 }
308 } 329 }
309 330
310 void VrShellGl::CreateContentSurface() { 331 void VrShellGl::CreateContentSurface() {
311 content_surface_ = 332 content_surface_ =
312 base::MakeUnique<gl::ScopedJavaSurface>(content_surface_texture_.get()); 333 base::MakeUnique<gl::ScopedJavaSurface>(content_surface_texture_.get());
313 browser_->ContentSurfaceChanged(content_surface_->j_surface().obj()); 334 browser_->ContentSurfaceChanged(content_surface_->j_surface().obj());
314 } 335 }
315 336
316 void VrShellGl::CreateOrResizeWebVRSurface(const gfx::Size& size) { 337 void VrShellGl::CreateOrResizeWebVRSurface(const gfx::Size& size) {
317 if (!webvr_surface_texture_) { 338 if (!webvr_surface_texture_) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 472
452 // For kFrameHeadlockedBuffer (for WebVR insecure content warning). 473 // For kFrameHeadlockedBuffer (for WebVR insecure content warning).
453 // Set this up at fixed resolution, the (smaller) FOV gets set below. 474 // Set this up at fixed resolution, the (smaller) FOV gets set below.
454 specs.push_back(gvr_api_->CreateBufferSpec()); 475 specs.push_back(gvr_api_->CreateBufferSpec());
455 specs.back().SetSize({kHeadlockedBufferDimensions.width(), 476 specs.back().SetSize({kHeadlockedBufferDimensions.width(),
456 kHeadlockedBufferDimensions.height()}); 477 kHeadlockedBufferDimensions.height()});
457 gvr::Sizei render_size_headlocked = specs[kFrameHeadlockedBuffer].GetSize(); 478 gvr::Sizei render_size_headlocked = specs[kFrameHeadlockedBuffer].GetSize();
458 render_size_headlocked_ = {render_size_headlocked.width, 479 render_size_headlocked_ = {render_size_headlocked.width,
459 render_size_headlocked.height}; 480 render_size_headlocked.height};
460 481
461 swap_chain_.reset(new gvr::SwapChain(gvr_api_->CreateSwapChain(specs))); 482 swap_chain_ =
483 base::MakeUnique<gvr::SwapChain>(gvr_api_->CreateSwapChain(specs));
462 484
463 vr_shell_renderer_.reset(new VrShellRenderer()); 485 vr_shell_renderer_ = base::MakeUnique<VrShellRenderer>();
464 486
465 // Allocate a buffer viewport for use in UI drawing. This isn't 487 // Allocate a buffer viewport for use in UI drawing. This isn't
466 // initialized at this point, it'll be set from other viewport list 488 // initialized at this point, it'll be set from other viewport list
467 // entries as needed. 489 // entries as needed.
468 buffer_viewport_.reset( 490 buffer_viewport_.reset(
469 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); 491 new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
470 492
471 // Set up main content viewports. The list has two elements, 0=left 493 // Set up main content viewports. The list has two elements, 0=left
472 // eye and 1=right eye. 494 // eye and 1=right eye.
473 buffer_viewport_list_.reset( 495 buffer_viewport_list_.reset(
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 // This assumes that the initial webvr_surface_size_ was set to the 1528 // This assumes that the initial webvr_surface_size_ was set to the
1507 // appropriate recommended render resolution as the default size during 1529 // appropriate recommended render resolution as the default size during
1508 // InitializeGl. Revisit if the initialization order changes. 1530 // InitializeGl. Revisit if the initialization order changes.
1509 device::mojom::VRDisplayInfoPtr info = 1531 device::mojom::VRDisplayInfoPtr info =
1510 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1532 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1511 webvr_surface_size_, device_id); 1533 webvr_surface_size_, device_id);
1512 browser_->RunVRDisplayInfoCallback(callback, &info); 1534 browser_->RunVRDisplayInfoCallback(callback, &info);
1513 } 1535 }
1514 1536
1515 } // namespace vr_shell 1537 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | chrome/browser/android/vr_shell/vr_shell_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698