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

Side by Side Diff: ui/display/fake_display_delegate.cc

Issue 2613493002: Fix namespace for src/ui/display/. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 | « ui/display/fake_display_delegate.h ('k') | ui/display/fake_display_snapshot.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 "ui/display/fake_display_delegate.h" 5 #include "ui/display/fake_display_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 int64_t id = GenerateDisplayID(kReservedManufacturerID, kProductCodeHash, 50 int64_t id = GenerateDisplayID(kReservedManufacturerID, kProductCodeHash,
51 ++next_display_id_); 51 ++next_display_id_);
52 52
53 FakeDisplaySnapshot::Builder builder; 53 FakeDisplaySnapshot::Builder builder;
54 builder.SetId(id).SetNativeMode(display_size); 54 builder.SetId(id).SetNativeMode(display_size);
55 55
56 return AddDisplay(builder.Build()) ? id : kInvalidDisplayId; 56 return AddDisplay(builder.Build()) ? id : kInvalidDisplayId;
57 } 57 }
58 58
59 bool FakeDisplayDelegate::AddDisplay( 59 bool FakeDisplayDelegate::AddDisplay(std::unique_ptr<DisplaySnapshot> display) {
60 std::unique_ptr<ui::DisplaySnapshot> display) {
61 DCHECK(display); 60 DCHECK(display);
62 61
63 int64_t display_id = display->display_id(); 62 int64_t display_id = display->display_id();
64 // Check there is no existing display with the same id. 63 // Check there is no existing display with the same id.
65 for (auto& existing_display : displays_) { 64 for (auto& existing_display : displays_) {
66 if (existing_display->display_id() == display_id) { 65 if (existing_display->display_id() == display_id) {
67 LOG(ERROR) << "Display with id " << display_id << " already exists"; 66 LOG(ERROR) << "Display with id " << display_id << " already exists";
68 return false; 67 return false;
69 } 68 }
70 } 69 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 106 }
108 107
109 initialized_ = true; 108 initialized_ = true;
110 } 109 }
111 110
112 void FakeDisplayDelegate::GrabServer() {} 111 void FakeDisplayDelegate::GrabServer() {}
113 112
114 void FakeDisplayDelegate::UngrabServer() {} 113 void FakeDisplayDelegate::UngrabServer() {}
115 114
116 void FakeDisplayDelegate::TakeDisplayControl( 115 void FakeDisplayDelegate::TakeDisplayControl(
117 const ui::DisplayControlCallback& callback) { 116 const DisplayControlCallback& callback) {
118 callback.Run(false); 117 callback.Run(false);
119 } 118 }
120 119
121 void FakeDisplayDelegate::RelinquishDisplayControl( 120 void FakeDisplayDelegate::RelinquishDisplayControl(
122 const ui::DisplayControlCallback& callback) { 121 const DisplayControlCallback& callback) {
123 callback.Run(false); 122 callback.Run(false);
124 } 123 }
125 124
126 void FakeDisplayDelegate::SyncWithServer() {} 125 void FakeDisplayDelegate::SyncWithServer() {}
127 126
128 void FakeDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {} 127 void FakeDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {}
129 128
130 void FakeDisplayDelegate::ForceDPMSOn() {} 129 void FakeDisplayDelegate::ForceDPMSOn() {}
131 130
132 void FakeDisplayDelegate::GetDisplays(const ui::GetDisplaysCallback& callback) { 131 void FakeDisplayDelegate::GetDisplays(const GetDisplaysCallback& callback) {
133 std::vector<ui::DisplaySnapshot*> displays; 132 std::vector<DisplaySnapshot*> displays;
134 for (auto& display : displays_) 133 for (auto& display : displays_)
135 displays.push_back(display.get()); 134 displays.push_back(display.get());
136 callback.Run(displays); 135 callback.Run(displays);
137 } 136 }
138 137
139 void FakeDisplayDelegate::AddMode(const ui::DisplaySnapshot& output, 138 void FakeDisplayDelegate::AddMode(const DisplaySnapshot& output,
140 const ui::DisplayMode* mode) {} 139 const DisplayMode* mode) {}
141 140
142 void FakeDisplayDelegate::Configure(const ui::DisplaySnapshot& output, 141 void FakeDisplayDelegate::Configure(const DisplaySnapshot& output,
143 const ui::DisplayMode* mode, 142 const DisplayMode* mode,
144 const gfx::Point& origin, 143 const gfx::Point& origin,
145 const ui::ConfigureCallback& callback) { 144 const ConfigureCallback& callback) {
146 bool configure_success = false; 145 bool configure_success = false;
147 146
148 if (!mode) { 147 if (!mode) {
149 // This is a request to turn off the display. 148 // This is a request to turn off the display.
150 configure_success = true; 149 configure_success = true;
151 } else { 150 } else {
152 // Check that |mode| is appropriate for the display snapshot. 151 // Check that |mode| is appropriate for the display snapshot.
153 for (const auto& existing_mode : output.modes()) { 152 for (const auto& existing_mode : output.modes()) {
154 if (existing_mode.get() == mode) { 153 if (existing_mode.get() == mode) {
155 configure_success = true; 154 configure_success = true;
156 break; 155 break;
157 } 156 }
158 } 157 }
159 } 158 }
160 159
161 configure_callbacks_.push(base::Bind(callback, configure_success)); 160 configure_callbacks_.push(base::Bind(callback, configure_success));
162 161
163 // Start the timer if it's not already running. If there are multiple queued 162 // Start the timer if it's not already running. If there are multiple queued
164 // configuration requests then ConfigureDone() will handle starting the 163 // configuration requests then ConfigureDone() will handle starting the
165 // next request. 164 // next request.
166 if (!configure_timer_.IsRunning()) { 165 if (!configure_timer_.IsRunning()) {
167 configure_timer_.Start( 166 configure_timer_.Start(
168 FROM_HERE, base::TimeDelta::FromMilliseconds(kConfigureDisplayDelayMs), 167 FROM_HERE, base::TimeDelta::FromMilliseconds(kConfigureDisplayDelayMs),
169 this, &FakeDisplayDelegate::ConfigureDone); 168 this, &FakeDisplayDelegate::ConfigureDone);
170 } 169 }
171 } 170 }
172 171
173 void FakeDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {} 172 void FakeDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {}
174 173
175 void FakeDisplayDelegate::GetHDCPState( 174 void FakeDisplayDelegate::GetHDCPState(const DisplaySnapshot& output,
176 const ui::DisplaySnapshot& output, 175 const GetHDCPStateCallback& callback) {
177 const ui::GetHDCPStateCallback& callback) { 176 callback.Run(false, HDCP_STATE_UNDESIRED);
178 callback.Run(false, ui::HDCP_STATE_UNDESIRED);
179 } 177 }
180 178
181 void FakeDisplayDelegate::SetHDCPState( 179 void FakeDisplayDelegate::SetHDCPState(const DisplaySnapshot& output,
182 const ui::DisplaySnapshot& output, 180 HDCPState state,
183 ui::HDCPState state, 181 const SetHDCPStateCallback& callback) {
184 const ui::SetHDCPStateCallback& callback) {
185 callback.Run(false); 182 callback.Run(false);
186 } 183 }
187 184
188 std::vector<ui::ColorCalibrationProfile> 185 std::vector<ColorCalibrationProfile>
189 FakeDisplayDelegate::GetAvailableColorCalibrationProfiles( 186 FakeDisplayDelegate::GetAvailableColorCalibrationProfiles(
190 const ui::DisplaySnapshot& output) { 187 const DisplaySnapshot& output) {
191 return std::vector<ui::ColorCalibrationProfile>(); 188 return std::vector<ColorCalibrationProfile>();
192 } 189 }
193 190
194 bool FakeDisplayDelegate::SetColorCalibrationProfile( 191 bool FakeDisplayDelegate::SetColorCalibrationProfile(
195 const ui::DisplaySnapshot& output, 192 const DisplaySnapshot& output,
196 ui::ColorCalibrationProfile new_profile) { 193 ColorCalibrationProfile new_profile) {
197 return false; 194 return false;
198 } 195 }
199 196
200 bool FakeDisplayDelegate::SetColorCorrection( 197 bool FakeDisplayDelegate::SetColorCorrection(
201 const ui::DisplaySnapshot& output, 198 const DisplaySnapshot& output,
202 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, 199 const std::vector<GammaRampRGBEntry>& degamma_lut,
203 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, 200 const std::vector<GammaRampRGBEntry>& gamma_lut,
204 const std::vector<float>& correction_matrix) { 201 const std::vector<float>& correction_matrix) {
205 return false; 202 return false;
206 } 203 }
207 204
208 void FakeDisplayDelegate::AddObserver(ui::NativeDisplayObserver* observer) { 205 void FakeDisplayDelegate::AddObserver(NativeDisplayObserver* observer) {
209 observers_.AddObserver(observer); 206 observers_.AddObserver(observer);
210 } 207 }
211 208
212 void FakeDisplayDelegate::RemoveObserver(ui::NativeDisplayObserver* observer) { 209 void FakeDisplayDelegate::RemoveObserver(NativeDisplayObserver* observer) {
213 observers_.RemoveObserver(observer); 210 observers_.RemoveObserver(observer);
214 } 211 }
215 212
216 FakeDisplayController* FakeDisplayDelegate::GetFakeDisplayController() { 213 FakeDisplayController* FakeDisplayDelegate::GetFakeDisplayController() {
217 return this; 214 return this;
218 } 215 }
219 216
220 bool FakeDisplayDelegate::InitializeFromSpecString(const std::string& str) { 217 bool FakeDisplayDelegate::InitializeFromSpecString(const std::string& str) {
221 // Start without any displays. 218 // Start without any displays.
222 if (str == "none") 219 if (str == "none")
223 return true; 220 return true;
224 221
225 // Split on commas and parse each display string. 222 // Split on commas and parse each display string.
226 for (const std::string& part : base::SplitString( 223 for (const std::string& part : base::SplitString(
227 str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { 224 str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
228 int64_t id = GenerateDisplayID(kReservedManufacturerID, kProductCodeHash, 225 int64_t id = GenerateDisplayID(kReservedManufacturerID, kProductCodeHash,
229 next_display_id_); 226 next_display_id_);
230 std::unique_ptr<ui::DisplaySnapshot> snapshot = 227 std::unique_ptr<DisplaySnapshot> snapshot =
231 FakeDisplaySnapshot::CreateFromSpec(id, part); 228 FakeDisplaySnapshot::CreateFromSpec(id, part);
232 if (snapshot) { 229 if (snapshot) {
233 AddDisplay(std::move(snapshot)); 230 AddDisplay(std::move(snapshot));
234 next_display_id_++; 231 next_display_id_++;
235 } else { 232 } else {
236 LOG(ERROR) << "Failed to parse display \"" << part << "\""; 233 LOG(ERROR) << "Failed to parse display \"" << part << "\"";
237 return false; 234 return false;
238 } 235 }
239 } 236 }
240 237
241 return true; 238 return true;
242 } 239 }
243 240
244 void FakeDisplayDelegate::OnConfigurationChanged() { 241 void FakeDisplayDelegate::OnConfigurationChanged() {
245 if (!initialized_) 242 if (!initialized_)
246 return; 243 return;
247 244
248 for (ui::NativeDisplayObserver& observer : observers_) 245 for (NativeDisplayObserver& observer : observers_)
249 observer.OnConfigurationChanged(); 246 observer.OnConfigurationChanged();
250 } 247 }
251 248
252 void FakeDisplayDelegate::ConfigureDone() { 249 void FakeDisplayDelegate::ConfigureDone() {
253 DCHECK(!configure_callbacks_.empty()); 250 DCHECK(!configure_callbacks_.empty());
254 configure_callbacks_.front().Run(); 251 configure_callbacks_.front().Run();
255 configure_callbacks_.pop(); 252 configure_callbacks_.pop();
256 253
257 // If there are more configuration requests waiting then restart the timer. 254 // If there are more configuration requests waiting then restart the timer.
258 if (!configure_callbacks_.empty()) { 255 if (!configure_callbacks_.empty()) {
259 configure_timer_.Start( 256 configure_timer_.Start(
260 FROM_HERE, base::TimeDelta::FromMilliseconds(kConfigureDisplayDelayMs), 257 FROM_HERE, base::TimeDelta::FromMilliseconds(kConfigureDisplayDelayMs),
261 this, &FakeDisplayDelegate::ConfigureDone); 258 this, &FakeDisplayDelegate::ConfigureDone);
262 } 259 }
263 } 260 }
264 261
265 } // namespace display 262 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/fake_display_delegate.h ('k') | ui/display/fake_display_snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698