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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 531 |
532 // When using async reprojection, we need to know which pose was used in | 532 // When using async reprojection, we need to know which pose was used in |
533 // the WebVR app for drawing this frame. Due to unknown amounts of | 533 // the WebVR app for drawing this frame. Due to unknown amounts of |
534 // buffering in the compositor and SurfaceTexture, we read the pose number | 534 // buffering in the compositor and SurfaceTexture, we read the pose number |
535 // from a corner pixel. There's no point in doing this for legacy | 535 // from a corner pixel. There's no point in doing this for legacy |
536 // distortion rendering since that doesn't need a pose, and reading back | 536 // distortion rendering since that doesn't need a pose, and reading back |
537 // pixels is an expensive operation. TODO(klausw): stop doing this once we | 537 // pixels is an expensive operation. TODO(klausw): stop doing this once we |
538 // have working no-compositor rendering for WebVR. | 538 // have working no-compositor rendering for WebVR. |
539 if (gvr_api_->GetAsyncReprojectionEnabled()) { | 539 if (gvr_api_->GetAsyncReprojectionEnabled()) { |
540 uint32_t webvr_pose_frame = GetPixelEncodedPoseIndex(); | 540 uint32_t webvr_pose_frame = GetPixelEncodedPoseIndex(); |
541 head_pose = webvr_head_pose_[webvr_pose_frame % kPoseRingBufferSize]; | 541 // If we don't get a valid frame ID back we shouldn't attempt to reproject |
| 542 // by an invalid matrix, so turn of reprojection instead. |
| 543 if (webvr_pose_frame == 0) { |
| 544 webvr_left_viewport_->SetReprojection(GVR_REPROJECTION_NONE); |
| 545 webvr_right_viewport_->SetReprojection(GVR_REPROJECTION_NONE); |
| 546 } else { |
| 547 webvr_left_viewport_->SetReprojection(GVR_REPROJECTION_FULL); |
| 548 webvr_right_viewport_->SetReprojection(GVR_REPROJECTION_FULL); |
| 549 head_pose = webvr_head_pose_[webvr_pose_frame % kPoseRingBufferSize]; |
| 550 } |
542 } | 551 } |
543 } | 552 } |
544 | 553 |
545 DrawVrShell(head_pose, frame); | 554 DrawVrShell(head_pose, frame); |
546 | 555 |
547 frame.Unbind(); | 556 frame.Unbind(); |
548 frame.Submit(*buffer_viewport_list_, head_pose); | 557 frame.Submit(*buffer_viewport_list_, head_pose); |
549 } | 558 } |
550 | 559 |
551 void VrShell::DrawVrShell(const gvr::Mat4f& head_pose, | 560 void VrShell::DrawVrShell(const gvr::Mat4f& head_pose, |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 const JavaParamRef<jobject>& ui_web_contents, | 908 const JavaParamRef<jobject>& ui_web_contents, |
900 jlong ui_window_android) { | 909 jlong ui_window_android) { |
901 return reinterpret_cast<intptr_t>(new VrShell( | 910 return reinterpret_cast<intptr_t>(new VrShell( |
902 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 911 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
903 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 912 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
904 content::WebContents::FromJavaWebContents(ui_web_contents), | 913 content::WebContents::FromJavaWebContents(ui_web_contents), |
905 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); | 914 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); |
906 } | 915 } |
907 | 916 |
908 } // namespace vr_shell | 917 } // namespace vr_shell |
OLD | NEW |