| 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 e79d743b24e2821af4ee78c48512edc56fa9bb72..d953ab743036d97c152b584d0fcaf67b617688b0 100644
|
| --- a/chrome/browser/android/vr_shell/vr_shell.cc
|
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc
|
| @@ -8,7 +8,13 @@
|
|
|
| #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
|
| #include "chrome/browser/android/vr_shell/vr_util.h"
|
| +#include "content/public/browser/android/content_view_core.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 "jni/VrShell_jni.h"
|
| +#include "ui/android/view_android.h"
|
| +#include "ui/android/window_android.h"
|
| #include "ui/gl/gl_bindings.h"
|
| #include "ui/gl/init/gl_factory.h"
|
|
|
| @@ -27,17 +33,21 @@ static constexpr float kDesktopHeightDefault = 1.6f;
|
| // Screen angle in degrees. 0 = vertical, positive = top closer.
|
| static constexpr float kDesktopScreenTiltDefault = 0;
|
|
|
| -static constexpr float kScreenHeightMeters = 2.0f;
|
| -static constexpr float kScreenWidthMeters = 2.0f;
|
| -}
|
| +static constexpr float kScreenHeightRatio = 1.0f;
|
| +static constexpr float kScreenWidthRatio = 16.0f / 9.0f;
|
| +} // namespace
|
|
|
| namespace vr_shell {
|
|
|
| -VrShell::VrShell(JNIEnv* env, jobject obj)
|
| +VrShell::VrShell(JNIEnv* env, jobject obj,
|
| + content::ContentViewCore* content_core,
|
| + ui::WindowAndroid* content_window)
|
| : desktop_screen_tilt_(kDesktopScreenTiltDefault),
|
| desktop_height_(kDesktopHeightDefault),
|
| - desktop_position_(kDesktopPositionDefault) {
|
| + desktop_position_(kDesktopPositionDefault),
|
| + content_core_(content_core) {
|
| j_vr_shell_.Reset(env, obj);
|
| + content_compositor_view_.reset(new SimpleCompositorView(content_window));
|
| ui_rects_.emplace_back(new ContentRectangle());
|
| desktop_plane_ = ui_rects_.back().get();
|
| desktop_plane_->id = 0;
|
| @@ -50,6 +60,13 @@ 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_core_->GetWebContents()->GetRenderWidgetHostView()
|
| + ->GetRenderWidgetHost()->WasResized();
|
| +}
|
| +
|
| +void VrShell::UpdateCompositorLayers(JNIEnv* env,
|
| + const JavaParamRef<jobject>& obj) {
|
| + content_compositor_view_->SetLayer(content_core_);
|
| }
|
|
|
| void VrShell::Destroy(JNIEnv* env,
|
| @@ -120,8 +137,8 @@ void ApplyNeckModel(gvr::Mat4f& mat_forward) {
|
|
|
| void VrShell::DrawFrame(JNIEnv* env,
|
| const JavaParamRef<jobject>& obj) {
|
| - float screen_width = kScreenWidthMeters * desktop_height_;
|
| - float screen_height = kScreenHeightMeters * desktop_height_;
|
| + float screen_width = kScreenWidthRatio * desktop_height_;
|
| + float screen_height = kScreenHeightRatio * desktop_height_;
|
|
|
| float screen_tilt = desktop_screen_tilt_ * M_PI / 180.0f;
|
|
|
| @@ -224,6 +241,19 @@ void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| gvr_api_->ResumeTracking();
|
| }
|
|
|
| +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);
|
| +}
|
| +
|
| void VrShell::UpdateTransforms(float screen_width_meters,
|
| float screen_height_meters,
|
| float screen_tilt) {
|
| @@ -274,8 +304,15 @@ void VrShell::UpdateTransforms(float screen_width_meters,
|
| // Native JNI methods
|
| // ----------------------------------------------------------------------------
|
|
|
| -jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
|
| - return reinterpret_cast<intptr_t>(new VrShell(env, obj));
|
| +jlong Init(JNIEnv* env,
|
| + const JavaParamRef<jobject>& obj,
|
| + const JavaParamRef<jobject>& content_web_contents,
|
| + jlong content_window_android) {
|
| + content::ContentViewCore* c_core = content::ContentViewCore::FromWebContents(
|
| + content::WebContents::FromJavaWebContents(content_web_contents));
|
| + return reinterpret_cast<intptr_t>(new VrShell(
|
| + env, obj, c_core,
|
| + reinterpret_cast<ui::WindowAndroid*>(content_window_android)));
|
| }
|
|
|
| } // namespace vr_shell
|
|
|