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

Side by Side Diff: services/ui/demo/mus_demo.cc

Issue 2755673003: Allow parallel creation of windows
Patch Set: nits Created 3 years, 9 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/demo/mus_demo.h ('k') | services/ui/demo/mus_demo_external.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/demo/mus_demo.h" 5 #include "services/ui/demo/mus_demo.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "services/service_manager/public/cpp/connector.h" 8 #include "services/service_manager/public/cpp/connector.h"
9 #include "services/ui/demo/window_tree_data.h" 9 #include "services/ui/demo/window_tree_data.h"
10 #include "services/ui/public/cpp/gpu/gpu.h" 10 #include "services/ui/public/cpp/gpu/gpu.h"
(...skipping 13 matching lines...) Expand all
24 24
25 MusDemo::~MusDemo() { 25 MusDemo::~MusDemo() {
26 display::Screen::SetScreenInstance(nullptr); 26 display::Screen::SetScreenInstance(nullptr);
27 } 27 }
28 28
29 void MusDemo::AddPrimaryDisplay(const display::Display& display) { 29 void MusDemo::AddPrimaryDisplay(const display::Display& display) {
30 screen_->display_list().AddDisplay(display, 30 screen_->display_list().AddDisplay(display,
31 display::DisplayList::Type::PRIMARY); 31 display::DisplayList::Type::PRIMARY);
32 } 32 }
33 33
34 bool MusDemo::HasPendingWindowTreeData() const {
35 return !window_tree_data_list_.empty() &&
36 !window_tree_data_list_.back()->IsInitialized();
37 }
38
39 void MusDemo::AppendWindowTreeData( 34 void MusDemo::AppendWindowTreeData(
40 std::unique_ptr<WindowTreeData> window_tree_data) { 35 std::unique_ptr<WindowTreeData> window_tree_data) {
41 DCHECK(!HasPendingWindowTreeData());
42 window_tree_data_list_.push_back(std::move(window_tree_data)); 36 window_tree_data_list_.push_back(std::move(window_tree_data));
43 } 37 }
44 38
45 void MusDemo::InitWindowTreeData(
46 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
47 DCHECK(HasPendingWindowTreeData());
48 window_tree_data_list_.back()->Init(std::move(window_tree_host));
49 }
50
51 void MusDemo::RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host) { 39 void MusDemo::RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host) {
52 DCHECK(window_tree_host); 40 DCHECK(window_tree_host);
41 auto window_tree_data = FindWindowTreeData(window_tree_host);
42 window_tree_data_list_.erase(window_tree_data);
43 }
44
45 std::vector<std::unique_ptr<WindowTreeData>>::iterator
46 MusDemo::FindWindowTreeData(aura::WindowTreeHostMus* window_tree_host) {
53 auto it = 47 auto it =
54 std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(), 48 std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(),
55 [window_tree_host](std::unique_ptr<WindowTreeData>& data) { 49 [window_tree_host](std::unique_ptr<WindowTreeData>& data) {
56 return data->WindowTreeHost() == window_tree_host; 50 return data->WindowTreeHost() == window_tree_host;
57 }); 51 });
58 DCHECK(it != window_tree_data_list_.end()); 52 DCHECK(it != window_tree_data_list_.end());
59 window_tree_data_list_.erase(it); 53 return it;
60 } 54 }
61 55
62 void MusDemo::OnStart() { 56 void MusDemo::OnStart() {
63 screen_ = base::MakeUnique<display::ScreenBase>(); 57 screen_ = base::MakeUnique<display::ScreenBase>();
64 display::Screen::SetScreenInstance(screen_.get()); 58 display::Screen::SetScreenInstance(screen_.get());
65 59
66 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); 60 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS);
67 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); 61 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>();
68 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); 62 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
69 wm_state_ = base::MakeUnique<::wm::WMState>(); 63 wm_state_ = base::MakeUnique<::wm::WMState>();
(...skipping 29 matching lines...) Expand all
99 93
100 void MusDemo::OnPointerEventObserved(const PointerEvent& event, 94 void MusDemo::OnPointerEventObserved(const PointerEvent& event,
101 aura::Window* target) {} 95 aura::Window* target) {}
102 96
103 aura::PropertyConverter* MusDemo::GetPropertyConverter() { 97 aura::PropertyConverter* MusDemo::GetPropertyConverter() {
104 return property_converter_.get(); 98 return property_converter_.get();
105 } 99 }
106 100
107 } // namespace demo 101 } // namespace demo
108 } // namespace ui 102 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/demo/mus_demo_external.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698