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

Unified Diff: components/view_manager/connection_manager.cc

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet anther rebase (YAR!!!) Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/view_manager/connection_manager.cc
diff --git a/components/view_manager/connection_manager.cc b/components/view_manager/connection_manager.cc
index ce8d32bab9db183345300b588eb29bd6814dc9e5..0bd53ce88692dbcdab27f412b0cfc0c3594c5859 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"
@@ -17,12 +19,19 @@
#include "mojo/application/public/interfaces/service_provider.mojom.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) {
@@ -111,8 +120,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),
@@ -451,6 +463,11 @@ void ConnectionManager::ProcessViewDeleted(const ViewId& view) {
}
}
+void ConnectionManager::ReturnResources(
rjkroege 2015/08/19 23:45:44 this is not how I plumbed it
Fady Samuel 2015/08/20 16:22:44 Feel free to change. This boilerplate code exists
+ const cc::ReturnedResourceArray& resources) {
+ // TODO(fsamuel): Implement this.
+}
+
void ConnectionManager::ProcessViewportMetricsChanged(
const mojo::ViewportMetrics& old_metrics,
const mojo::ViewportMetrics& new_metrics) {
@@ -498,6 +515,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()) {

Powered by Google App Engine
This is Rietveld 408576698