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

Unified Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2354373002: Implement UI web contents for Vr Shell (Closed)
Patch Set: Add new deps Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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..a67105c3c9084d73384ea2551097634b4f28b9bf 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"
@@ -59,15 +62,21 @@ static constexpr float kReticleZOffset = 0.01f;
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 +89,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();
bshe 2016/09/21 21:37:34 why is this no longer needed?
mthiesse 2016/09/21 23:56:48 It was never needed. I missed removing it when pul
+
+ 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 +104,15 @@ void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
gl::init::ClearGLBindings();
}
+void VrShell::LoadUIContent() {
+ content::WebContents* contents = ui_cvc_->GetWebContents();
+ content::NavigationController& controller = contents->GetController();
bshe 2016/09/21 21:37:34 nit: controller = ui_cvc_->GetWebContents()->GetCo
mthiesse 2016/09/21 23:56:48 Done.
+ GURL url(base::StringPiece("chrome://vr-shell-ui"));
bshe 2016/09/21 21:37:34 nit: similar to this pattern: https://cs.chromium.
mthiesse 2016/09/21 23:56:48 Done.
+ controller.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

Powered by Google App Engine
This is Rietveld 408576698