| OLD | NEW |
| 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.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 return {size.width(), size.height()}; | 247 return {size.width(), size.height()}; |
| 248 } | 248 } |
| 249 | 249 |
| 250 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { | 250 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
| 251 // TODO(cjgrant): Align this state with the logic that drives the omnibox. | 251 // TODO(cjgrant): Align this state with the logic that drives the omnibox. |
| 252 html_interface_->SetWebVRSecureOrigin(secure_origin); | 252 html_interface_->SetWebVRSecureOrigin(secure_origin); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void VrShell::SubmitWebVRFrame() {} | 255 void VrShell::SubmitWebVRFrame() {} |
| 256 | 256 |
| 257 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 257 void VrShell::UpdateWebVRTextureBounds(int16_t frame_index, |
| 258 const gvr::Rectf& left_bounds, |
| 258 const gvr::Rectf& right_bounds) { | 259 const gvr::Rectf& right_bounds) { |
| 259 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, | 260 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, |
| 260 gl_thread_->GetVrShellGl(), left_bounds, | 261 gl_thread_->GetVrShellGl(), frame_index, |
| 261 right_bounds)); | 262 left_bounds, right_bounds)); |
| 262 } | 263 } |
| 263 | 264 |
| 264 // TODO(mthiesse): Do not expose GVR API outside of GL thread. | 265 // TODO(mthiesse): Do not expose GVR API outside of GL thread. |
| 265 // It's not thread-safe. | 266 // It's not thread-safe. |
| 266 gvr::GvrApi* VrShell::gvr_api() { | 267 gvr::GvrApi* VrShell::gvr_api() { |
| 267 if (gl_thread_->GetVrShellGlUnsafe()) { | 268 if (gl_thread_->GetVrShellGlUnsafe()) { |
| 268 return gl_thread_->GetVrShellGlUnsafe()->gvr_api(); | 269 return gl_thread_->GetVrShellGlUnsafe()->gvr_api(); |
| 269 } | 270 } |
| 270 CHECK(false); | 271 CHECK(false); |
| 271 return nullptr; | 272 return nullptr; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 442 |
| 442 } | 443 } |
| 443 | 444 |
| 444 void VrShell::ProcessContentGesture( | 445 void VrShell::ProcessContentGesture( |
| 445 std::unique_ptr<blink::WebInputEvent> event) { | 446 std::unique_ptr<blink::WebInputEvent> event) { |
| 446 if (content_input_manager_) { | 447 if (content_input_manager_) { |
| 447 content_input_manager_->ProcessUpdatedGesture(std::move(event)); | 448 content_input_manager_->ProcessUpdatedGesture(std::move(event)); |
| 448 } | 449 } |
| 449 } | 450 } |
| 450 | 451 |
| 451 device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat, | 452 device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) { |
| 452 uint32_t pose_index) { | |
| 453 device::mojom::VRPosePtr pose = device::mojom::VRPose::New(); | 453 device::mojom::VRPosePtr pose = device::mojom::VRPose::New(); |
| 454 | 454 |
| 455 pose->timestamp = base::Time::Now().ToJsTime(); | 455 pose->timestamp = base::Time::Now().ToJsTime(); |
| 456 | |
| 457 pose->poseIndex = pose_index; | |
| 458 pose->orientation.emplace(4); | 456 pose->orientation.emplace(4); |
| 459 | 457 |
| 460 gfx::Transform inv_transform( | 458 gfx::Transform inv_transform( |
| 461 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], | 459 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], |
| 462 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], | 460 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], |
| 463 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], | 461 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], |
| 464 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); | 462 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); |
| 465 | 463 |
| 466 gfx::Transform transform; | 464 gfx::Transform transform; |
| 467 if (inv_transform.GetInverse(&transform)) { | 465 if (inv_transform.GetInverse(&transform)) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 496 return reinterpret_cast<intptr_t>(new VrShell( | 494 return reinterpret_cast<intptr_t>(new VrShell( |
| 497 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 495 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 498 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 496 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 499 content::WebContents::FromJavaWebContents(ui_web_contents), | 497 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 500 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 498 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 501 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), | 499 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), |
| 502 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 500 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 503 } | 501 } |
| 504 | 502 |
| 505 } // namespace vr_shell | 503 } // namespace vr_shell |
| OLD | NEW |