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

Side by Side Diff: ui/display/chromeos/output_configurator.cc

Issue 215233002: Update ui/display to use primitive types as defined in stdint.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/output_configurator.h" 5 #include "ui/display/chromeos/output_configurator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/sys_info.h" 11 #include "base/sys_info.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "ui/display/chromeos/display_mode.h" 13 #include "ui/display/chromeos/display_mode.h"
14 #include "ui/display/chromeos/display_snapshot.h" 14 #include "ui/display/chromeos/display_snapshot.h"
15 #include "ui/display/chromeos/x11/native_display_delegate_x11.h" 15 #include "ui/display/chromeos/x11/native_display_delegate_x11.h"
16 #include "ui/display/chromeos/x11/touchscreen_delegate_x11.h" 16 #include "ui/display/chromeos/x11/touchscreen_delegate_x11.h"
17 17
18 namespace ui { 18 namespace ui {
19 19
20 namespace { 20 namespace {
21 21
22 typedef std::vector<const DisplayMode*> DisplayModeList; 22 typedef std::vector<const DisplayMode*> DisplayModeList;
23 23
24 // The delay to perform configuration after RRNotify. See the comment 24 // The delay to perform configuration after RRNotify. See the comment
25 // in |Dispatch()|. 25 // in |Dispatch()|.
26 const int64 kConfigureDelayMs = 500; 26 const int kConfigureDelayMs = 500;
27 27
28 // Returns a string describing |state|. 28 // Returns a string describing |state|.
29 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) { 29 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) {
30 switch (state) { 30 switch (state) {
31 case chromeos::DISPLAY_POWER_ALL_ON: 31 case chromeos::DISPLAY_POWER_ALL_ON:
32 return "ALL_ON"; 32 return "ALL_ON";
33 case chromeos::DISPLAY_POWER_ALL_OFF: 33 case chromeos::DISPLAY_POWER_ALL_OFF:
34 return "ALL_OFF"; 34 return "ALL_OFF";
35 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON: 35 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON:
36 return "INTERNAL_OFF_EXTERNAL_ON"; 36 return "INTERNAL_OFF_EXTERNAL_ON";
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 if (!native_display_delegate_) { 191 if (!native_display_delegate_) {
192 native_display_delegate_.reset(new NativeDisplayDelegateX11()); 192 native_display_delegate_.reset(new NativeDisplayDelegateX11());
193 native_display_delegate_->AddObserver(this); 193 native_display_delegate_->AddObserver(this);
194 } 194 }
195 195
196 if (!touchscreen_delegate_) 196 if (!touchscreen_delegate_)
197 touchscreen_delegate_.reset(new TouchscreenDelegateX11()); 197 touchscreen_delegate_.reset(new TouchscreenDelegateX11());
198 } 198 }
199 199
200 void OutputConfigurator::ForceInitialConfigure(uint32 background_color_argb) { 200 void OutputConfigurator::ForceInitialConfigure(uint32_t background_color_argb) {
201 if (!configure_display_) 201 if (!configure_display_)
202 return; 202 return;
203 203
204 native_display_delegate_->GrabServer(); 204 native_display_delegate_->GrabServer();
205 native_display_delegate_->Initialize(); 205 native_display_delegate_->Initialize();
206 206
207 UpdateCachedOutputs(); 207 UpdateCachedOutputs();
208 if (cached_outputs_.size() > 1 && background_color_argb) 208 if (cached_outputs_.size() > 1 && background_color_argb)
209 native_display_delegate_->SetBackgroundColor(background_color_argb); 209 native_display_delegate_->SetBackgroundColor(background_color_argb);
210 const OutputState new_state = ChooseOutputState(power_state_); 210 const OutputState new_state = ChooseOutputState(power_state_);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 ++it2) { 278 ++it2) {
279 protections[it2->first] |= it2->second; 279 protections[it2->first] |= it2->second;
280 } 280 }
281 } 281 }
282 282
283 ApplyProtections(protections); 283 ApplyProtections(protections);
284 } 284 }
285 285
286 bool OutputConfigurator::QueryOutputProtectionStatus( 286 bool OutputConfigurator::QueryOutputProtectionStatus(
287 OutputProtectionClientId client_id, 287 OutputProtectionClientId client_id,
288 int64 display_id, 288 int64_t display_id,
289 uint32_t* link_mask, 289 uint32_t* link_mask,
290 uint32_t* protection_mask) { 290 uint32_t* protection_mask) {
291 if (!configure_display_) 291 if (!configure_display_)
292 return false; 292 return false;
293 293
294 uint32_t enabled = 0; 294 uint32_t enabled = 0;
295 uint32_t unfulfilled = 0; 295 uint32_t unfulfilled = 0;
296 *link_mask = 0; 296 *link_mask = 0;
297 for (DisplayStateList::const_iterator it = cached_outputs_.begin(); 297 for (DisplayStateList::const_iterator it = cached_outputs_.begin();
298 it != cached_outputs_.end(); 298 it != cached_outputs_.end();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 requested_mask = it->second[display_id]; 335 requested_mask = it->second[display_id];
336 *protection_mask = enabled & ~unfulfilled & requested_mask; 336 *protection_mask = enabled & ~unfulfilled & requested_mask;
337 } else { 337 } else {
338 *protection_mask = 0; 338 *protection_mask = 0;
339 } 339 }
340 return true; 340 return true;
341 } 341 }
342 342
343 bool OutputConfigurator::EnableOutputProtection( 343 bool OutputConfigurator::EnableOutputProtection(
344 OutputProtectionClientId client_id, 344 OutputProtectionClientId client_id,
345 int64 display_id, 345 int64_t display_id,
346 uint32_t desired_method_mask) { 346 uint32_t desired_method_mask) {
347 if (!configure_display_) 347 if (!configure_display_)
348 return false; 348 return false;
349 349
350 DisplayProtections protections; 350 DisplayProtections protections;
351 for (ProtectionRequests::const_iterator it = 351 for (ProtectionRequests::const_iterator it =
352 client_protection_requests_.begin(); 352 client_protection_requests_.begin();
353 it != client_protection_requests_.end(); 353 it != client_protection_requests_.end();
354 ++it) { 354 ++it) {
355 for (DisplayProtections::const_iterator it2 = it->second.begin(); 355 for (DisplayProtections::const_iterator it2 = it->second.begin();
(...skipping 18 matching lines...) Expand all
374 } 374 }
375 } else { 375 } else {
376 client_protection_requests_[client_id][display_id] = desired_method_mask; 376 client_protection_requests_[client_id][display_id] = desired_method_mask;
377 } 377 }
378 378
379 return true; 379 return true;
380 } 380 }
381 381
382 std::vector<ui::ColorCalibrationProfile> 382 std::vector<ui::ColorCalibrationProfile>
383 OutputConfigurator::GetAvailableColorCalibrationProfiles( 383 OutputConfigurator::GetAvailableColorCalibrationProfiles(
384 int64 display_id) { 384 int64_t display_id) {
385 for (size_t i = 0; i < cached_outputs_.size(); ++i) { 385 for (size_t i = 0; i < cached_outputs_.size(); ++i) {
386 if (cached_outputs_[i].display && 386 if (cached_outputs_[i].display &&
387 cached_outputs_[i].display->display_id() == display_id) { 387 cached_outputs_[i].display->display_id() == display_id) {
388 return native_display_delegate_->GetAvailableColorCalibrationProfiles( 388 return native_display_delegate_->GetAvailableColorCalibrationProfiles(
389 *cached_outputs_[i].display); 389 *cached_outputs_[i].display);
390 } 390 }
391 } 391 }
392 392
393 return std::vector<ui::ColorCalibrationProfile>(); 393 return std::vector<ui::ColorCalibrationProfile>();
394 } 394 }
395 395
396 bool OutputConfigurator::SetColorCalibrationProfile( 396 bool OutputConfigurator::SetColorCalibrationProfile(
397 int64 display_id, 397 int64_t display_id,
398 ui::ColorCalibrationProfile new_profile) { 398 ui::ColorCalibrationProfile new_profile) {
399 for (size_t i = 0; i < cached_outputs_.size(); ++i) { 399 for (size_t i = 0; i < cached_outputs_.size(); ++i) {
400 if (cached_outputs_[i].display && 400 if (cached_outputs_[i].display &&
401 cached_outputs_[i].display->display_id() == display_id) { 401 cached_outputs_[i].display->display_id() == display_id) {
402 return native_display_delegate_->SetColorCalibrationProfile( 402 return native_display_delegate_->SetColorCalibrationProfile(
403 *cached_outputs_[i].display, new_profile); 403 *cached_outputs_[i].display, new_profile);
404 } 404 }
405 } 405 }
406 406
407 return false; 407 return false;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 case 2: { 909 case 2: {
910 if (num_on_outputs == 1) { 910 if (num_on_outputs == 1) {
911 // If only one output is currently turned on, return the "single" 911 // If only one output is currently turned on, return the "single"
912 // state so that its native mode will be used. 912 // state so that its native mode will be used.
913 return OUTPUT_STATE_SINGLE; 913 return OUTPUT_STATE_SINGLE;
914 } else { 914 } else {
915 if (!state_controller_) 915 if (!state_controller_)
916 return OUTPUT_STATE_DUAL_EXTENDED; 916 return OUTPUT_STATE_DUAL_EXTENDED;
917 // With either both outputs on or both outputs off, use one of the 917 // With either both outputs on or both outputs off, use one of the
918 // dual modes. 918 // dual modes.
919 std::vector<int64> display_ids; 919 std::vector<int64_t> display_ids;
920 for (size_t i = 0; i < cached_outputs_.size(); ++i) { 920 for (size_t i = 0; i < cached_outputs_.size(); ++i) {
921 // If display id isn't available, switch to extended mode. 921 // If display id isn't available, switch to extended mode.
922 if (!cached_outputs_[i].display->has_proper_display_id()) 922 if (!cached_outputs_[i].display->has_proper_display_id())
923 return OUTPUT_STATE_DUAL_EXTENDED; 923 return OUTPUT_STATE_DUAL_EXTENDED;
924 display_ids.push_back(cached_outputs_[i].display->display_id()); 924 display_ids.push_back(cached_outputs_[i].display->display_id());
925 } 925 }
926 return state_controller_->GetStateForDisplayIds(display_ids); 926 return state_controller_->GetStateForDisplayIds(display_ids);
927 } 927 }
928 } 928 }
929 default: 929 default:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 float width_ratio = static_cast<float>(mirror_mode_info->size().width()) / 1024 float width_ratio = static_cast<float>(mirror_mode_info->size().width()) /
1025 static_cast<float>(native_mode_info->size().width()); 1025 static_cast<float>(native_mode_info->size().width());
1026 float height_ratio = static_cast<float>(mirror_mode_info->size().height()) / 1026 float height_ratio = static_cast<float>(mirror_mode_info->size().height()) /
1027 static_cast<float>(native_mode_info->size().height()); 1027 static_cast<float>(native_mode_info->size().height());
1028 1028
1029 area_ratio = width_ratio * height_ratio; 1029 area_ratio = width_ratio * height_ratio;
1030 return area_ratio; 1030 return area_ratio;
1031 } 1031 }
1032 1032
1033 } // namespace ui 1033 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/output_configurator.h ('k') | ui/display/chromeos/output_configurator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698