OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/display/chromeos/display_util.h" | |
6 | |
7 #include "base/strings/string_number_conversions.h" | |
8 #include "base/strings/stringprintf.h" | |
9 #include "ui/display/types/display_snapshot.h" | |
10 | |
11 namespace ui { | |
12 | |
13 // Returns a string describing |state|. | |
Daniel Erat
2014/12/11 23:34:07
nit: these functions are already commented in the
| |
14 std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) { | |
15 switch (state) { | |
16 case chromeos::DISPLAY_POWER_ALL_ON: | |
17 return "ALL_ON"; | |
18 case chromeos::DISPLAY_POWER_ALL_OFF: | |
19 return "ALL_OFF"; | |
20 case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON: | |
21 return "INTERNAL_OFF_EXTERNAL_ON"; | |
22 case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF: | |
23 return "INTERNAL_ON_EXTERNAL_OFF"; | |
24 default: | |
25 return "unknown (" + base::IntToString(state) + ")"; | |
26 } | |
27 } | |
28 | |
29 // Returns a string describing |state|. | |
30 std::string DisplayStateToString(MultipleDisplayState state) { | |
31 switch (state) { | |
32 case MULTIPLE_DISPLAY_STATE_INVALID: | |
33 return "INVALID"; | |
34 case MULTIPLE_DISPLAY_STATE_HEADLESS: | |
35 return "HEADLESS"; | |
36 case MULTIPLE_DISPLAY_STATE_SINGLE: | |
37 return "SINGLE"; | |
38 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: | |
39 return "DUAL_MIRROR"; | |
40 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: | |
41 return "DUAL_EXTENDED"; | |
42 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: | |
43 return "MULTI_EXTENDED"; | |
44 } | |
45 NOTREACHED() << "Unknown state " << state; | |
46 return "INVALID"; | |
47 } | |
48 | |
49 // Returns the number of displays in |displays| that should be turned on, per | |
50 // |state|. If |display_power| is non-NULL, it is updated to contain the | |
51 // on/off state of each corresponding entry in |displays|. | |
52 int GetDisplayPower( | |
53 const std::vector<DisplayConfigurator::DisplayState>& display_states, | |
54 chromeos::DisplayPowerState state, | |
55 std::vector<bool>* display_power) { | |
56 int num_on_displays = 0; | |
57 if (display_power) | |
58 display_power->resize(display_states.size()); | |
59 | |
60 for (size_t i = 0; i < display_states.size(); ++i) { | |
61 bool internal = | |
62 display_states[i].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; | |
63 bool on = | |
64 state == chromeos::DISPLAY_POWER_ALL_ON || | |
65 (state == chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON && | |
66 !internal) || | |
67 (state == chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal); | |
68 if (display_power) | |
69 (*display_power)[i] = on; | |
70 if (on) | |
71 num_on_displays++; | |
72 } | |
73 return num_on_displays; | |
74 } | |
75 | |
76 } // namespace ui | |
OLD | NEW |