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

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

Issue 2319863005: Implement new compositor and ContentViewCore reparenting for VR Shell. (Closed)
Patch Set: 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/simple_compositor_view.cc
diff --git a/chrome/browser/android/vr_shell/simple_compositor_view.cc b/chrome/browser/android/vr_shell/simple_compositor_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a32db674496dcee9c363ff121a8bd25b8fc20605
--- /dev/null
+++ b/chrome/browser/android/vr_shell/simple_compositor_view.cc
@@ -0,0 +1,60 @@
+// 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/simple_compositor_view.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 {
+
+SimpleCompositorView::SimpleCompositorView(ui::WindowAndroid* window)
cjgrant 2016/09/09 13:56:32 Does Google style allow in-class initializers?
mthiesse 2016/09/09 14:45:25 I think so. I'll use them because I also prefer th
+ : current_surface_format_(0), layer_(nullptr), layer_parent_(nullptr) {
+ compositor_.reset(content::Compositor::Create(this, window));
+}
+
+SimpleCompositorView::~SimpleCompositorView() {
+ if (layer_parent_ && layer_) {
+ layer_parent_->AddChild(layer_);
+ }
+}
+
+void SimpleCompositorView::UpdateLayerTreeHost() {}
+
+void SimpleCompositorView::OnSwapBuffersCompleted(int pending_swap_buffers) {}
+
+void SimpleCompositorView::SurfaceCreated() {
+ current_surface_format_ = 0;
cjgrant 2016/09/09 13:56:32 Consider a constant instead of 0, as suggested els
mthiesse 2016/09/09 14:45:25 Done.
+}
+
+void SimpleCompositorView::SetLayer(content::ContentViewCore* core) {
+ 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 owner, so we remember that and restore it to
+ // its previous owner on teardown.
+ layer_ = view_android->GetLayer();
+ layer_parent_ = layer_->parent();
+ compositor_->SetRootLayer(view_android->GetLayer());
+}
+
+void SimpleCompositorView::SurfaceDestroyed() {
+ compositor_->SetSurface(nullptr);
+ current_surface_format_ = 0;
cjgrant 2016/09/09 13:56:32 (same as above)
mthiesse 2016/09/09 14:45:25 Done.
+}
+
+void SimpleCompositorView::SurfaceChanged(
+ int format,
+ int width,
+ int height,
+ const base::android::JavaParamRef<jobject>& surface) {
+ DCHECK(surface);
+ current_surface_format_ = format;
+ compositor_->SetSurface(surface);
+ compositor_->SetWindowBounds(gfx::Size(width, height));
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698