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

Side by Side Diff: sky/compositor/surface_holder.cc

Issue 871373015: De-Client Surface interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sky/compositor/surface_holder.h" 5 #include "sky/compositor/surface_holder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/public/cpp/application/connect.h" 10 #include "mojo/public/cpp/application/connect.h"
11 #include "mojo/public/interfaces/application/shell.mojom.h" 11 #include "mojo/public/interfaces/application/shell.mojom.h"
12 #include "sky/compositor/surface_allocator.h" 12 #include "sky/compositor/surface_allocator.h"
13 13
14 namespace sky { 14 namespace sky {
15 15
16 SurfaceHolder::Client::~Client() { 16 SurfaceHolder::Client::~Client() {
17 } 17 }
18 18
19 SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell) 19 SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell)
20 : client_(client), id_namespace_(0u), local_id_(0u), weak_factory_(this) { 20 : client_(client),
21 id_namespace_(0u),
22 local_id_(0u),
23 returner_binding_(this),
24 weak_factory_(this) {
21 mojo::ServiceProviderPtr service_provider; 25 mojo::ServiceProviderPtr service_provider;
22 shell->ConnectToApplication("mojo:surfaces_service", 26 shell->ConnectToApplication("mojo:surfaces_service",
23 mojo::GetProxy(&service_provider), nullptr); 27 mojo::GetProxy(&service_provider), nullptr);
24 mojo::ConnectToService(service_provider.get(), &surface_); 28 mojo::ConnectToService(service_provider.get(), &surface_);
25 surface_.set_client(this); 29 surface_->GetIdNamespace(
30 base::Bind(&SurfaceHolder::SetIdNamespace, base::Unretained(this)));
31 mojo::ResourceReturnerPtr returner_ptr;
32 returner_binding_.Bind(GetProxy(&returner_ptr));
33 surface_->SetResourceReturner(returner_ptr.Pass());
26 } 34 }
27 35
28 SurfaceHolder::~SurfaceHolder() { 36 SurfaceHolder::~SurfaceHolder() {
29 if (local_id_ != 0u) 37 if (local_id_ != 0u)
30 surface_->DestroySurface(local_id_); 38 surface_->DestroySurface(local_id_);
31 } 39 }
32 40
33 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame, 41 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame,
34 const base::Closure& callback) { 42 const base::Closure& callback) {
35 surface_->SubmitFrame(local_id_, frame.Pass(), callback); 43 surface_->SubmitFrame(local_id_, frame.Pass(), callback);
(...skipping 22 matching lines...) Expand all
58 } 66 }
59 67
60 void SurfaceHolder::SetIdNamespace(uint32_t id_namespace) { 68 void SurfaceHolder::SetIdNamespace(uint32_t id_namespace) {
61 id_namespace_ = id_namespace; 69 id_namespace_ = id_namespace;
62 if (local_id_ != 0u) 70 if (local_id_ != 0u)
63 SetQualifiedId(); 71 SetQualifiedId();
64 } 72 }
65 73
66 void SurfaceHolder::ReturnResources( 74 void SurfaceHolder::ReturnResources(
67 mojo::Array<mojo::ReturnedResourcePtr> resources) { 75 mojo::Array<mojo::ReturnedResourcePtr> resources) {
68 // TODO(abarth): The surface service shouldn't spam us with empty calls.
69 if (!resources.size())
70 return;
71 client_->ReturnResources(resources.Pass()); 76 client_->ReturnResources(resources.Pass());
72 } 77 }
73 78
74 } // namespace sky 79 } // namespace sky
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698