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

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

Issue 788423002: Add display task to trigger display configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-refactor3
Patch Set: . Created 6 years 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 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/display_configurator.h" 5 #include "ui/display/chromeos/display_configurator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/sys_info.h" 10 #include "base/sys_info.h"
13 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/display/chromeos/display_util.h"
14 #include "ui/display/display_switches.h" 13 #include "ui/display/display_switches.h"
15 #include "ui/display/types/display_mode.h" 14 #include "ui/display/types/display_mode.h"
16 #include "ui/display/types/display_snapshot.h" 15 #include "ui/display/types/display_snapshot.h"
17 #include "ui/display/types/native_display_delegate.h" 16 #include "ui/display/types/native_display_delegate.h"
18 17
19 namespace ui { 18 namespace ui {
20 19
21 namespace { 20 namespace {
22 21
23 typedef std::vector<const DisplayMode*> DisplayModeList; 22 typedef std::vector<const DisplayMode*> DisplayModeList;
24 23
25 // The delay to perform configuration after RRNotify. See the comment for 24 // The delay to perform configuration after RRNotify. See the comment for
26 // |configure_timer_|. 25 // |configure_timer_|.
27 const int kConfigureDelayMs = 500; 26 const int kConfigureDelayMs = 500;
28 27
29 // The delay spent before reading the display configuration after coming out of 28 // The delay spent before reading the display configuration after coming out of
30 // suspend. While coming out of suspend the display state may be updating. This 29 // suspend. While coming out of suspend the display state may be updating. This
31 // is used to wait until the hardware had a chance to update the display state 30 // is used to wait until the hardware had a chance to update the display state
32 // such that we read an up to date state. 31 // such that we read an up to date state.
33 const int kResumeDelayMs = 500; 32 const int kResumeDelayMs = 500;
34 33
35 // Returns a string describing |state|.
36 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) {
37 switch (state) {
38 case chromeos::DISPLAY_POWER_ALL_ON:
39 return "ALL_ON";
40 case chromeos::DISPLAY_POWER_ALL_OFF:
41 return "ALL_OFF";
42 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON:
43 return "INTERNAL_OFF_EXTERNAL_ON";
44 case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF:
45 return "INTERNAL_ON_EXTERNAL_OFF";
46 default:
47 return "unknown (" + base::IntToString(state) + ")";
48 }
49 }
50
51 // Returns a string describing |state|.
52 std::string DisplayStateToString(MultipleDisplayState state) {
53 switch (state) {
54 case MULTIPLE_DISPLAY_STATE_INVALID:
55 return "INVALID";
56 case MULTIPLE_DISPLAY_STATE_HEADLESS:
57 return "HEADLESS";
58 case MULTIPLE_DISPLAY_STATE_SINGLE:
59 return "SINGLE";
60 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR:
61 return "DUAL_MIRROR";
62 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED:
63 return "DUAL_EXTENDED";
64 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED:
65 return "MULTI_EXTENDED";
66 }
67 NOTREACHED() << "Unknown state " << state;
68 return "INVALID";
69 }
70
71 // Returns the number of displays in |displays| that should be turned on, per
72 // |state|. If |display_power| is non-NULL, it is updated to contain the
73 // on/off state of each corresponding entry in |displays|.
74 int GetDisplayPower(
75 const std::vector<DisplayConfigurator::DisplayState>& display_states,
76 chromeos::DisplayPowerState state,
77 std::vector<bool>* display_power) {
78 int num_on_displays = 0;
79 if (display_power)
80 display_power->resize(display_states.size());
81
82 for (size_t i = 0; i < display_states.size(); ++i) {
83 bool internal =
84 display_states[i].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL;
85 bool on =
86 state == chromeos::DISPLAY_POWER_ALL_ON ||
87 (state == chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON &&
88 !internal) ||
89 (state == chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal);
90 if (display_power)
91 (*display_power)[i] = on;
92 if (on)
93 num_on_displays++;
94 }
95 return num_on_displays;
96 }
97
98 } // namespace 34 } // namespace
99 35
100 36
101 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0; 37 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0;
102 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0; 38 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0;
103 const int 39 const int
104 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; 40 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1;
105 41
106 DisplayConfigurator::DisplayState::DisplayState() 42 DisplayConfigurator::DisplayState::DisplayState()
107 : display(NULL), 43 : display(NULL),
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 943
1008 return state_controller_->GetStateForDisplayIds(display_ids); 944 return state_controller_->GetStateForDisplayIds(display_ids);
1009 } 945 }
1010 NOTREACHED(); 946 NOTREACHED();
1011 } 947 }
1012 } 948 }
1013 return MULTIPLE_DISPLAY_STATE_INVALID; 949 return MULTIPLE_DISPLAY_STATE_INVALID;
1014 } 950 }
1015 951
1016 } // namespace ui 952 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698