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

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) {
30 assert(layer_ == nullptr);
31 ui::ViewAndroid* view_android = core->GetWebContents()->GetNativeView();
32 // When we pass the layer for the ContentViewCore to the compositor it may be
33 // removing it from its previous parent, so we remember that and restore it to
34 // its previous parent on teardown.
35 layer_ = view_android->GetLayer();
36 layer_parent_ = layer_->parent();
37 compositor_->SetRootLayer(view_android->GetLayer());
38 }
39
40 void VrCompositor::SurfaceDestroyed() {
41 compositor_->SetSurface(nullptr);
42 }
43
44 void VrCompositor::SurfaceChanged(
45 int width,
46 int height,
47 const base::android::JavaParamRef<jobject>& surface) {
48 DCHECK(surface);
49 compositor_->SetSurface(surface);
50 compositor_->SetWindowBounds(gfx::Size(width, height));
51 }
52
53 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_compositor.h ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698