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

Unified Diff: sky/compositor/surface_holder.cc

Issue 826423008: Use local ids for Surfaces APIs that can only apply to local surfaces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« services/view_manager/display_manager.h ('K') | « sky/compositor/surface_holder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/compositor/surface_holder.cc
diff --git a/sky/compositor/surface_holder.cc b/sky/compositor/surface_holder.cc
index e8475802f301a0fecba33f20a8c06b8f3e6534fb..f2ad3297a07d8724d3a5e260732cf1e3884db534 100644
--- a/sky/compositor/surface_holder.cc
+++ b/sky/compositor/surface_holder.cc
@@ -17,48 +17,50 @@ SurfaceHolder::Client::~Client() {
}
SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell)
- : client_(client), weak_factory_(this) {
+ : client_(client), id_namespace_(0u), local_id_(0u), weak_factory_(this) {
mojo::ServiceProviderPtr service_provider;
shell->ConnectToApplication("mojo:surfaces_service",
mojo::GetProxy(&service_provider));
- mojo::ConnectToService(service_provider.get(), &surfaces_service_);
-
- surfaces_service_->CreateSurfaceConnection(base::Bind(
- &SurfaceHolder::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr()));
+ mojo::ConnectToService(service_provider.get(), &surface_);
+ surface_.set_client(this);
}
SurfaceHolder::~SurfaceHolder() {
- if (surface_ && surface_id_)
- surface_->DestroySurface(surface_id_.Clone());
-}
-
-bool SurfaceHolder::IsReadyForFrame() const {
- return surface_;
+ if (local_id_ != 0u)
+ surface_->DestroySurface(local_id_);
}
void SurfaceHolder::SubmitFrame(mojo::FramePtr frame,
const base::Closure& callback) {
- surface_->SubmitFrame(surface_id_.Clone(), frame.Pass(), callback);
+ surface_->SubmitFrame(local_id_, frame.Pass(), callback);
}
void SurfaceHolder::SetSize(const gfx::Size& size) {
- if (surface_id_ && size_ == size)
+ if (local_id_ != 0u && size_ == size)
return;
- if (surface_id_) {
- surface_->DestroySurface(surface_id_.Clone());
- } else {
- surface_id_ = mojo::SurfaceId::New();
- }
+ if (local_id_ != 0u)
+ surface_->DestroySurface(local_id_);
- surface_id_ = surface_allocator_->CreateSurfaceId();
- surface_->CreateSurface(surface_id_.Clone());
+ local_id_++;
+ surface_->CreateSurface(local_id_);
size_ = size;
- client_->OnSurfaceIdAvailable(surface_id_.Clone());
+ if (id_namespace_ != 0u)
+ SetQualifiedId();
+}
+
+void SurfaceHolder::SetQualifiedId() {
+ auto qualified_id = mojo::SurfaceId::New();
+ qualified_id->id_namespace = id_namespace_;
+ qualified_id->local = local_id_;
+ client_->OnSurfaceIdAvailable(qualified_id.Pass());
}
void SurfaceHolder::SetIdNamespace(uint32_t id_namespace) {
+ id_namespace_ = id_namespace;
+ if (local_id_ != 0u)
+ SetQualifiedId();
}
void SurfaceHolder::ReturnResources(
@@ -69,12 +71,4 @@ void SurfaceHolder::ReturnResources(
client_->ReturnResources(resources.Pass());
}
-void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface,
- uint32_t id_namespace) {
- surface_ = surface.Pass();
- surface_.set_client(this);
- surface_allocator_.reset(new SurfaceAllocator(id_namespace));
- client_->OnSurfaceConnectionCreated();
-}
-
} // namespace sky
« services/view_manager/display_manager.h ('K') | « sky/compositor/surface_holder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698