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

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

Issue 226183004: Renamed OutputConfigurator to DisplayConfigurator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 #ifndef UI_DISPLAY_CHROMEOS_OUTPUT_CONFIGURATOR_H_ 5 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
6 #define UI_DISPLAY_CHROMEOS_OUTPUT_CONFIGURATOR_H_ 6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/event_types.h" 14 #include "base/event_types.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
19 #include "ui/display/chromeos/native_display_observer.h" 19 #include "ui/display/chromeos/native_display_observer.h"
20 #include "ui/display/display_constants.h" 20 #include "ui/display/display_constants.h"
21 #include "ui/display/display_export.h" 21 #include "ui/display/display_export.h"
22 22
23 namespace gfx { 23 namespace gfx {
24 class Point; 24 class Point;
25 class Size; 25 class Size;
26 } 26 }
27 27
28 namespace ui { 28 namespace ui {
29 class DisplayMode; 29 class DisplayMode;
30 class DisplaySnapshot; 30 class DisplaySnapshot;
31 class NativeDisplayDelegate; 31 class NativeDisplayDelegate;
32 32
33 // This class interacts directly with the system display configurator. 33 // This class interacts directly with the system display configurator.
34 class DISPLAY_EXPORT OutputConfigurator : public NativeDisplayObserver { 34 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
35 public: 35 public:
36 typedef uint64_t OutputProtectionClientId; 36 typedef uint64_t OutputProtectionClientId;
dnicoara 2014/04/04 18:28:59 Daniel, are you thinking to rename typedefs such a
Daniel Erat 2014/04/04 21:04:55 yeah, i think it makes sense to just drop the "out
dnicoara 2014/04/07 17:10:39 Actually, I started the other renames and there ar
37 static const OutputProtectionClientId kInvalidClientId = 0; 37 static const OutputProtectionClientId kInvalidClientId = 0;
38 38
39 struct CoordinateTransformation { 39 struct CoordinateTransformation {
40 // Initialized to the identity transformation. 40 // Initialized to the identity transformation.
41 CoordinateTransformation(); 41 CoordinateTransformation();
42 42
43 float x_scale; 43 float x_scale;
44 float x_offset; 44 float x_offset;
45 float y_scale; 45 float y_scale;
46 float y_offset; 46 float y_offset;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // |ctm| contains the desired transformation parameters. The offsets 122 // |ctm| contains the desired transformation parameters. The offsets
123 // in it should be normalized so that 1 corresponds to the X or Y axis 123 // in it should be normalized so that 1 corresponds to the X or Y axis
124 // size for the corresponding offset. 124 // size for the corresponding offset.
125 virtual void ConfigureCTM(int touch_device_id, 125 virtual void ConfigureCTM(int touch_device_id,
126 const CoordinateTransformation& ctm) = 0; 126 const CoordinateTransformation& ctm) = 0;
127 }; 127 };
128 128
129 // Helper class used by tests. 129 // Helper class used by tests.
130 class TestApi { 130 class TestApi {
131 public: 131 public:
132 TestApi(OutputConfigurator* configurator) : configurator_(configurator) {} 132 TestApi(DisplayConfigurator* configurator) : configurator_(configurator) {}
133 ~TestApi() {} 133 ~TestApi() {}
134 134
135 // If |configure_timer_| is started, stops the timer, runs 135 // If |configure_timer_| is started, stops the timer, runs
136 // ConfigureOutputs(), and returns true; returns false otherwise. 136 // ConfigureOutputs(), and returns true; returns false otherwise.
137 bool TriggerConfigureTimeout(); 137 bool TriggerConfigureTimeout();
138 138
139 private: 139 private:
140 OutputConfigurator* configurator_; // not owned 140 DisplayConfigurator* configurator_; // not owned
141 141
142 DISALLOW_COPY_AND_ASSIGN(TestApi); 142 DISALLOW_COPY_AND_ASSIGN(TestApi);
143 }; 143 };
144 144
145 // Flags that can be passed to SetDisplayPower(). 145 // Flags that can be passed to SetDisplayPower().
146 static const int kSetDisplayPowerNoFlags = 0; 146 static const int kSetDisplayPowerNoFlags = 0;
147 // Configure displays even if the passed-in state matches |power_state_|. 147 // Configure displays even if the passed-in state matches |power_state_|.
148 static const int kSetDisplayPowerForceProbe = 1 << 0; 148 static const int kSetDisplayPowerForceProbe = 1 << 0;
149 // Do not change the state if multiple displays are connected or if the 149 // Do not change the state if multiple displays are connected or if the
150 // only connected display is external. 150 // only connected display is external.
151 static const int kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; 151 static const int kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1;
152 152
153 // Gap between screens so cursor at bottom of active display doesn't 153 // Gap between screens so cursor at bottom of active display doesn't
154 // partially appear on top of inactive display. Higher numbers guard 154 // partially appear on top of inactive display. Higher numbers guard
155 // against larger cursors, but also waste more memory. 155 // against larger cursors, but also waste more memory.
156 // For simplicity, this is hard-coded to avoid the complexity of always 156 // For simplicity, this is hard-coded to avoid the complexity of always
157 // determining the DPI of the screen and rationalizing which screen we 157 // determining the DPI of the screen and rationalizing which screen we
158 // need to use for the DPI calculation. 158 // need to use for the DPI calculation.
159 // See crbug.com/130188 for initial discussion. 159 // See crbug.com/130188 for initial discussion.
160 static const int kVerticalGap = 60; 160 static const int kVerticalGap = 60;
161 161
162 // Returns the mode within |output| that matches the given size with highest 162 // Returns the mode within |output| that matches the given size with highest
163 // refresh rate. Returns None if no matching output was found. 163 // refresh rate. Returns None if no matching output was found.
164 static const DisplayMode* FindDisplayModeMatchingSize( 164 static const DisplayMode* FindDisplayModeMatchingSize(
165 const DisplaySnapshot& output, 165 const DisplaySnapshot& output,
166 const gfx::Size& size); 166 const gfx::Size& size);
167 167
168 OutputConfigurator(); 168 DisplayConfigurator();
169 virtual ~OutputConfigurator(); 169 virtual ~DisplayConfigurator();
170 170
171 OutputState output_state() const { return output_state_; } 171 OutputState output_state() const { return output_state_; }
172 chromeos::DisplayPowerState power_state() const { return power_state_; } 172 chromeos::DisplayPowerState power_state() const { return power_state_; }
173 const std::vector<DisplayState>& cached_outputs() const { 173 const std::vector<DisplayState>& cached_outputs() const {
174 return cached_outputs_; 174 return cached_outputs_;
175 } 175 }
176 176
177 void set_state_controller(StateController* controller) { 177 void set_state_controller(StateController* controller) {
178 state_controller_ = controller; 178 state_controller_ = controller;
179 } 179 }
(...skipping 11 matching lines...) Expand all
191 191
192 // Sets the initial value of |power_state_|. Must be called before Start(). 192 // Sets the initial value of |power_state_|. Must be called before Start().
193 void SetInitialDisplayPower(chromeos::DisplayPowerState power_state); 193 void SetInitialDisplayPower(chromeos::DisplayPowerState power_state);
194 194
195 // Initialization, must be called right after constructor. 195 // Initialization, must be called right after constructor.
196 // |is_panel_fitting_enabled| indicates hardware panel fitting support. 196 // |is_panel_fitting_enabled| indicates hardware panel fitting support.
197 void Init(bool is_panel_fitting_enabled); 197 void Init(bool is_panel_fitting_enabled);
198 198
199 // Does initial configuration of displays during startup. 199 // Does initial configuration of displays during startup.
200 // If |background_color_argb| is non zero and there are multiple displays, 200 // If |background_color_argb| is non zero and there are multiple displays,
201 // OutputConfigurator sets the background color of X's RootWindow to this 201 // DisplayConfigurator sets the background color of X's RootWindow to this
202 // color. 202 // color.
203 void ForceInitialConfigure(uint32_t background_color_argb); 203 void ForceInitialConfigure(uint32_t background_color_argb);
204 204
205 // Stop handling display configuration events/requests. 205 // Stop handling display configuration events/requests.
206 void PrepareForExit(); 206 void PrepareForExit();
207 207
208 // Called when powerd notifies us that some set of displays should be turned 208 // Called when powerd notifies us that some set of displays should be turned
209 // on or off. This requires enabling or disabling the CRTC associated with 209 // on or off. This requires enabling or disabling the CRTC associated with
210 // the display(s) in question so that the low power state is engaged. 210 // the display(s) in question so that the low power state is engaged.
211 // |flags| contains bitwise-or-ed kSetDisplayPower* values. 211 // |flags| contains bitwise-or-ed kSetDisplayPower* values.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 bool EnableOutputProtection(OutputProtectionClientId client_id, 259 bool EnableOutputProtection(OutputProtectionClientId client_id,
260 int64_t display_id, 260 int64_t display_id,
261 uint32_t desired_protection_mask); 261 uint32_t desired_protection_mask);
262 262
263 // Checks the available color profiles for |display_id| and fills the result 263 // Checks the available color profiles for |display_id| and fills the result
264 // into |profiles|. 264 // into |profiles|.
265 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( 265 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles(
266 int64_t display_id); 266 int64_t display_id);
267 267
268 // Updates the color calibration to |new_profile|. 268 // Updates the color calibration to |new_profile|.
269 bool SetColorCalibrationProfile( 269 bool SetColorCalibrationProfile(int64_t display_id,
270 int64_t display_id, 270 ui::ColorCalibrationProfile new_profile);
271 ui::ColorCalibrationProfile new_profile);
272 271
273 private: 272 private:
274 // Mapping a display_id to a protection request bitmask. 273 // Mapping a display_id to a protection request bitmask.
275 typedef std::map<int64_t, uint32_t> DisplayProtections; 274 typedef std::map<int64_t, uint32_t> DisplayProtections;
276 // Mapping a client to its protection request. 275 // Mapping a client to its protection request.
277 typedef std::map<OutputProtectionClientId, DisplayProtections> 276 typedef std::map<OutputProtectionClientId, DisplayProtections>
278 ProtectionRequests; 277 ProtectionRequests;
279 278
280 // Updates |cached_outputs_| to contain currently-connected outputs. Calls 279 // Updates |cached_outputs_| to contain currently-connected outputs. Calls
281 // |delegate_->GetOutputs()| and then does additional work, like finding the 280 // |delegate_->GetOutputs()| and then does additional work, like finding the
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 chromeos::DisplayPowerState power_state_; 376 chromeos::DisplayPowerState power_state_;
378 377
379 // Most-recently-used output configuration. Note that the actual 378 // Most-recently-used output configuration. Note that the actual
380 // configuration changes asynchronously. 379 // configuration changes asynchronously.
381 DisplayStateList cached_outputs_; 380 DisplayStateList cached_outputs_;
382 381
383 ObserverList<Observer> observers_; 382 ObserverList<Observer> observers_;
384 383
385 // The timer to delay configuring outputs. See also the comments in 384 // The timer to delay configuring outputs. See also the comments in
386 // Dispatch(). 385 // Dispatch().
387 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; 386 scoped_ptr<base::OneShotTimer<DisplayConfigurator> > configure_timer_;
388 387
389 // Id for next output protection client. 388 // Id for next output protection client.
390 OutputProtectionClientId next_output_protection_client_id_; 389 OutputProtectionClientId next_output_protection_client_id_;
391 390
392 // Output protection requests of each client. 391 // Output protection requests of each client.
393 ProtectionRequests client_protection_requests_; 392 ProtectionRequests client_protection_requests_;
394 393
395 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 394 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator);
396 }; 395 };
397 396
398 } // namespace ui 397 } // namespace ui
399 398
400 #endif // UI_DISPLAY_CHROMEOS_OUTPUT_CONFIGURATOR_H_ 399 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698