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 e79d743b24e2821af4ee78c48512edc56fa9bb72..abc5b375e8c05212af5efc1c4fb12ce7122d0826 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 kScreenHeightMeters = 1.0f; |
| +static constexpr float kScreenWidthMeters = 16.0f / 9.0f; |
|
cjgrant
2016/09/09 13:56:33
This constant looks misnamed (it appears to be a r
mthiesse
2016/09/09 14:45:25
Done.
|
| } |
| 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,15 @@ 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() |
|
cjgrant
2016/09/09 13:56:32
Shouldn't this wrap on two lines rather than four?
mthiesse
2016/09/09 14:45:25
This is just what auto-format does. I'll make it t
|
| + ->GetRenderWidgetHostView() |
| + ->GetRenderWidgetHost() |
| + ->WasResized(); |
| +} |
| + |
| +void VrShell::UpdateCompositorLayers(JNIEnv* env, |
| + const JavaParamRef<jobject>& obj) { |
| + content_compositor_view_->SetLayer(content_core_); |
| } |
| void VrShell::Destroy(JNIEnv* env, |
| @@ -224,6 +243,26 @@ void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| gvr_api_->ResumeTracking(); |
| } |
| +void VrShell::ContentSurfaceCreated(JNIEnv* env, |
| + const JavaParamRef<jobject>& object) { |
| + content_compositor_view_->SurfaceCreated(); |
| +} |
| + |
| +void VrShell::ContentSurfaceDestroyed(JNIEnv* env, |
| + const JavaParamRef<jobject>& object) { |
| + content_compositor_view_->SurfaceDestroyed(); |
| +} |
| + |
| +void VrShell::ContentSurfaceChanged(JNIEnv* env, |
| + const JavaParamRef<jobject>& object, |
| + jint format, |
| + jint width, |
| + jint height, |
| + const JavaParamRef<jobject>& surface) { |
| + content_compositor_view_->SurfaceChanged((int)format, (int)width, (int)height, |
| + surface); |
| +} |
| + |
| void VrShell::UpdateTransforms(float screen_width_meters, |
| float screen_height_meters, |
| float screen_tilt) { |
| @@ -274,8 +313,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 |