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

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

Issue 2310133002: Add mojom::DisplayController. (Closed)
Patch Set: Remove acclerator. Created 4 years, 3 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
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/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
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.
sky 2016/09/08 18:03:35 Use NOTIMPLEMENTED on all of these.
kylechar 2016/09/08 18:12:03 Done.
88 }
89
90 void PlatformScreenOzone::DecreaseResolution(int64_t display_id) {
91 // TODO(kylechar): Implement.
92 }
93
94 void PlatformScreenOzone::UseDefaultResolution(int64_t display_id) {
95 // TODO(kylechar): Implement.
96 }
97
67 void PlatformScreenOzone::ProcessRemovedDisplays( 98 void PlatformScreenOzone::ProcessRemovedDisplays(
68 const ui::DisplayConfigurator::DisplayStateList& snapshots) { 99 const ui::DisplayConfigurator::DisplayStateList& snapshots) {
69 std::vector<int64_t> current_ids; 100 std::vector<int64_t> current_ids;
70 for (ui::DisplaySnapshot* snapshot : snapshots) 101 for (ui::DisplaySnapshot* snapshot : snapshots)
71 current_ids.push_back(snapshot->display_id()); 102 current_ids.push_back(snapshot->display_id());
72 103
73 // Find cached displays with no matching snapshot and mark as removed. 104 // Find cached displays with no matching snapshot and mark as removed.
74 for (DisplayInfo& display : cached_displays_) { 105 for (DisplayInfo& display : cached_displays_) {
75 if (std::find(current_ids.begin(), current_ids.end(), display.id) == 106 if (std::find(current_ids.begin(), current_ids.end(), display.id) ==
76 current_ids.end()) { 107 current_ids.end()) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 gfx::Rect bounds(next_display_origin_, current_mode->size()); 179 gfx::Rect bounds(next_display_origin_, current_mode->size());
149 180
150 // Move the origin so that next display is to the right of current display. 181 // Move the origin so that next display is to the right of current display.
151 next_display_origin_.Offset(current_mode->size().width(), 0); 182 next_display_origin_.Offset(current_mode->size().width(), 0);
152 183
153 // If we have no primary display then this one should be it. 184 // If we have no primary display then this one should be it.
154 if (primary_display_id_ == display::Display::kInvalidDisplayID) 185 if (primary_display_id_ == display::Display::kInvalidDisplayID)
155 primary_display_id_ = id; 186 primary_display_id_ = id;
156 187
157 cached_displays_.push_back(DisplayInfo(id, bounds)); 188 cached_displays_.push_back(DisplayInfo(id, bounds));
158 delegate_->OnDisplayAdded(this, id, bounds); 189 delegate_->OnDisplayAdded(id, bounds);
159 } 190 }
160 } 191 }
161 192
162 PlatformScreenOzone::CachedDisplayIterator 193 PlatformScreenOzone::CachedDisplayIterator
163 PlatformScreenOzone::GetCachedDisplayIterator(int64_t display_id) { 194 PlatformScreenOzone::GetCachedDisplayIterator(int64_t display_id) {
164 return std::find_if(cached_displays_.begin(), cached_displays_.end(), 195 return std::find_if(cached_displays_.begin(), cached_displays_.end(),
165 [display_id](const DisplayInfo& display_info) { 196 [display_id](const DisplayInfo& display_info) {
166 return display_info.id == display_id; 197 return display_info.id == display_id;
167 }); 198 });
168 } 199 }
169 200
170 void PlatformScreenOzone::OnDisplayModeChanged( 201 void PlatformScreenOzone::OnDisplayModeChanged(
171 const ui::DisplayConfigurator::DisplayStateList& displays) { 202 const ui::DisplayConfigurator::DisplayStateList& displays) {
172 ProcessRemovedDisplays(displays); 203 ProcessRemovedDisplays(displays);
173 ProcessModifiedDisplays(displays); 204 ProcessModifiedDisplays(displays);
174 UpdateCachedDisplays(); 205 UpdateCachedDisplays();
175 AddNewDisplays(displays); 206 AddNewDisplays(displays);
176 } 207 }
177 208
178 void PlatformScreenOzone::OnDisplayModeChangeFailed( 209 void PlatformScreenOzone::OnDisplayModeChangeFailed(
179 const ui::DisplayConfigurator::DisplayStateList& displays, 210 const ui::DisplayConfigurator::DisplayStateList& displays,
180 ui::MultipleDisplayState failed_new_state) { 211 ui::MultipleDisplayState failed_new_state) {
181 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; 212 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator";
182 } 213 }
183 214
184 } // namespace display 215 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698