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

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

Issue 2595263002: Introduce ViewRoot forwarding input/view events to native (Closed)
Patch Set: unittest Created 3 years, 11 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 "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 gvr_context* gvr_api_; 95 gvr_context* gvr_api_;
96 bool initially_web_vr_; 96 bool initially_web_vr_;
97 bool reprojected_rendering_; 97 bool reprojected_rendering_;
98 }; 98 };
99 99
100 } // namespace 100 } // namespace
101 101
102 VrShell::VrShell(JNIEnv* env, 102 VrShell::VrShell(JNIEnv* env,
103 jobject obj, 103 jobject obj,
104 content::WebContents* main_contents, 104 content::WebContents* main_contents,
105 ui::WindowAndroid* content_window, 105 ui::ViewRoot* content_view_root,
106 content::WebContents* ui_contents, 106 content::WebContents* ui_contents,
107 ui::WindowAndroid* ui_window, 107 ui::ViewRoot* ui_view_root,
108 bool for_web_vr, 108 bool for_web_vr,
109 VrShellDelegate* delegate, 109 VrShellDelegate* delegate,
110 gvr_context* gvr_api, 110 gvr_context* gvr_api,
111 bool reprojected_rendering) 111 bool reprojected_rendering)
112 : WebContentsObserver(ui_contents), 112 : WebContentsObserver(ui_contents),
113 main_contents_(main_contents), 113 main_contents_(main_contents),
114 content_compositor_(new VrCompositor(content_window, false)), 114 content_compositor_(new VrCompositor(content_view_root, false)),
115 ui_contents_(ui_contents), 115 ui_contents_(ui_contents),
116 ui_compositor_(new VrCompositor(ui_window, true)), 116 ui_compositor_(new VrCompositor(ui_view_root, true)),
117 delegate_(delegate), 117 delegate_(delegate),
118 metrics_helper_(new VrMetricsHelper(main_contents_)), 118 metrics_helper_(new VrMetricsHelper(main_contents_)),
119 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), 119 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
120 reprojected_rendering_(reprojected_rendering), 120 reprojected_rendering_(reprojected_rendering),
121 weak_ptr_factory_(this) { 121 weak_ptr_factory_(this) {
122 DCHECK(g_instance == nullptr); 122 DCHECK(g_instance == nullptr);
123 g_instance = this; 123 g_instance = this;
124 j_vr_shell_.Reset(env, obj); 124 j_vr_shell_.Reset(env, obj);
125 125
126 content_input_manager_.reset(new VrInputManager(main_contents_)); 126 content_input_manager_.reset(new VrInputManager(main_contents_));
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 JNIEnv* env = base::android::AttachCurrentThread(); 467 JNIEnv* env = base::android::AttachCurrentThread();
468 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); 468 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr);
469 } 469 }
470 470
471 // ---------------------------------------------------------------------------- 471 // ----------------------------------------------------------------------------
472 // Native JNI methods 472 // Native JNI methods
473 // ---------------------------------------------------------------------------- 473 // ----------------------------------------------------------------------------
474 474
475 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj, 475 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj,
476 const JavaParamRef<jobject>& content_web_contents, 476 const JavaParamRef<jobject>& content_web_contents,
477 jlong content_window_android, 477 jlong content_view_root,
478 const JavaParamRef<jobject>& ui_web_contents, 478 const JavaParamRef<jobject>& ui_web_contents,
479 jlong ui_window_android, jboolean for_web_vr, 479 jlong ui_view_root, jboolean for_web_vr,
480 const base::android::JavaParamRef<jobject>& delegate, 480 const base::android::JavaParamRef<jobject>& delegate,
481 jlong gvr_api, jboolean reprojected_rendering) { 481 jlong gvr_api, jboolean reprojected_rendering) {
482 return reinterpret_cast<intptr_t>(new VrShell( 482 return reinterpret_cast<intptr_t>(new VrShell(
483 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 483 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
484 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 484 reinterpret_cast<ui::ViewRoot*>(content_view_root),
485 content::WebContents::FromJavaWebContents(ui_web_contents), 485 content::WebContents::FromJavaWebContents(ui_web_contents),
486 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), 486 reinterpret_cast<ui::ViewRoot*>(ui_view_root),
487 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), 487 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate),
488 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 488 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
489 } 489 }
490 490
491 } // namespace vr_shell 491 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698