| Index: chrome/browser/android/vr_shell/vr_shell.cc
|
| diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
|
| index 66cc25e717ec5e57ebffcd523ed6362d2d6857aa..dd5fd6f7e7e9a4e60dacbcee6f9ba34f640ab87b 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell.cc
|
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc
|
| @@ -11,12 +11,15 @@
|
| #include "chrome/browser/android/vr_shell/vr_math.h"
|
| #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
|
| #include "content/public/browser/android/content_view_core.h"
|
| +#include "content/public/browser/navigation_controller.h"
|
| #include "content/public/browser/render_widget_host.h"
|
| #include "content/public/browser/render_widget_host_view.h"
|
| #include "content/public/browser/web_contents.h"
|
| +#include "content/public/common/referrer.h"
|
| #include "jni/VrShell_jni.h"
|
| #include "ui/android/view_android.h"
|
| #include "ui/android/window_android.h"
|
| +#include "ui/base/page_transition_types.h"
|
| #include "ui/gl/gl_bindings.h"
|
| #include "ui/gl/init/gl_factory.h"
|
|
|
| @@ -55,19 +58,27 @@ static constexpr gvr::Vec3f kHandPosition = {0.2f, -0.5f, -0.2f};
|
|
|
| static constexpr float kReticleZOffset = 0.01f;
|
|
|
| +static const char kVrShellUIURL[] = "chrome://vr-shell-ui";
|
| +
|
| } // namespace
|
|
|
| namespace vr_shell {
|
|
|
| -VrShell::VrShell(JNIEnv* env, jobject obj,
|
| - content::ContentViewCore* content_core,
|
| - ui::WindowAndroid* content_window)
|
| +VrShell::VrShell(JNIEnv* env,
|
| + jobject obj,
|
| + content::ContentViewCore* content_cvc,
|
| + ui::WindowAndroid* content_window,
|
| + content::ContentViewCore* ui_cvc,
|
| + ui::WindowAndroid* ui_window)
|
| : desktop_screen_tilt_(kDesktopScreenTiltDefault),
|
| desktop_height_(kDesktopHeightDefault),
|
| desktop_position_(kDesktopPositionDefault),
|
| - content_cvc_(content_core) {
|
| + content_cvc_(content_cvc),
|
| + ui_cvc_(ui_cvc) {
|
| j_vr_shell_.Reset(env, obj);
|
| - content_compositor_view_.reset(new VrCompositor(content_window));
|
| + content_compositor_.reset(new VrCompositor(content_window));
|
| + ui_compositor_.reset(new VrCompositor(ui_window));
|
| +
|
| ui_rects_.emplace_back(new ContentRectangle());
|
| desktop_plane_ = ui_rects_.back().get();
|
| desktop_plane_->id = 0;
|
| @@ -80,13 +91,14 @@ VrShell::VrShell(JNIEnv* env, jobject obj,
|
| desktop_plane_->anchor_z = false;
|
| desktop_plane_->orientation_axis_angle = {{1.0f, 0.0f, 0.0f, 0.0f}};
|
| desktop_plane_->rotation_axis_angle = {{0.0f, 0.0f, 0.0f, 0.0f}};
|
| - content_cvc_->GetWebContents()->GetRenderWidgetHostView()
|
| - ->GetRenderWidgetHost()->WasResized();
|
| +
|
| + LoadUIContent();
|
| }
|
|
|
| void VrShell::UpdateCompositorLayers(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj) {
|
| - content_compositor_view_->SetLayer(content_cvc_);
|
| + content_compositor_->SetLayer(content_cvc_);
|
| + ui_compositor_->SetLayer(ui_cvc_);
|
| }
|
|
|
| void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| @@ -94,6 +106,13 @@ void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| gl::init::ClearGLBindings();
|
| }
|
|
|
| +void VrShell::LoadUIContent() {
|
| + GURL url(kVrShellUIURL);
|
| + ui_cvc_->GetWebContents()->GetController().LoadURL(
|
| + url, content::Referrer(),
|
| + ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string(""));
|
| +}
|
| +
|
| bool RegisterVrShell(JNIEnv* env) {
|
| return RegisterNativesImpl(env);
|
| }
|
| @@ -113,11 +132,14 @@ void VrShell::GvrInit(JNIEnv* env,
|
|
|
| void VrShell::InitializeGl(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj,
|
| - jint texture_data_handle) {
|
| + jint content_texture_handle,
|
| + jint ui_texture_handle) {
|
| CHECK(gl::GetGLImplementation() != gl::kGLImplementationNone ||
|
| gl::init::InitializeGLOneOff());
|
|
|
| - content_texture_id_ = texture_data_handle;
|
| + content_texture_id_ = content_texture_handle;
|
| + ui_texture_id_ = ui_texture_handle;
|
| +
|
| gvr_api_->InitializeGl();
|
| std::vector<gvr::BufferSpec> specs;
|
| specs.push_back(gvr_api_->CreateBufferSpec());
|
| @@ -403,17 +425,20 @@ gvr::GvrApi* VrShell::gvr_api() {
|
| return gvr_api_.get();
|
| }
|
|
|
| -void VrShell::ContentSurfaceDestroyed(JNIEnv* env,
|
| - const JavaParamRef<jobject>& object) {
|
| - content_compositor_view_->SurfaceDestroyed();
|
| -}
|
| -
|
| void VrShell::ContentSurfaceChanged(JNIEnv* env,
|
| const JavaParamRef<jobject>& object,
|
| jint width,
|
| jint height,
|
| const JavaParamRef<jobject>& surface) {
|
| - content_compositor_view_->SurfaceChanged((int)width, (int)height, surface);
|
| + content_compositor_->SurfaceChanged((int)width, (int)height, surface);
|
| +}
|
| +
|
| +void VrShell::UiSurfaceChanged(JNIEnv* env,
|
| + const JavaParamRef<jobject>& object,
|
| + jint width,
|
| + jint height,
|
| + const JavaParamRef<jobject>& surface) {
|
| + ui_compositor_->SurfaceChanged((int)width, (int)height, surface);
|
| }
|
|
|
| void VrShell::UpdateTransforms(float screen_width_meters,
|
| @@ -469,12 +494,17 @@ void VrShell::UpdateTransforms(float screen_width_meters,
|
| jlong Init(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj,
|
| const JavaParamRef<jobject>& content_web_contents,
|
| - jlong content_window_android) {
|
| + jlong content_window_android,
|
| + const JavaParamRef<jobject>& ui_web_contents,
|
| + jlong ui_window_android) {
|
| content::ContentViewCore* c_core = content::ContentViewCore::FromWebContents(
|
| content::WebContents::FromJavaWebContents(content_web_contents));
|
| + content::ContentViewCore* ui_core = content::ContentViewCore::FromWebContents(
|
| + content::WebContents::FromJavaWebContents(ui_web_contents));
|
| return reinterpret_cast<intptr_t>(new VrShell(
|
| env, obj, c_core,
|
| - reinterpret_cast<ui::WindowAndroid*>(content_window_android)));
|
| + reinterpret_cast<ui::WindowAndroid*>(content_window_android), ui_core,
|
| + reinterpret_cast<ui::WindowAndroid*>(ui_window_android)));
|
| }
|
|
|
| } // namespace vr_shell
|
|
|