| Index: chrome/browser/android/vr_shell/vr_shell_gl.cc
|
| diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
|
| index 5d013199042033fef8c551a80e37eb793a622dbb..5c510f45382336b156543a43f8b3af167c8555dd 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
|
| +++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
|
| @@ -20,6 +20,7 @@
|
| #include "chrome/browser/android/vr_shell/ui_scene.h"
|
| #include "chrome/browser/android/vr_shell/ui_scene_manager.h"
|
| #include "chrome/browser/android/vr_shell/vr_controller.h"
|
| +#include "chrome/browser/android/vr_shell/vr_gl_thread.h"
|
| #include "chrome/browser/android/vr_shell/vr_gl_util.h"
|
| #include "chrome/browser/android/vr_shell/vr_shell.h"
|
| #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
|
| @@ -190,19 +191,16 @@ gfx::RectF GfxRectFromUV(gvr::Rectf rect) {
|
|
|
| } // namespace
|
|
|
| -VrShellGl::VrShellGl(
|
| - const base::WeakPtr<VrShell>& weak_vr_shell,
|
| - scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
|
| - gvr_context* gvr_api,
|
| - bool initially_web_vr,
|
| - bool reprojected_rendering,
|
| - UiScene* scene)
|
| +VrShellGl::VrShellGl(const base::WeakPtr<VrGLThread>& weak_vr_gl_thread,
|
| + gvr_context* gvr_api,
|
| + bool initially_web_vr,
|
| + bool reprojected_rendering,
|
| + UiScene* scene)
|
| : web_vr_mode_(initially_web_vr),
|
| surfaceless_rendering_(reprojected_rendering),
|
| task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
| binding_(this),
|
| - weak_vr_shell_(weak_vr_shell),
|
| - main_thread_task_runner_(std::move(main_thread_task_runner)),
|
| + weak_vr_gl_thread_(weak_vr_gl_thread),
|
| scene_(scene),
|
| #if DCHECK_IS_ON()
|
| fps_meter_(new FPSMeter()),
|
| @@ -305,9 +303,8 @@ void VrShellGl::InitializeGl(gfx::AcceleratedWidget window) {
|
| void VrShellGl::CreateContentSurface() {
|
| content_surface_ =
|
| base::MakeUnique<gl::ScopedJavaSurface>(content_surface_texture_.get());
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::ContentSurfaceChanged, weak_vr_shell_,
|
| - content_surface_->j_surface().obj()));
|
| + weak_vr_gl_thread_->PostTaskToMainThreadShell(
|
| + &VrShell::ContentSurfaceChanged, content_surface_->j_surface().obj());
|
| }
|
|
|
| void VrShellGl::CreateOrResizeWebVRSurface(const gfx::Size& size) {
|
| @@ -503,8 +500,7 @@ void VrShellGl::InitializeRenderer() {
|
| webvr_right_viewport_.get());
|
| webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer);
|
|
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::GvrDelegateReady, weak_vr_shell_));
|
| + weak_vr_gl_thread_->PostTaskToMainThreadShell(&VrShell::GvrDelegateReady);
|
| }
|
|
|
| void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) {
|
| @@ -512,8 +508,8 @@ void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) {
|
| pointer_start_ = controller_->GetPointerStart();
|
|
|
| device::GvrGamepadData pad = controller_->GetGamepadData();
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::UpdateGamepadData, weak_vr_shell_, pad));
|
| + weak_vr_gl_thread_->PostTaskToMainThreadShell(&VrShell::UpdateGamepadData,
|
| + pad);
|
| }
|
|
|
| void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) {
|
| @@ -653,14 +649,14 @@ void VrShellGl::HandleControllerAppButtonActivity(
|
| if (fabs(gesture_xz_angle) > kMinAppButtonGestureAngleRad) {
|
| direction =
|
| gesture_xz_angle < 0 ? UiInterface::LEFT : UiInterface::RIGHT;
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::AppButtonGesturePerformed,
|
| - weak_vr_shell_, direction));
|
| + weak_vr_gl_thread_->PostTaskToMainThreadShell(
|
| + &VrShell::AppButtonGesturePerformed, direction);
|
| }
|
| }
|
| if (direction == UiInterface::NONE) {
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::AppButtonPressed, weak_vr_shell_));
|
| + task_runner_->PostTask(FROM_HERE,
|
| + base::Bind(&UiSceneManager::AppButtonPressed,
|
| + weak_vr_gl_thread_->GetSceneManager()));
|
| }
|
| }
|
| }
|
| @@ -786,9 +782,8 @@ void VrShellGl::SendInputToUiElements(UiElement* target_element) {
|
|
|
| void VrShellGl::SendGestureToContent(
|
| std::unique_ptr<blink::WebInputEvent> event) {
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::ProcessContentGesture, weak_vr_shell_,
|
| - base::Passed(std::move(event))));
|
| + weak_vr_gl_thread_->PostTaskToMainThreadShell(&VrShell::ProcessContentGesture,
|
| + base::Passed(std::move(event)));
|
| }
|
|
|
| void VrShellGl::DrawFrame(int16_t frame_index) {
|
| @@ -1330,8 +1325,7 @@ void VrShellGl::UpdateVSyncInterval(int64_t timebase_nanos,
|
| }
|
|
|
| void VrShellGl::ForceExitVr() {
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_));
|
| + weak_vr_gl_thread_->PostTaskToMainThreadShell(&VrShell::ForceExitVr);
|
| }
|
|
|
| void VrShellGl::SendVSync(base::TimeDelta time,
|
| @@ -1359,9 +1353,8 @@ void VrShellGl::CreateVRDisplayInfo(
|
| device::mojom::VRDisplayInfoPtr info =
|
| device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
|
| webvr_surface_size_, device_id);
|
| - main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info)));
|
| + weak_vr_gl_thread_->PostTaskToMainThread(&RunVRDisplayInfoCallback, callback,
|
| + base::Passed(&info));
|
| }
|
|
|
| } // namespace vr_shell
|
|
|