Chromium Code Reviews| 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 6ee80a971117ccac7869df163ec0e59de4c6e91a..8bbe4430604423b2b0ce953f4c2e5c54d9b4008d 100644 |
| --- a/chrome/browser/android/vr_shell/vr_shell.cc |
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc |
| @@ -6,9 +6,16 @@ |
| #include <thread> |
| +#include "chrome/browser/android/vr_shell/vr_compositor.h" |
| #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 +34,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_view_core) |
|
amp
2016/09/12 22:36:53
Why is the WindowAndroid the content_view_core? I
mthiesse
2016/09/13 19:04:04
Whoops, typo.
|
| : desktop_screen_tilt_(kDesktopScreenTiltDefault), |
| desktop_height_(kDesktopHeightDefault), |
| - desktop_position_(kDesktopPositionDefault) { |
| + desktop_position_(kDesktopPositionDefault), |
| + content_cvc_(content_core) { |
| j_vr_shell_.Reset(env, obj); |
| + content_compositor_view_.reset(new VrCompositor(content_view_core)); |
| ui_rects_.emplace_back(new ContentRectangle()); |
| desktop_plane_ = ui_rects_.back().get(); |
| desktop_plane_->id = 0; |
| @@ -50,6 +61,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_cvc_->GetWebContents()->GetRenderWidgetHostView() |
| + ->GetRenderWidgetHost()->WasResized(); |
| +} |
| + |
| +void VrShell::UpdateCompositorLayers(JNIEnv* env, |
| + const JavaParamRef<jobject>& obj) { |
| + content_compositor_view_->SetLayer(content_cvc_); |
| } |
| void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| @@ -143,8 +161,8 @@ void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| } |
| void VrShell::DrawVrShell() { |
| - 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; |
| @@ -271,6 +289,19 @@ 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); |
| +} |
| + |
| void VrShell::UpdateTransforms(float screen_width_meters, |
| float screen_height_meters, |
| float screen_tilt) { |
| @@ -321,8 +352,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 |