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

Unified Diff: ui/compositor/compositor.cc

Issue 2175293003: cc: Register namespace hierarchy after ui::Compositor's SurfaceFactory available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit test and addressed comments Created 4 years, 5 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
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/compositor.cc
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 1c3f3bc0e1256c0f734c25c32661214c9ce02073..8d1f7a02f332e35af79a87f06fd94a2e0f7298f9 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -245,15 +245,58 @@ Compositor::~Compositor() {
context_factory_->RemoveCompositor(this);
if (context_factory_->GetSurfaceManager()) {
+ for (auto& client : surface_clients_) {
+ if (client.second) {
+ context_factory_->GetSurfaceManager()
+ ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first);
+ }
+ }
context_factory_->GetSurfaceManager()->InvalidateSurfaceClientId(
surface_id_allocator_->client_id());
}
}
+void Compositor::AddSurfaceClient(uint32_t client_id) {
+ // We don't give the client a parent until the ui::Compositor has an
+ // OutputSurface.
+ uint32_t parent_client_id = 0;
+ if (host_->has_output_surface()) {
+ parent_client_id = surface_id_allocator_->client_id();
+ context_factory_->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy(
+ parent_client_id, client_id);
+ }
+ surface_clients_[client_id] = parent_client_id;
+}
+
+void Compositor::RemoveSurfaceClient(uint32_t client_id) {
+ auto it = surface_clients_.find(client_id);
+ DCHECK(it != surface_clients_.end());
+ if (host_->has_output_surface()) {
+ context_factory_->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy(
+ it->second, client_id);
+ }
+ surface_clients_.erase(it);
+}
+
void Compositor::SetOutputSurface(
std::unique_ptr<cc::OutputSurface> output_surface) {
output_surface_requested_ = false;
host_->SetOutputSurface(std::move(output_surface));
+ // ui::Compositor uses a SingleThreadProxy and so BindToClient will be called
+ // above and SurfaceManager will be made aware of the OutputSurface's client
+ // ID.
+ for (auto& client : surface_clients_) {
+ if (client.second == surface_id_allocator_->client_id())
+ continue;
+ // If a client already has a parent, then we unregister the existing parent.
+ if (client.second) {
+ context_factory_->GetSurfaceManager()
+ ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first);
+ }
+ context_factory_->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy(
+ surface_id_allocator_->client_id(), client.first);
+ client.second = surface_id_allocator_->client_id();
+ }
}
void Compositor::ScheduleDraw() {
@@ -363,8 +406,14 @@ void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) {
gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() {
DCHECK(!IsVisible());
- if (!host_->output_surface_lost())
+ if (!host_->output_surface_lost()) {
host_->ReleaseOutputSurface();
+ for (auto& client : surface_clients_) {
+ context_factory_->GetSurfaceManager()
+ ->UnregisterSurfaceNamespaceHierarchy(client.second, client.first);
+ client.second = 0;
+ }
+ }
context_factory_->RemoveCompositor(this);
widget_valid_ = false;
gfx::AcceleratedWidget widget = widget_;
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698