OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
14 | 14 |
15 // Forward declarations for Xlib and Xrandr. | 15 // Forward declarations for Xlib and Xrandr. |
16 // This is so unused X definitions don't pollute the namespace. | 16 // This is so unused X definitions don't pollute the namespace. |
17 typedef unsigned long XID; | 17 typedef unsigned long XID; |
18 typedef XID Window; | 18 typedef XID Window; |
19 typedef XID RROutput; | 19 typedef XID RROutput; |
20 typedef XID RRCrtc; | 20 typedef XID RRCrtc; |
21 typedef XID RRMode; | 21 typedef XID RRMode; |
22 | 22 |
23 struct _XDisplay; | |
24 typedef struct _XDisplay Display; | |
25 struct _XRROutputInfo; | |
26 typedef _XRROutputInfo XRROutputInfo; | |
23 struct _XRRScreenResources; | 27 struct _XRRScreenResources; |
24 typedef _XRRScreenResources XRRScreenResources; | 28 typedef _XRRScreenResources XRRScreenResources; |
25 | 29 |
26 namespace chromeos { | 30 namespace chromeos { |
27 | 31 |
32 struct OutputSnapshot; | |
33 typedef struct OutputSnapshot OutputSnapshot; | |
oshima
2012/09/21 19:38:12
you don't need this
ynovikov
2012/09/21 23:05:36
Done.
| |
34 | |
28 // Used to describe the state of a multi-display configuration. | 35 // Used to describe the state of a multi-display configuration. |
29 // TODO(oshima): remove DUAL_SECONDARY_ONLY | 36 // TODO(oshima): remove DUAL_SECONDARY_ONLY |
30 enum OutputState { | 37 enum OutputState { |
31 STATE_INVALID, | 38 STATE_INVALID, |
32 STATE_HEADLESS, | 39 STATE_HEADLESS, |
33 STATE_SINGLE, | 40 STATE_SINGLE, |
34 STATE_DUAL_MIRROR, | 41 STATE_DUAL_MIRROR, |
35 STATE_DUAL_PRIMARY_ONLY, | 42 STATE_DUAL_PRIMARY_ONLY, |
36 STATE_DUAL_SECONDARY_ONLY, | 43 STATE_DUAL_SECONDARY_ONLY, |
37 STATE_DUAL_UNKNOWN, | 44 STATE_DUAL_UNKNOWN, |
(...skipping 12 matching lines...) Expand all Loading... | |
50 virtual void OnDisplayModeChanged() = 0; | 57 virtual void OnDisplayModeChanged() = 0; |
51 }; | 58 }; |
52 | 59 |
53 OutputConfigurator(); | 60 OutputConfigurator(); |
54 virtual ~OutputConfigurator(); | 61 virtual ~OutputConfigurator(); |
55 | 62 |
56 int connected_output_count() const { return connected_output_count_; } | 63 int connected_output_count() const { return connected_output_count_; } |
57 | 64 |
58 OutputState output_state() const { return output_state_; } | 65 OutputState output_state() const { return output_state_; } |
59 | 66 |
67 // Initialization, must be called right after constructor. | |
68 // |is_panel_fitting_enabled| indicates hardware panel fitting support. | |
69 void Init(bool is_panel_fitting_enabled); | |
70 | |
60 // Called when the user hits ctrl-F4 to request a display mode change. | 71 // Called when the user hits ctrl-F4 to request a display mode change. |
61 // This method should only return false if it was called in a single-head or | 72 // This method should only return false if it was called in a single-head or |
62 // headless mode. | 73 // headless mode. |
63 bool CycleDisplayMode(); | 74 bool CycleDisplayMode(); |
64 | 75 |
65 // Called when powerd notifies us that some set of displays should be turned | 76 // Called when powerd notifies us that some set of displays should be turned |
66 // on or off. This requires enabling or disabling the CRTC associated with | 77 // on or off. This requires enabling or disabling the CRTC associated with |
67 // the display(s) in question so that the low power state is engaged. | 78 // the display(s) in question so that the low power state is engaged. |
68 bool ScreenPowerSet(bool power_on, bool all_displays); | 79 bool ScreenPowerSet(bool power_on, bool all_displays); |
69 | 80 |
(...skipping 12 matching lines...) Expand all Loading... | |
82 void AddObserver(Observer* observer); | 93 void AddObserver(Observer* observer); |
83 void RemoveObserver(Observer* observer); | 94 void RemoveObserver(Observer* observer); |
84 | 95 |
85 // Tells if the output specified by |name| is for internal display. | 96 // Tells if the output specified by |name| is for internal display. |
86 static bool IsInternalOutputName(const std::string& name); | 97 static bool IsInternalOutputName(const std::string& name); |
87 | 98 |
88 private: | 99 private: |
89 // Fires OnDisplayModeChanged() event to the observers. | 100 // Fires OnDisplayModeChanged() event to the observers. |
90 void NotifyOnDisplayChanged(); | 101 void NotifyOnDisplayChanged(); |
91 | 102 |
103 // Returns output's native mode, None if not found. | |
104 static RRMode GetOutputNativeMode(const XRROutputInfo* output_info); | |
105 | |
106 // Tells if the output specified by |output_info| is for internal display. | |
107 static bool IsInternalOutput(const XRROutputInfo* output_info); | |
oshima
2012/09/21 19:38:12
move static after private instance methods
also pl
ynovikov
2012/09/21 23:05:36
Done.
| |
108 | |
109 // Fills output parameters |one| and |two| with properties of | |
110 // first two connected outputs found on |display| and |screen|. | |
111 int GetDualOutputs(Display* display, | |
112 XRRScreenResources* screen, | |
113 OutputSnapshot* one, | |
114 OutputSnapshot* two); | |
oshima
2012/09/21 19:38:12
move static methods before (or after) private inst
ynovikov
2012/09/21 23:05:36
Done.
| |
115 | |
116 // Should be called if the internal (built-in) output didn't advertise a mode | |
117 // which would be capable to support mirror mode. | |
118 // Relies on hardware panel fitting support, | |
119 // returns immediately if it is not available. | |
120 // Tries to add the native mode of the external output to the internal output, | |
121 // assuming panel fitter hardware will take care of scaling and letterboxing. | |
122 // The RROutput IDs |output_one| and |output_two| are used | |
123 // to look up the modes and configure the internal output, | |
124 // |output_one_mode| and |output_two_mode| are the out-parameters | |
125 // for the modes on the two outputs which will have same resolution. | |
126 // Returns false if it fails to configure the internal output appropriately. | |
127 bool AddMirrorModeToInternalOutput(Display* display, | |
128 XRRScreenResources* screen, | |
129 RROutput output_one, | |
130 RROutput output_two, | |
131 RRMode* output_one_mode, | |
132 RRMode* output_two_mode); | |
133 | |
92 // This is detected by the constructor to determine whether or not we should | 134 // This is detected by the constructor to determine whether or not we should |
93 // be enabled. If we aren't running on ChromeOS, we can't assume that the | 135 // be enabled. If we aren't running on ChromeOS, we can't assume that the |
94 // Xrandr X11 extension is supported. | 136 // Xrandr X11 extension is supported. |
95 // If this flag is set to false, any attempts to change the output | 137 // If this flag is set to false, any attempts to change the output |
96 // configuration to immediately fail without changing the state. | 138 // configuration to immediately fail without changing the state. |
97 bool is_running_on_chrome_os_; | 139 bool is_running_on_chrome_os_; |
98 | 140 |
141 // This is set externally in Init, | |
142 // and is used to enable modes which rely on panel fitting. | |
143 bool is_panel_fitting_enabled_; | |
144 | |
99 // The number of outputs that are connected. | 145 // The number of outputs that are connected. |
100 int connected_output_count_; | 146 int connected_output_count_; |
101 | 147 |
102 // The base of the event numbers used to represent XRandr events used in | 148 // The base of the event numbers used to represent XRandr events used in |
103 // decoding events regarding output add/remove. | 149 // decoding events regarding output add/remove. |
104 int xrandr_event_base_; | 150 int xrandr_event_base_; |
105 | 151 |
106 // The display state as derived from the outputs observed in |output_cache_|. | 152 // The display state as derived from the outputs observed in |output_cache_|. |
107 // This is used for rotating display modes. | 153 // This is used for rotating display modes. |
108 OutputState output_state_; | 154 OutputState output_state_; |
109 | 155 |
110 ObserverList<Observer> observers_; | 156 ObserverList<Observer> observers_; |
111 | 157 |
112 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 158 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
113 }; | 159 }; |
114 | 160 |
115 } // namespace chromeos | 161 } // namespace chromeos |
116 | 162 |
117 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 163 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
OLD | NEW |