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

Side by Side 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 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/simple_compositor_view.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 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
16 : current_surface_format_(0), layer_(nullptr), layer_parent_(nullptr) {
17 compositor_.reset(content::Compositor::Create(this, window));
18 }
19
20 SimpleCompositorView::~SimpleCompositorView() {
21 if (layer_parent_ && layer_) {
22 layer_parent_->AddChild(layer_);
23 }
24 }
25
26 void SimpleCompositorView::UpdateLayerTreeHost() {}
27
28 void SimpleCompositorView::OnSwapBuffersCompleted(int pending_swap_buffers) {}
29
30 void SimpleCompositorView::SurfaceCreated() {
31 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.
32 }
33
34 void SimpleCompositorView::SetLayer(content::ContentViewCore* core) {
35 ui::ViewAndroid* view_android = core->GetWebContents()->GetNativeView();
36 // When we pass the layer for the ContentViewCore to the compositor it may be
37 // removing it from its previous owner, so we remember that and restore it to
38 // its previous owner on teardown.
39 layer_ = view_android->GetLayer();
40 layer_parent_ = layer_->parent();
41 compositor_->SetRootLayer(view_android->GetLayer());
42 }
43
44 void SimpleCompositorView::SurfaceDestroyed() {
45 compositor_->SetSurface(nullptr);
46 current_surface_format_ = 0;
cjgrant 2016/09/09 13:56:32 (same as above)
mthiesse 2016/09/09 14:45:25 Done.
47 }
48
49 void SimpleCompositorView::SurfaceChanged(
50 int format,
51 int width,
52 int height,
53 const base::android::JavaParamRef<jobject>& surface) {
54 DCHECK(surface);
55 current_surface_format_ = format;
56 compositor_->SetSurface(surface);
57 compositor_->SetWindowBounds(gfx::Size(width, height));
58 }
59
60 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698