Chromium Code Reviews| 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/display/platform_screen_ozone.h" | 5 #include "services/ui/display/platform_screen_ozone.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 } else { | 57 } else { |
| 58 display_configurator_.AddVirtualDisplay(gfx::Size(1024, 768)); | 58 display_configurator_.AddVirtualDisplay(gfx::Size(1024, 768)); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 int64_t PlatformScreenOzone::GetPrimaryDisplayId() const { | 63 int64_t PlatformScreenOzone::GetPrimaryDisplayId() const { |
| 64 return primary_display_id_; | 64 return primary_display_id_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void PlatformScreenOzone::ToggleVirtualDisplay( | |
| 68 const ToggleVirtualDisplayCallback& callback) { | |
| 69 if (base::SysInfo::IsRunningOnChromeOS()) { | |
| 70 callback.Run(false); | |
| 71 return; | |
| 72 } | |
| 73 | |
| 74 if (cached_displays_.size() == 1) { | |
| 75 display_configurator_.AddVirtualDisplay(cached_displays_[0].bounds.size()); | |
| 76 callback.Run(true); | |
| 77 } else if (cached_displays_.size() > 1) { | |
| 78 callback.Run( | |
| 79 display_configurator_.RemoveVirtualDisplay(cached_displays_.back().id)); | |
| 80 } else { | |
| 81 NOTREACHED(); | |
| 82 callback.Run(false); | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 void PlatformScreenOzone::IncreaseResolution(int64_t display_id) { | |
| 87 // TODO(kylechar): Implement. | |
| 88 NOTIMPLEMENTED(); | |
|
dcheng
2016/09/08 21:02:57
Would it be possible to just merge the implementat
kylechar
2016/09/08 21:20:53
It's not possible to implement yet. Removed.
| |
| 89 } | |
| 90 | |
| 91 void PlatformScreenOzone::DecreaseResolution(int64_t display_id) { | |
| 92 // TODO(kylechar): Implement. | |
| 93 NOTIMPLEMENTED(); | |
| 94 } | |
| 95 | |
| 96 void PlatformScreenOzone::UseDefaultResolution(int64_t display_id) { | |
| 97 // TODO(kylechar): Implement. | |
| 98 NOTIMPLEMENTED(); | |
| 99 } | |
| 100 | |
| 67 void PlatformScreenOzone::ProcessRemovedDisplays( | 101 void PlatformScreenOzone::ProcessRemovedDisplays( |
| 68 const ui::DisplayConfigurator::DisplayStateList& snapshots) { | 102 const ui::DisplayConfigurator::DisplayStateList& snapshots) { |
| 69 std::vector<int64_t> current_ids; | 103 std::vector<int64_t> current_ids; |
| 70 for (ui::DisplaySnapshot* snapshot : snapshots) | 104 for (ui::DisplaySnapshot* snapshot : snapshots) |
| 71 current_ids.push_back(snapshot->display_id()); | 105 current_ids.push_back(snapshot->display_id()); |
| 72 | 106 |
| 73 // Find cached displays with no matching snapshot and mark as removed. | 107 // Find cached displays with no matching snapshot and mark as removed. |
| 74 for (DisplayInfo& display : cached_displays_) { | 108 for (DisplayInfo& display : cached_displays_) { |
| 75 if (std::find(current_ids.begin(), current_ids.end(), display.id) == | 109 if (std::find(current_ids.begin(), current_ids.end(), display.id) == |
| 76 current_ids.end()) { | 110 current_ids.end()) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 gfx::Rect bounds(next_display_origin_, current_mode->size()); | 182 gfx::Rect bounds(next_display_origin_, current_mode->size()); |
| 149 | 183 |
| 150 // Move the origin so that next display is to the right of current display. | 184 // Move the origin so that next display is to the right of current display. |
| 151 next_display_origin_.Offset(current_mode->size().width(), 0); | 185 next_display_origin_.Offset(current_mode->size().width(), 0); |
| 152 | 186 |
| 153 // If we have no primary display then this one should be it. | 187 // If we have no primary display then this one should be it. |
| 154 if (primary_display_id_ == display::Display::kInvalidDisplayID) | 188 if (primary_display_id_ == display::Display::kInvalidDisplayID) |
| 155 primary_display_id_ = id; | 189 primary_display_id_ = id; |
| 156 | 190 |
| 157 cached_displays_.push_back(DisplayInfo(id, bounds)); | 191 cached_displays_.push_back(DisplayInfo(id, bounds)); |
| 158 delegate_->OnDisplayAdded(this, id, bounds); | 192 delegate_->OnDisplayAdded(id, bounds); |
| 159 } | 193 } |
| 160 } | 194 } |
| 161 | 195 |
| 162 PlatformScreenOzone::CachedDisplayIterator | 196 PlatformScreenOzone::CachedDisplayIterator |
| 163 PlatformScreenOzone::GetCachedDisplayIterator(int64_t display_id) { | 197 PlatformScreenOzone::GetCachedDisplayIterator(int64_t display_id) { |
| 164 return std::find_if(cached_displays_.begin(), cached_displays_.end(), | 198 return std::find_if(cached_displays_.begin(), cached_displays_.end(), |
| 165 [display_id](const DisplayInfo& display_info) { | 199 [display_id](const DisplayInfo& display_info) { |
| 166 return display_info.id == display_id; | 200 return display_info.id == display_id; |
| 167 }); | 201 }); |
| 168 } | 202 } |
| 169 | 203 |
| 170 void PlatformScreenOzone::OnDisplayModeChanged( | 204 void PlatformScreenOzone::OnDisplayModeChanged( |
| 171 const ui::DisplayConfigurator::DisplayStateList& displays) { | 205 const ui::DisplayConfigurator::DisplayStateList& displays) { |
| 172 ProcessRemovedDisplays(displays); | 206 ProcessRemovedDisplays(displays); |
| 173 ProcessModifiedDisplays(displays); | 207 ProcessModifiedDisplays(displays); |
| 174 UpdateCachedDisplays(); | 208 UpdateCachedDisplays(); |
| 175 AddNewDisplays(displays); | 209 AddNewDisplays(displays); |
| 176 } | 210 } |
| 177 | 211 |
| 178 void PlatformScreenOzone::OnDisplayModeChangeFailed( | 212 void PlatformScreenOzone::OnDisplayModeChangeFailed( |
| 179 const ui::DisplayConfigurator::DisplayStateList& displays, | 213 const ui::DisplayConfigurator::DisplayStateList& displays, |
| 180 ui::MultipleDisplayState failed_new_state) { | 214 ui::MultipleDisplayState failed_new_state) { |
| 181 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; | 215 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; |
| 182 } | 216 } |
| 183 | 217 |
| 184 } // namespace display | 218 } // namespace display |
| OLD | NEW |