Chromium Code Reviews| 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 |