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

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

Issue 2319863005: Implement new compositor and ContentViewCore reparenting for VR Shell. (Closed)
Patch Set: Rebase onto ToT 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_compositor.cc
diff --git a/chrome/browser/android/vr_shell/vr_compositor.cc b/chrome/browser/android/vr_shell/vr_compositor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..492c77ad55494f454645fe60cd5c5b025738ab9e
--- /dev/null
+++ b/chrome/browser/android/vr_shell/vr_compositor.cc
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/vr_compositor.h"
+
+#include "cc/layers/layer.h"
+#include "content/public/browser/android/compositor.h"
+#include "content/public/browser/android/content_view_core.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/android/window_android.h"
+
+namespace vr_shell {
+
+VrCompositor::VrCompositor(ui::WindowAndroid* window) {
+ compositor_.reset(content::Compositor::Create(this, window));
+}
+
+VrCompositor::~VrCompositor() {
+ if (layer_parent_ && layer_) {
+ layer_parent_->AddChild(layer_);
+ }
+}
+
+void VrCompositor::UpdateLayerTreeHost() {}
+
+void VrCompositor::OnSwapBuffersCompleted(int pending_swap_buffers) {}
+
+void VrCompositor::SetLayer(content::ContentViewCore* core) {
mdjones 2016/09/20 20:29:44 Will this ever be called more than once for this o
mthiesse 2016/09/20 20:56:08 This will only ever be called once. I've added an
+ ui::ViewAndroid* view_android = core->GetWebContents()->GetNativeView();
+ // When we pass the layer for the ContentViewCore to the compositor it may be
+ // removing it from its previous parent, so we remember that and restore it to
+ // its previous parent on teardown.
+ layer_ = view_android->GetLayer();
+ layer_parent_ = layer_->parent();
+ compositor_->SetRootLayer(view_android->GetLayer());
+}
+
+void VrCompositor::SurfaceDestroyed() {
+ compositor_->SetSurface(nullptr);
+}
+
+void VrCompositor::SurfaceChanged(
+ int width,
+ int height,
+ const base::android::JavaParamRef<jobject>& surface) {
+ DCHECK(surface);
+ compositor_->SetSurface(surface);
+ compositor_->SetWindowBounds(gfx::Size(width, height));
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698