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 "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "chrome/browser/android/vr_shell/ui_elements.h" | 8 #include "chrome/browser/android/vr_shell/ui_elements.h" |
9 #include "chrome/browser/android/vr_shell/ui_interface.h" | 9 #include "chrome/browser/android/vr_shell/ui_interface.h" |
10 #include "chrome/browser/android/vr_shell/ui_scene.h" | 10 #include "chrome/browser/android/vr_shell/ui_scene.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 headlocked_left_viewport_.get()); | 275 headlocked_left_viewport_.get()); |
276 headlocked_left_viewport_->SetSourceBufferIndex(kFrameHeadlockedBuffer); | 276 headlocked_left_viewport_->SetSourceBufferIndex(kFrameHeadlockedBuffer); |
277 headlocked_left_viewport_->SetReprojection(GVR_REPROJECTION_NONE); | 277 headlocked_left_viewport_->SetReprojection(GVR_REPROJECTION_NONE); |
278 | 278 |
279 headlocked_right_viewport_.reset( | 279 headlocked_right_viewport_.reset( |
280 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); | 280 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); |
281 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, | 281 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, |
282 headlocked_right_viewport_.get()); | 282 headlocked_right_viewport_.get()); |
283 headlocked_right_viewport_->SetSourceBufferIndex(kFrameHeadlockedBuffer); | 283 headlocked_right_viewport_->SetSourceBufferIndex(kFrameHeadlockedBuffer); |
284 headlocked_right_viewport_->SetReprojection(GVR_REPROJECTION_NONE); | 284 headlocked_right_viewport_->SetReprojection(GVR_REPROJECTION_NONE); |
| 285 |
| 286 webvr_left_viewport_.reset( |
| 287 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); |
| 288 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, |
| 289 webvr_left_viewport_.get()); |
| 290 webvr_left_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); |
| 291 |
| 292 webvr_right_viewport_.reset( |
| 293 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); |
| 294 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, |
| 295 webvr_right_viewport_.get()); |
| 296 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); |
285 } | 297 } |
286 | 298 |
287 void VrShell::UpdateController(const gvr::Vec3f& forward_vector) { | 299 void VrShell::UpdateController(const gvr::Vec3f& forward_vector) { |
288 controller_->UpdateState(); | 300 controller_->UpdateState(); |
289 | 301 |
290 #if defined(ENABLE_VR_SHELL) | 302 #if defined(ENABLE_VR_SHELL) |
291 // Note that button up/down state is transient, so IsButtonUp only returns | 303 // Note that button up/down state is transient, so IsButtonUp only returns |
292 // true for a single frame (and we're guaranteed not to miss it). | 304 // true for a single frame (and we're guaranteed not to miss it). |
293 if (controller_->IsButtonUp( | 305 if (controller_->IsButtonUp( |
294 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP)) { | 306 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP)) { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 // Don't need face culling, depth testing, blending, etc. Turn it all off. | 728 // Don't need face culling, depth testing, blending, etc. Turn it all off. |
717 glDisable(GL_CULL_FACE); | 729 glDisable(GL_CULL_FACE); |
718 glDepthMask(GL_FALSE); | 730 glDepthMask(GL_FALSE); |
719 glDisable(GL_DEPTH_TEST); | 731 glDisable(GL_DEPTH_TEST); |
720 glDisable(GL_SCISSOR_TEST); | 732 glDisable(GL_SCISSOR_TEST); |
721 glDisable(GL_BLEND); | 733 glDisable(GL_BLEND); |
722 glDisable(GL_POLYGON_OFFSET_FILL); | 734 glDisable(GL_POLYGON_OFFSET_FILL); |
723 | 735 |
724 glViewport(0, 0, render_size_.width, render_size_.height); | 736 glViewport(0, 0, render_size_.width, render_size_.height); |
725 vr_shell_renderer_->GetWebVrRenderer()->Draw(content_texture_id_); | 737 vr_shell_renderer_->GetWebVrRenderer()->Draw(content_texture_id_); |
| 738 |
| 739 buffer_viewport_list_->SetBufferViewport(0, *webvr_left_viewport_); |
| 740 buffer_viewport_list_->SetBufferViewport(1, *webvr_right_viewport_); |
726 } | 741 } |
727 | 742 |
728 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 743 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
729 // Set a flag to handle this on the render thread at the next frame. | 744 // Set a flag to handle this on the render thread at the next frame. |
730 touch_pending_ = true; | 745 touch_pending_ = true; |
731 } | 746 } |
732 | 747 |
733 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 748 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
734 if (gvr_api_ == nullptr) | 749 if (gvr_api_ == nullptr) |
735 return; | 750 return; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 } | 787 } |
773 } | 788 } |
774 | 789 |
775 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { | 790 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
776 html_interface_->SetSecureOrigin(secure_origin); | 791 html_interface_->SetSecureOrigin(secure_origin); |
777 } | 792 } |
778 | 793 |
779 void VrShell::SubmitWebVRFrame() { | 794 void VrShell::SubmitWebVRFrame() { |
780 } | 795 } |
781 | 796 |
782 void VrShell::UpdateWebVRTextureBounds( | 797 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
783 int eye, float left, float top, float width, float height) { | 798 const gvr::Rectf& right_bounds) { |
784 gvr::Rectf bounds = { left, top, width, height }; | 799 webvr_left_viewport_->SetSourceUv(left_bounds); |
785 vr_shell_renderer_->GetWebVrRenderer()->UpdateTextureBounds(eye, bounds); | 800 webvr_right_viewport_->SetSourceUv(right_bounds); |
786 } | 801 } |
787 | 802 |
788 gvr::GvrApi* VrShell::gvr_api() { | 803 gvr::GvrApi* VrShell::gvr_api() { |
789 return gvr_api_.get(); | 804 return gvr_api_.get(); |
790 } | 805 } |
791 | 806 |
792 void VrShell::ContentSurfaceChanged(JNIEnv* env, | 807 void VrShell::ContentSurfaceChanged(JNIEnv* env, |
793 const JavaParamRef<jobject>& object, | 808 const JavaParamRef<jobject>& object, |
794 jint width, | 809 jint width, |
795 jint height, | 810 jint height, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 const JavaParamRef<jobject>& ui_web_contents, | 904 const JavaParamRef<jobject>& ui_web_contents, |
890 jlong ui_window_android) { | 905 jlong ui_window_android) { |
891 return reinterpret_cast<intptr_t>(new VrShell( | 906 return reinterpret_cast<intptr_t>(new VrShell( |
892 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 907 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
893 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 908 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
894 content::WebContents::FromJavaWebContents(ui_web_contents), | 909 content::WebContents::FromJavaWebContents(ui_web_contents), |
895 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); | 910 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); |
896 } | 911 } |
897 | 912 |
898 } // namespace vr_shell | 913 } // namespace vr_shell |
OLD | NEW |