| Index: components/view_manager/connection_manager.cc
|
| diff --git a/components/view_manager/connection_manager.cc b/components/view_manager/connection_manager.cc
|
| index 3a468367e7ca9e912887322b8eb44322fcc8ae59..b67a7ac515e76f399a0c2a356e00f9f33f2ed273 100644
|
| --- a/components/view_manager/connection_manager.cc
|
| +++ b/components/view_manager/connection_manager.cc
|
| @@ -6,6 +6,8 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/stl_util.h"
|
| +#include "cc/output/compositor_frame.h"
|
| +#include "cc/surfaces/surface_id_allocator.h"
|
| #include "components/view_manager/client_connection.h"
|
| #include "components/view_manager/connection_manager_delegate.h"
|
| #include "components/view_manager/focus_controller.h"
|
| @@ -16,12 +18,19 @@
|
| #include "mojo/application/public/cpp/application_connection.h"
|
| #include "mojo/converters/geometry/geometry_type_converters.h"
|
| #include "mojo/converters/input_events/input_events_type_converters.h"
|
| +#include "mojo/converters/surfaces/surfaces_type_converters.h"
|
|
|
| using mojo::ConnectionSpecificId;
|
|
|
| namespace view_manager {
|
| namespace {
|
|
|
| +namespace {
|
| +void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) {
|
| + callback.Run();
|
| +}
|
| +}
|
| +
|
| // Creates a copy of |view|. The copied view has |delegate| as its delegate.
|
| // This does not recurse.
|
| ServerView* CloneView(const ServerView* view, ServerViewDelegate* delegate) {
|
| @@ -110,8 +119,11 @@ ConnectionManager::ScopedChange::~ScopedChange() {
|
| connection_manager_->FinishChange();
|
| }
|
|
|
| -ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate)
|
| +ConnectionManager::ConnectionManager(
|
| + ConnectionManagerDelegate* delegate,
|
| + const scoped_refptr<surfaces::SurfacesState>& surfaces_state)
|
| : delegate_(delegate),
|
| + surfaces_state_(surfaces_state),
|
| next_connection_id_(1),
|
| next_root_id_(0),
|
| event_dispatcher_(this),
|
| @@ -450,6 +462,11 @@ void ConnectionManager::ProcessViewDeleted(const ViewId& view) {
|
| }
|
| }
|
|
|
| +void ConnectionManager::ReturnResources(
|
| + const cc::ReturnedResourceArray& resources) {
|
| + // TODO(fsamuel): Implement this.
|
| +}
|
| +
|
| void ConnectionManager::ProcessViewportMetricsChanged(
|
| const mojo::ViewportMetrics& old_metrics,
|
| const mojo::ViewportMetrics& new_metrics) {
|
| @@ -497,6 +514,45 @@ ViewManagerRootImpl* ConnectionManager::GetViewManagerRootByView(
|
| return nullptr;
|
| }
|
|
|
| +void ConnectionManager::SubmitCompositorFrame(ServerView* view,
|
| + mojo::CompositorFramePtr frame,
|
| + const mojo::Closure& callback) {
|
| + // Create Surfaces state on demand.
|
| + if (!surface_factory_) {
|
| + surface_factory_.reset(
|
| + new cc::SurfaceFactory(surfaces_state_->manager(), this));
|
| + }
|
| +
|
| + if (!surface_id_allocator_) {
|
| + surface_id_allocator_.reset(
|
| + new cc::SurfaceIdAllocator(surfaces_state_->next_id_namespace()));
|
| + }
|
| +
|
| +
|
| + if (view->surface_id().is_null()) {
|
| + // Create a Surface ID for the first time for this view.
|
| + cc::SurfaceId surface_id(surface_id_allocator_->GenerateId());
|
| + surface_factory_->Create(surface_id);
|
| + view->SetSurfaceId(surface_id);
|
| + } else {
|
| + // If the size of the CompostiorFrame has changed then destroy the existing
|
| + // Surface and create a new one of the appropriate size.
|
| + gfx::Size frame_size =
|
| + frame->passes[0]->output_rect.To<gfx::Rect>().size();
|
| + if (frame_size != view->last_submitted_frame_size()) {
|
| + surface_factory_->Destroy(view->surface_id());
|
| + cc::SurfaceId surface_id(surface_id_allocator_->GenerateId());
|
| + surface_factory_->Create(surface_id);
|
| + view->SetSurfaceId(surface_id);
|
| + }
|
| + }
|
| +
|
| + surface_factory_->SubmitFrame(view->surface_id(),
|
| + frame.To<scoped_ptr<cc::CompositorFrame>>(),
|
| + base::Bind(&CallCallback, callback));
|
| + surfaces_state_->scheduler()->SetNeedsDraw();
|
| +}
|
| +
|
| void ConnectionManager::PrepareToDestroyView(ServerView* view) {
|
| if (!in_destructor_ && IsViewAttachedToRoot(view) &&
|
| view->id() != ClonedViewId()) {
|
|
|