OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 display::DisplayList::Type::PRIMARY); | 31 display::DisplayList::Type::PRIMARY); |
32 } | 32 } |
33 | 33 |
34 bool MusDemo::HasPendingWindowTreeData() const { | 34 bool MusDemo::HasPendingWindowTreeData() const { |
35 return !window_tree_data_list_.empty() && | 35 return !window_tree_data_list_.empty() && |
36 !window_tree_data_list_.back()->IsInitialized(); | 36 !window_tree_data_list_.back()->IsInitialized(); |
37 } | 37 } |
38 | 38 |
39 void MusDemo::AppendWindowTreeData( | 39 void MusDemo::AppendWindowTreeData( |
40 std::unique_ptr<WindowTreeData> window_tree_data) { | 40 std::unique_ptr<WindowTreeData> window_tree_data) { |
41 DCHECK(!HasPendingWindowTreeData()); | |
42 window_tree_data_list_.push_back(std::move(window_tree_data)); | 41 window_tree_data_list_.push_back(std::move(window_tree_data)); |
43 } | 42 } |
44 | 43 |
45 void MusDemo::InitWindowTreeData( | 44 void MusDemo::InitWindowTreeData( |
46 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 45 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
47 DCHECK(HasPendingWindowTreeData()); | 46 DCHECK(HasPendingWindowTreeData()); |
48 window_tree_data_list_.back()->Init(std::move(window_tree_host)); | 47 window_tree_data_list_.back()->Init(std::move(window_tree_host)); |
49 } | 48 } |
50 | 49 |
| 50 void MusDemo::InitWindowTreeDataExternal( |
| 51 aura::WindowTreeHostMus* window_tree_host) { |
| 52 DCHECK(HasPendingWindowTreeData()); |
| 53 auto window_tree_data = FindWindowTreeData(window_tree_host); |
| 54 (*window_tree_data)->Init(nullptr); |
| 55 } |
| 56 |
51 void MusDemo::RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host) { | 57 void MusDemo::RemoveWindowTreeData(aura::WindowTreeHostMus* window_tree_host) { |
52 DCHECK(window_tree_host); | 58 DCHECK(window_tree_host); |
| 59 auto window_tree_data = FindWindowTreeData(window_tree_host); |
| 60 window_tree_data_list_.erase(window_tree_data); |
| 61 } |
| 62 |
| 63 std::vector<std::unique_ptr<WindowTreeData>>::iterator |
| 64 MusDemo::FindWindowTreeData(aura::WindowTreeHostMus* window_tree_host) { |
53 auto it = | 65 auto it = |
54 std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(), | 66 std::find_if(window_tree_data_list_.begin(), window_tree_data_list_.end(), |
55 [window_tree_host](std::unique_ptr<WindowTreeData>& data) { | 67 [window_tree_host](std::unique_ptr<WindowTreeData>& data) { |
56 return data->WindowTreeHost() == window_tree_host; | 68 return data->WindowTreeHost() == window_tree_host; |
57 }); | 69 }); |
58 DCHECK(it != window_tree_data_list_.end()); | 70 DCHECK(it != window_tree_data_list_.end()); |
59 window_tree_data_list_.erase(it); | 71 return it; |
60 } | 72 } |
61 | 73 |
62 void MusDemo::OnStart() { | 74 void MusDemo::OnStart() { |
63 screen_ = base::MakeUnique<display::ScreenBase>(); | 75 screen_ = base::MakeUnique<display::ScreenBase>(); |
64 display::Screen::SetScreenInstance(screen_.get()); | 76 display::Screen::SetScreenInstance(screen_.get()); |
65 | 77 |
66 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); | 78 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); |
67 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); | 79 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); |
68 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); | 80 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); |
69 wm_state_ = base::MakeUnique<::wm::WMState>(); | 81 wm_state_ = base::MakeUnique<::wm::WMState>(); |
(...skipping 29 matching lines...) Expand all Loading... |
99 | 111 |
100 void MusDemo::OnPointerEventObserved(const PointerEvent& event, | 112 void MusDemo::OnPointerEventObserved(const PointerEvent& event, |
101 aura::Window* target) {} | 113 aura::Window* target) {} |
102 | 114 |
103 aura::PropertyConverter* MusDemo::GetPropertyConverter() { | 115 aura::PropertyConverter* MusDemo::GetPropertyConverter() { |
104 return property_converter_.get(); | 116 return property_converter_.get(); |
105 } | 117 } |
106 | 118 |
107 } // namespace demo | 119 } // namespace demo |
108 } // namespace ui | 120 } // namespace ui |
OLD | NEW |