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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/vr_compositor.h"
6
7 #include "cc/layers/layer.h"
8 #include "content/public/browser/android/compositor.h"
9 #include "content/public/browser/android/content_view_core.h"
10 #include "content/public/browser/web_contents.h"
11 #include "ui/android/window_android.h"
12
13 namespace vr_shell {
14
15 VrCompositor::VrCompositor(ui::WindowAndroid* window) {
16 compositor_.reset(content::Compositor::Create(this, window));
17 }
18
19 VrCompositor::~VrCompositor() {
20 if (layer_parent_ && layer_) {
21 layer_parent_->AddChild(layer_);
22 }
23 }
24
25 void VrCompositor::UpdateLayerTreeHost() {}
26
27 void VrCompositor::OnSwapBuffersCompleted(int pending_swap_buffers) {}
28
29 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
30 ui::ViewAndroid* view_android = core->GetWebContents()->GetNativeView();
31 // When we pass the layer for the ContentViewCore to the compositor it may be
32 // removing it from its previous parent, so we remember that and restore it to
33 // its previous parent on teardown.
34 layer_ = view_android->GetLayer();
35 layer_parent_ = layer_->parent();
36 compositor_->SetRootLayer(view_android->GetLayer());
37 }
38
39 void VrCompositor::SurfaceDestroyed() {
40 compositor_->SetSurface(nullptr);
41 }
42
43 void VrCompositor::SurfaceChanged(
44 int width,
45 int height,
46 const base::android::JavaParamRef<jobject>& surface) {
47 DCHECK(surface);
48 compositor_->SetSurface(surface);
49 compositor_->SetWindowBounds(gfx::Size(width, height));
50 }
51
52 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698