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

Side by Side Diff: services/ui/ws/display.cc

Issue 2400723003: Mus+Ash: Use standard cc mechanism for surface lifetime. (Closed)
Patch Set: Only AddObserver once Created 4 years, 2 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
« no previous file with comments | « services/ui/ws/display.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/ui/ws/display.h" 5 #include "services/ui/ws/display.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 window_server_->user_id_tracker()->RemoveObserver(this); 47 window_server_->user_id_tracker()->RemoveObserver(this);
48 48
49 window_server_->window_manager_window_tree_factory_set()->RemoveObserver( 49 window_server_->window_manager_window_tree_factory_set()->RemoveObserver(
50 this); 50 this);
51 51
52 if (!focus_controller_) { 52 if (!focus_controller_) {
53 focus_controller_->RemoveObserver(this); 53 focus_controller_->RemoveObserver(this);
54 focus_controller_.reset(); 54 focus_controller_.reset();
55 } 55 }
56 56
57 for (ServerWindow* window : windows_needing_frame_destruction_)
58 window->RemoveObserver(this);
59
60 if (!binding_) { 57 if (!binding_) {
61 for (auto& pair : window_manager_display_root_map_) 58 for (auto& pair : window_manager_display_root_map_)
62 pair.second->window_manager_state()->OnDisplayDestroying(this); 59 pair.second->window_manager_state()->OnDisplayDestroying(this);
63 } else if (!window_manager_display_root_map_.empty()) { 60 } else if (!window_manager_display_root_map_.empty()) {
64 // If there is a |binding_| then the tree was created specifically for this 61 // If there is a |binding_| then the tree was created specifically for this
65 // display (which corresponds to a WindowTreeHost). 62 // display (which corresponds to a WindowTreeHost).
66 window_server_->DestroyTree(window_manager_display_root_map_.begin() 63 window_server_->DestroyTree(window_manager_display_root_map_.begin()
67 ->second->window_manager_state() 64 ->second->window_manager_state()
68 ->window_tree()); 65 ->window_tree());
69 } 66 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 109
113 return display; 110 return display;
114 } 111 }
115 112
116 void Display::SchedulePaint(const ServerWindow* window, 113 void Display::SchedulePaint(const ServerWindow* window,
117 const gfx::Rect& bounds) { 114 const gfx::Rect& bounds) {
118 DCHECK(root_->Contains(window)); 115 DCHECK(root_->Contains(window));
119 platform_display_->SchedulePaint(window, bounds); 116 platform_display_->SchedulePaint(window, bounds);
120 } 117 }
121 118
122 void Display::ScheduleSurfaceDestruction(ServerWindow* window) {
123 if (!platform_display_->IsFramePending()) {
124 window->DestroySurfacesScheduledForDestruction();
125 return;
126 }
127 if (windows_needing_frame_destruction_.count(window))
128 return;
129 windows_needing_frame_destruction_.insert(window);
130 window->AddObserver(this);
131 }
132
133 display::Display::Rotation Display::GetRotation() const { 119 display::Display::Rotation Display::GetRotation() const {
134 return platform_display_->GetRotation(); 120 return platform_display_->GetRotation();
135 } 121 }
136 122
137 gfx::Size Display::GetSize() const { 123 gfx::Size Display::GetSize() const {
138 return platform_display_->GetBounds().size(); 124 return platform_display_->GetBounds().size();
139 } 125 }
140 126
141 ServerWindow* Display::GetRootWithId(const WindowId& id) { 127 ServerWindow* Display::GetRootWithId(const WindowId& id) {
142 if (id == root_->id()) 128 if (id == root_->id())
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return; 315 return;
330 316
331 gfx::Rect new_bounds(new_metrics.bounds.size()); 317 gfx::Rect new_bounds(new_metrics.bounds.size());
332 root_->SetBounds(new_bounds); 318 root_->SetBounds(new_bounds);
333 for (auto& pair : window_manager_display_root_map_) 319 for (auto& pair : window_manager_display_root_map_)
334 pair.second->root()->SetBounds(new_bounds); 320 pair.second->root()->SetBounds(new_bounds);
335 321
336 display_manager()->OnDisplayUpdate(this); 322 display_manager()->OnDisplayUpdate(this);
337 } 323 }
338 324
339 void Display::OnCompositorFrameDrawn() {
340 std::set<ServerWindow*> windows;
341 windows.swap(windows_needing_frame_destruction_);
342 for (ServerWindow* window : windows) {
343 window->RemoveObserver(this);
344 window->DestroySurfacesScheduledForDestruction();
345 }
346 }
347
348 bool Display::CanHaveActiveChildren(ServerWindow* window) const { 325 bool Display::CanHaveActiveChildren(ServerWindow* window) const {
349 return window && activation_parents_.Contains(window); 326 return window && activation_parents_.Contains(window);
350 } 327 }
351 328
352 void Display::OnActivationChanged(ServerWindow* old_active_window, 329 void Display::OnActivationChanged(ServerWindow* old_active_window,
353 ServerWindow* new_active_window) { 330 ServerWindow* new_active_window) {
354 // Don't do anything here. We assume the window manager handles restacking. If 331 // Don't do anything here. We assume the window manager handles restacking. If
355 // we did attempt to restack than we would have to ensure clients see the 332 // we did attempt to restack than we would have to ensure clients see the
356 // restack. 333 // restack.
357 } 334 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (wm_tree != owning_tree_old && wm_tree != embedded_tree_old && 388 if (wm_tree != owning_tree_old && wm_tree != embedded_tree_old &&
412 wm_tree != owning_tree_new && wm_tree != embedded_tree_new) { 389 wm_tree != owning_tree_new && wm_tree != embedded_tree_new) {
413 wm_tree->ProcessFocusChanged(old_focused_window, new_focused_window); 390 wm_tree->ProcessFocusChanged(old_focused_window, new_focused_window);
414 } 391 }
415 } 392 }
416 393
417 UpdateTextInputState(new_focused_window, 394 UpdateTextInputState(new_focused_window,
418 new_focused_window->text_input_state()); 395 new_focused_window->text_input_state());
419 } 396 }
420 397
421 void Display::OnWindowDestroyed(ServerWindow* window) {
422 windows_needing_frame_destruction_.erase(window);
423 window->RemoveObserver(this);
424 }
425
426 void Display::OnUserIdRemoved(const UserId& id) { 398 void Display::OnUserIdRemoved(const UserId& id) {
427 window_manager_display_root_map_.erase(id); 399 window_manager_display_root_map_.erase(id);
428 } 400 }
429 401
430 void Display::OnWindowManagerWindowTreeFactoryReady( 402 void Display::OnWindowManagerWindowTreeFactoryReady(
431 WindowManagerWindowTreeFactory* factory) { 403 WindowManagerWindowTreeFactory* factory) {
432 if (!binding_) 404 if (!binding_)
433 CreateWindowManagerDisplayRootFromFactory(factory); 405 CreateWindowManagerDisplayRootFromFactory(factory);
434 } 406 }
435 407
436 } // namespace ws 408 } // namespace ws
437 } // namespace ui 409 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698