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

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

Issue 2464373005: Fix VR Shell crashing when renderer crashes or native page is shown. (Closed)
Patch Set: Rebase + address comment Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_input_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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"
11 #include "chrome/browser/android/vr_shell/vr_compositor.h" 11 #include "chrome/browser/android/vr_shell/vr_compositor.h"
12 #include "chrome/browser/android/vr_shell/vr_controller.h" 12 #include "chrome/browser/android/vr_shell/vr_controller.h"
13 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 13 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
14 #include "chrome/browser/android/vr_shell/vr_input_manager.h" 14 #include "chrome/browser/android/vr_shell/vr_input_manager.h"
15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" 15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
16 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 16 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
17 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" 17 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h"
18 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/render_widget_host.h" 20 #include "content/public/browser/render_widget_host.h"
21 #include "content/public/browser/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/referrer.h" 23 #include "content/public/common/referrer.h"
24 #include "content/public/common/screen_info.h"
25 #include "jni/VrShellImpl_jni.h" 24 #include "jni/VrShellImpl_jni.h"
26 #include "ui/android/view_android.h" 25 #include "ui/android/view_android.h"
27 #include "ui/android/window_android.h" 26 #include "ui/android/window_android.h"
28 #include "ui/base/page_transition_types.h" 27 #include "ui/base/page_transition_types.h"
28 #include "ui/display/display.h"
29 #include "ui/display/screen.h"
29 #include "ui/gl/gl_bindings.h" 30 #include "ui/gl/gl_bindings.h"
30 #include "ui/gl/init/gl_factory.h" 31 #include "ui/gl/init/gl_factory.h"
31 32
32 using base::android::JavaParamRef; 33 using base::android::JavaParamRef;
33 34
34 namespace { 35 namespace {
35 // Constant taken from treasure_hunt demo. 36 // Constant taken from treasure_hunt demo.
36 static constexpr long kPredictionTimeWithoutVsyncNanos = 50000000; 37 static constexpr long kPredictionTimeWithoutVsyncNanos = 50000000;
37 38
38 static constexpr float kZNear = 0.1f; 39 static constexpr float kZNear = 0.1f;
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 gvr::GvrApi* VrShell::gvr_api() { 743 gvr::GvrApi* VrShell::gvr_api() {
743 return gvr_api_.get(); 744 return gvr_api_.get();
744 } 745 }
745 746
746 void VrShell::ContentSurfaceChanged(JNIEnv* env, 747 void VrShell::ContentSurfaceChanged(JNIEnv* env,
747 const JavaParamRef<jobject>& object, 748 const JavaParamRef<jobject>& object,
748 jint width, 749 jint width,
749 jint height, 750 jint height,
750 const JavaParamRef<jobject>& surface) { 751 const JavaParamRef<jobject>& surface) {
751 content_compositor_->SurfaceChanged((int)width, (int)height, surface); 752 content_compositor_->SurfaceChanged((int)width, (int)height, surface);
752 content::ScreenInfo result; 753 float scale_factor = display::Screen::GetScreen()
753 main_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost() 754 ->GetPrimaryDisplay().device_scale_factor();
754 ->GetScreenInfo(&result); 755 content_tex_width_ = width / scale_factor;
755 content_tex_width_ = width / result.device_scale_factor; 756 content_tex_height_ = height / scale_factor;
756 content_tex_height_ = height / result.device_scale_factor;
757 } 757 }
758 758
759 void VrShell::UiSurfaceChanged(JNIEnv* env, 759 void VrShell::UiSurfaceChanged(JNIEnv* env,
760 const JavaParamRef<jobject>& object, 760 const JavaParamRef<jobject>& object,
761 jint width, 761 jint width,
762 jint height, 762 jint height,
763 const JavaParamRef<jobject>& surface) { 763 const JavaParamRef<jobject>& surface) {
764 ui_compositor_->SurfaceChanged((int)width, (int)height, surface); 764 ui_compositor_->SurfaceChanged((int)width, (int)height, surface);
765 content::ScreenInfo result; 765 float scale_factor = display::Screen::GetScreen()
766 ui_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost()->GetScreenInfo( 766 ->GetPrimaryDisplay().device_scale_factor();
767 &result); 767 ui_tex_width_ = width / scale_factor;
768 ui_tex_width_ = width / result.device_scale_factor; 768 ui_tex_height_ = height / scale_factor;
769 ui_tex_height_ = height / result.device_scale_factor;
770 } 769 }
771 770
772 UiScene* VrShell::GetScene() { 771 UiScene* VrShell::GetScene() {
773 return scene_.get(); 772 return scene_.get();
774 } 773 }
775 774
776 UiInterface* VrShell::GetUiInterface() { 775 UiInterface* VrShell::GetUiInterface() {
777 return html_interface_.get(); 776 return html_interface_.get();
778 } 777 }
779 778
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 const JavaParamRef<jobject>& ui_web_contents, 844 const JavaParamRef<jobject>& ui_web_contents,
846 jlong ui_window_android) { 845 jlong ui_window_android) {
847 return reinterpret_cast<intptr_t>(new VrShell( 846 return reinterpret_cast<intptr_t>(new VrShell(
848 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 847 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
849 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 848 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
850 content::WebContents::FromJavaWebContents(ui_web_contents), 849 content::WebContents::FromJavaWebContents(ui_web_contents),
851 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); 850 reinterpret_cast<ui::WindowAndroid*>(ui_window_android)));
852 } 851 }
853 852
854 } // namespace vr_shell 853 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_input_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698