OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/display/screen_manager_forwarding.h" | 5 #include "services/ui/display/screen_manager_forwarding.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "services/service_manager/public/cpp/binder_registry.h" | 10 #include "services/service_manager/public/cpp/binder_registry.h" |
| 11 #include "ui/display/screen_base.h" |
11 #include "ui/display/types/display_constants.h" | 12 #include "ui/display/types/display_constants.h" |
12 #include "ui/display/types/display_snapshot_mojo.h" | 13 #include "ui/display/types/display_snapshot_mojo.h" |
13 #include "ui/display/types/native_display_delegate.h" | 14 #include "ui/display/types/native_display_delegate.h" |
14 #include "ui/ozone/public/ozone_platform.h" | 15 #include "ui/ozone/public/ozone_platform.h" |
15 | 16 |
16 namespace display { | 17 namespace display { |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Finds the display mode in |snapshot| that corresponds to |mode_to_find|. | 20 // Finds the display mode in |snapshot| that corresponds to |mode_to_find|. |
20 const DisplayMode* GetCorrespondingMode(const DisplaySnapshot& snapshot, | 21 const DisplayMode* GetCorrespondingMode(const DisplaySnapshot& snapshot, |
21 const DisplayMode* mode_to_find) { | 22 const DisplayMode* mode_to_find) { |
22 if (!mode_to_find) | 23 if (!mode_to_find) |
23 return nullptr; | 24 return nullptr; |
24 | 25 |
25 for (auto& mode : snapshot.modes()) { | 26 for (auto& mode : snapshot.modes()) { |
26 if (mode->size() == mode_to_find->size() && | 27 if (mode->size() == mode_to_find->size() && |
27 mode->is_interlaced() == mode_to_find->is_interlaced() && | 28 mode->is_interlaced() == mode_to_find->is_interlaced() && |
28 mode->refresh_rate() == mode_to_find->refresh_rate()) { | 29 mode->refresh_rate() == mode_to_find->refresh_rate()) { |
29 return mode.get(); | 30 return mode.get(); |
30 } | 31 } |
31 } | 32 } |
32 NOTREACHED(); | 33 NOTREACHED(); |
33 return nullptr; | 34 return nullptr; |
34 } | 35 } |
35 | 36 |
36 } // namespace | 37 } // namespace |
37 | 38 |
38 // TODO(sky/kylechar): Change ScreenManager::Create() to make a | 39 ScreenManagerForwarding::ScreenManagerForwarding() |
39 // ScreenManagerForwarding in mus mode. | 40 : screen_(base::MakeUnique<display::ScreenBase>()), binding_(this) {} |
40 | |
41 ScreenManagerForwarding::ScreenManagerForwarding() : binding_(this) {} | |
42 | 41 |
43 ScreenManagerForwarding::~ScreenManagerForwarding() { | 42 ScreenManagerForwarding::~ScreenManagerForwarding() { |
44 if (native_display_delegate_) | 43 if (native_display_delegate_) |
45 native_display_delegate_->RemoveObserver(this); | 44 native_display_delegate_->RemoveObserver(this); |
46 } | 45 } |
47 | 46 |
48 void ScreenManagerForwarding::AddInterfaces( | 47 void ScreenManagerForwarding::AddInterfaces( |
49 service_manager::BinderRegistry* registry) { | 48 service_manager::BinderRegistry* registry) { |
50 registry->AddInterface<mojom::NativeDisplayDelegate>(this); | 49 registry->AddInterface<mojom::NativeDisplayDelegate>(this); |
51 } | 50 } |
52 | 51 |
53 void ScreenManagerForwarding::Init(ScreenManagerDelegate* delegate) { | 52 void ScreenManagerForwarding::Init(ScreenManagerDelegate* delegate) { |
54 // Done in NativeDisplayDelegate::Initialize() instead. | 53 // Done in NativeDisplayDelegate::Initialize() instead. |
55 } | 54 } |
56 | 55 |
57 void ScreenManagerForwarding::RequestCloseDisplay(int64_t display_id) {} | 56 void ScreenManagerForwarding::RequestCloseDisplay(int64_t display_id) {} |
58 | 57 |
| 58 display::ScreenBase* ScreenManagerForwarding::GetScreen() { |
| 59 return screen_.get(); |
| 60 } |
| 61 |
59 void ScreenManagerForwarding::OnConfigurationChanged() { | 62 void ScreenManagerForwarding::OnConfigurationChanged() { |
60 if (observer_.is_bound()) | 63 if (observer_.is_bound()) |
61 observer_->OnConfigurationChanged(); | 64 observer_->OnConfigurationChanged(); |
62 } | 65 } |
63 | 66 |
64 void ScreenManagerForwarding::OnDisplaySnapshotsInvalidated() { | 67 void ScreenManagerForwarding::OnDisplaySnapshotsInvalidated() { |
65 snapshot_map_.clear(); | 68 snapshot_map_.clear(); |
66 } | 69 } |
67 | 70 |
68 void ScreenManagerForwarding::Initialize( | 71 void ScreenManagerForwarding::Initialize( |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (status) { | 194 if (status) { |
192 // Modify display snapshot similar to how ConfigureDisplaysTask would. Ozone | 195 // Modify display snapshot similar to how ConfigureDisplaysTask would. Ozone |
193 // DRM needs these to be changed and ConfigureDisplaysTasks can't do it. | 196 // DRM needs these to be changed and ConfigureDisplaysTasks can't do it. |
194 snapshot->set_current_mode(mode); | 197 snapshot->set_current_mode(mode); |
195 snapshot->set_origin(origin); | 198 snapshot->set_origin(origin); |
196 } | 199 } |
197 callback.Run(status); | 200 callback.Run(status); |
198 } | 201 } |
199 | 202 |
200 } // namespace display | 203 } // namespace display |
OLD | NEW |