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

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

Issue 2955483003: Show splash screen when entering VR from a deep-link (Closed)
Patch Set: . Created 3 years, 6 months 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
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 <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "device/vr/android/gvr/gvr_device_provider.h" 49 #include "device/vr/android/gvr/gvr_device_provider.h"
50 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h" 50 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
51 #include "gpu/command_buffer/common/mailbox.h" 51 #include "gpu/command_buffer/common/mailbox.h"
52 #include "jni/VrShellImpl_jni.h" 52 #include "jni/VrShellImpl_jni.h"
53 #include "third_party/WebKit/public/platform/WebInputEvent.h" 53 #include "third_party/WebKit/public/platform/WebInputEvent.h"
54 #include "ui/android/view_android.h" 54 #include "ui/android/view_android.h"
55 #include "ui/android/window_android.h" 55 #include "ui/android/window_android.h"
56 #include "ui/base/page_transition_types.h" 56 #include "ui/base/page_transition_types.h"
57 #include "ui/display/display.h" 57 #include "ui/display/display.h"
58 #include "ui/display/screen.h" 58 #include "ui/display/screen.h"
59 #include "ui/gfx/android/java_bitmap.h"
59 #include "ui/gfx/codec/png_codec.h" 60 #include "ui/gfx/codec/png_codec.h"
60 #include "ui/gfx/geometry/size.h" 61 #include "ui/gfx/geometry/size.h"
61 #include "ui/gfx/native_widget_types.h" 62 #include "ui/gfx/native_widget_types.h"
62 #include "url/gurl.h" 63 #include "url/gurl.h"
63 64
64 using base::android::JavaParamRef; 65 using base::android::JavaParamRef;
65 using base::android::JavaRef; 66 using base::android::JavaRef;
66 67
67 namespace vr_shell { 68 namespace vr_shell {
68 69
(...skipping 18 matching lines...) Expand all
87 vr_tab_helper->SetIsInVr(is_in_vr); 88 vr_tab_helper->SetIsInVr(is_in_vr);
88 } 89 }
89 } 90 }
90 91
91 } // namespace 92 } // namespace
92 93
93 VrShell::VrShell(JNIEnv* env, 94 VrShell::VrShell(JNIEnv* env,
94 jobject obj, 95 jobject obj,
95 ui::WindowAndroid* window, 96 ui::WindowAndroid* window,
96 bool for_web_vr, 97 bool for_web_vr,
97 bool web_vr_autopresented, 98 bool web_vr_autopresentation_expected,
98 bool in_cct, 99 bool in_cct,
99 VrShellDelegate* delegate, 100 VrShellDelegate* delegate,
100 gvr_context* gvr_api, 101 gvr_context* gvr_api,
101 bool reprojected_rendering) 102 bool reprojected_rendering)
102 : vr_shell_enabled_(base::FeatureList::IsEnabled(features::kVrShell)), 103 : vr_shell_enabled_(base::FeatureList::IsEnabled(features::kVrShell)),
103 window_(window), 104 window_(window),
104 compositor_(base::MakeUnique<VrCompositor>(window_)), 105 compositor_(base::MakeUnique<VrCompositor>(window_)),
105 delegate_provider_(delegate), 106 delegate_provider_(delegate),
106 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), 107 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
107 reprojected_rendering_(reprojected_rendering), 108 reprojected_rendering_(reprojected_rendering),
108 gvr_api_(gvr_api), 109 gvr_api_(gvr_api),
109 weak_ptr_factory_(this) { 110 weak_ptr_factory_(this) {
110 DVLOG(1) << __FUNCTION__ << "=" << this; 111 DVLOG(1) << __FUNCTION__ << "=" << this;
111 DCHECK(g_instance == nullptr); 112 DCHECK(g_instance == nullptr);
112 g_instance = this; 113 g_instance = this;
113 j_vr_shell_.Reset(env, obj); 114 j_vr_shell_.Reset(env, obj);
114 115
115 gl_thread_ = base::MakeUnique<VrGLThread>( 116 gl_thread_ = base::MakeUnique<VrGLThread>(
116 weak_ptr_factory_.GetWeakPtr(), main_thread_task_runner_, gvr_api, 117 weak_ptr_factory_.GetWeakPtr(), main_thread_task_runner_, gvr_api,
117 for_web_vr, web_vr_autopresented, in_cct, reprojected_rendering_, 118 for_web_vr, web_vr_autopresentation_expected, in_cct,
118 HasDaydreamSupport(env)); 119 reprojected_rendering_, HasDaydreamSupport(env));
119 ui_ = gl_thread_.get(); 120 ui_ = gl_thread_.get();
120 121
121 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); 122 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0);
122 options.priority = base::ThreadPriority::DISPLAY; 123 options.priority = base::ThreadPriority::DISPLAY;
123 gl_thread_->StartWithOptions(options); 124 gl_thread_->StartWithOptions(options);
124 } 125 }
125 126
127 void VrShell::SetSplashScreenIcon(JNIEnv* env,
128 const JavaParamRef<jobject>& obj,
129 const JavaParamRef<jobject>& bitmap) {
130 ui_->SetSplashScreenIcon(
131 gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(bitmap)));
132 }
133
126 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { 134 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
127 delete this; 135 delete this;
128 } 136 }
129 137
130 void VrShell::SwapContents( 138 void VrShell::SwapContents(
131 JNIEnv* env, 139 JNIEnv* env,
132 const JavaParamRef<jobject>& obj, 140 const JavaParamRef<jobject>& obj,
133 const JavaParamRef<jobject>& web_contents, 141 const JavaParamRef<jobject>& web_contents,
134 const JavaParamRef<jobject>& touch_event_synthesizer) { 142 const JavaParamRef<jobject>& touch_event_synthesizer) {
135 content::WebContents* contents = 143 content::WebContents* contents =
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 gfx::AcceleratedWidget window = 338 gfx::AcceleratedWidget window =
331 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface); 339 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface);
332 WaitForGlThread(); 340 WaitForGlThread();
333 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::InitializeGl, 341 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::InitializeGl,
334 gl_thread_->GetVrShellGl(), 342 gl_thread_->GetVrShellGl(),
335 base::Unretained(window))); 343 base::Unretained(window)));
336 } 344 }
337 345
338 void VrShell::SetWebVrMode(JNIEnv* env, 346 void VrShell::SetWebVrMode(JNIEnv* env,
339 const JavaParamRef<jobject>& obj, 347 const JavaParamRef<jobject>& obj,
340 bool enabled, 348 bool enabled) {
341 bool auto_presented) {
342 webvr_mode_ = enabled; 349 webvr_mode_ = enabled;
343 if (metrics_helper_) 350 if (metrics_helper_)
344 metrics_helper_->SetWebVREnabled(enabled); 351 metrics_helper_->SetWebVREnabled(enabled);
345 WaitForGlThread(); 352 WaitForGlThread();
346 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::SetWebVrMode, 353 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::SetWebVrMode,
347 gl_thread_->GetVrShellGl(), enabled)); 354 gl_thread_->GetVrShellGl(), enabled));
348 ui_->SetWebVrMode(enabled, auto_presented); 355 ui_->SetWebVrMode(enabled);
349 } 356 }
350 357
351 void VrShell::OnFullscreenChanged(bool enabled) { 358 void VrShell::OnFullscreenChanged(bool enabled) {
352 JNIEnv* env = base::android::AttachCurrentThread(); 359 JNIEnv* env = base::android::AttachCurrentThread();
353 Java_VrShellImpl_onFullscreenChanged(env, j_vr_shell_.obj(), enabled); 360 Java_VrShellImpl_onFullscreenChanged(env, j_vr_shell_.obj(), enabled);
354 ui_->SetFullscreen(enabled); 361 ui_->SetFullscreen(enabled);
355 } 362 }
356 363
357 bool VrShell::GetWebVrMode(JNIEnv* env, const JavaParamRef<jobject>& obj) { 364 bool VrShell::GetWebVrMode(JNIEnv* env, const JavaParamRef<jobject>& obj) {
358 return webvr_mode_; 365 return webvr_mode_;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 733
727 // ---------------------------------------------------------------------------- 734 // ----------------------------------------------------------------------------
728 // Native JNI methods 735 // Native JNI methods
729 // ---------------------------------------------------------------------------- 736 // ----------------------------------------------------------------------------
730 737
731 jlong Init(JNIEnv* env, 738 jlong Init(JNIEnv* env,
732 const JavaParamRef<jobject>& obj, 739 const JavaParamRef<jobject>& obj,
733 const JavaParamRef<jobject>& delegate, 740 const JavaParamRef<jobject>& delegate,
734 jlong window_android, 741 jlong window_android,
735 jboolean for_web_vr, 742 jboolean for_web_vr,
736 jboolean web_vr_autopresented, 743 jboolean web_vr_autopresentation_expected,
737 jboolean in_cct, 744 jboolean in_cct,
738 jlong gvr_api, 745 jlong gvr_api,
739 jboolean reprojected_rendering) { 746 jboolean reprojected_rendering) {
740 return reinterpret_cast<intptr_t>(new VrShell( 747 return reinterpret_cast<intptr_t>(new VrShell(
741 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), 748 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android),
742 for_web_vr, web_vr_autopresented, in_cct, 749 for_web_vr, web_vr_autopresentation_expected, in_cct,
743 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 750 VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
744 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 751 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
745 } 752 }
746 753
747 } // namespace vr_shell 754 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698