Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_DISPLAY_CONFIGURATOR_H_ | 5 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
| 6 #define UI_DISPLAY_CHROMEOS_DISPLAY_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> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 namespace ui { | 36 namespace ui { |
| 37 struct DisplayConfigureRequest; | 37 struct DisplayConfigureRequest; |
| 38 struct GammaRampRGBEntry; | 38 struct GammaRampRGBEntry; |
| 39 class DisplayLayoutManager; | 39 class DisplayLayoutManager; |
| 40 class DisplayMode; | 40 class DisplayMode; |
| 41 class DisplaySnapshot; | 41 class DisplaySnapshot; |
| 42 class NativeDisplayDelegate; | 42 class NativeDisplayDelegate; |
| 43 class UpdateDisplayConfigurationTask; | 43 class UpdateDisplayConfigurationTask; |
| 44 | 44 |
| 45 namespace test { | |
| 46 class DisplayConfiguratorTest; | |
| 47 } // namespace | |
| 48 | |
| 45 // This class interacts directly with the system display configurator. | 49 // This class interacts directly with the system display configurator. |
| 46 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { | 50 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { |
| 47 public: | 51 public: |
| 48 typedef uint64_t ContentProtectionClientId; | 52 typedef uint64_t ContentProtectionClientId; |
| 49 static const ContentProtectionClientId kInvalidClientId = 0; | 53 static const ContentProtectionClientId kInvalidClientId = 0; |
| 50 | 54 |
| 51 typedef base::Callback<void(bool /* success */)> ConfigurationCallback; | 55 typedef base::Callback<void(bool /* success */)> ConfigurationCallback; |
| 52 | 56 |
| 53 typedef base::Callback<void(bool /* success */)> EnableProtectionCallback; | 57 typedef base::Callback<void(bool /* success */)> EnableProtectionCallback; |
| 54 | 58 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 | 164 |
| 161 // Returns the mode within |display| that matches the given size with highest | 165 // Returns the mode within |display| that matches the given size with highest |
| 162 // refresh rate. Returns None if no matching display was found. | 166 // refresh rate. Returns None if no matching display was found. |
| 163 static const DisplayMode* FindDisplayModeMatchingSize( | 167 static const DisplayMode* FindDisplayModeMatchingSize( |
| 164 const DisplaySnapshot& display, | 168 const DisplaySnapshot& display, |
| 165 const gfx::Size& size); | 169 const gfx::Size& size); |
| 166 | 170 |
| 167 DisplayConfigurator(); | 171 DisplayConfigurator(); |
| 168 ~DisplayConfigurator() override; | 172 ~DisplayConfigurator() override; |
| 169 | 173 |
| 170 MultipleDisplayState display_state() const { return current_display_state_; } | |
| 171 chromeos::DisplayPowerState requested_power_state() const { | |
| 172 return requested_power_state_; | |
| 173 } | |
| 174 const gfx::Size framebuffer_size() const { return framebuffer_size_; } | |
| 175 const std::vector<DisplaySnapshot*>& cached_displays() const { | |
| 176 return cached_displays_; | |
| 177 } | |
| 178 | |
| 179 // Called when an external process no longer needs to control the display | 174 // Called when an external process no longer needs to control the display |
| 180 // and Chrome can take control. | 175 // and Chrome can take control. |
| 181 void TakeControl(const DisplayControlCallback& callback); | 176 void TakeControl(const DisplayControlCallback& callback); |
| 182 | 177 |
| 183 // Called when an external process needs to control the display and thus | 178 // Called when an external process needs to control the display and thus |
| 184 // Chrome should relinquish it. | 179 // Chrome should relinquish it. |
| 185 void RelinquishControl(const DisplayControlCallback& callback); | 180 void RelinquishControl(const DisplayControlCallback& callback); |
| 186 | 181 |
| 187 void set_state_controller(StateController* controller) { | |
| 188 state_controller_ = controller; | |
| 189 } | |
| 190 void set_mirroring_controller(SoftwareMirroringController* controller) { | |
| 191 mirroring_controller_ = controller; | |
| 192 } | |
| 193 | |
| 194 // Replaces |native_display_delegate_| with the delegate passed in and sets | 182 // Replaces |native_display_delegate_| with the delegate passed in and sets |
| 195 // |configure_display_| to true. Should be called before Init(). | 183 // |configure_display_| to true. Should be called before Init(). |
| 196 void SetDelegateForTesting( | 184 void SetDelegateForTesting( |
| 197 std::unique_ptr<NativeDisplayDelegate> display_delegate); | 185 std::unique_ptr<NativeDisplayDelegate> display_delegate); |
| 198 | 186 |
| 199 // Sets the initial value of |power_state_|. Must be called before Start(). | 187 // Sets the initial value of |power_state_|. Must be called before Start(). |
| 200 void SetInitialDisplayPower(chromeos::DisplayPowerState power_state); | 188 void SetInitialDisplayPower(chromeos::DisplayPowerState power_state); |
| 201 | 189 |
| 202 // Initialization, must be called right after constructor. | 190 // Initialization, must be called right after constructor. |
| 203 // |is_panel_fitting_enabled| indicates hardware panel fitting support. | 191 // |is_panel_fitting_enabled| indicates hardware panel fitting support. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 bool SetColorCalibrationProfile(int64_t display_id, | 263 bool SetColorCalibrationProfile(int64_t display_id, |
| 276 ui::ColorCalibrationProfile new_profile); | 264 ui::ColorCalibrationProfile new_profile); |
| 277 | 265 |
| 278 // Enables/disables virtual display. | 266 // Enables/disables virtual display. |
| 279 int64_t AddVirtualDisplay(const gfx::Size& display_size); | 267 int64_t AddVirtualDisplay(const gfx::Size& display_size); |
| 280 bool RemoveVirtualDisplay(int64_t display_id); | 268 bool RemoveVirtualDisplay(int64_t display_id); |
| 281 | 269 |
| 282 // Returns true if there is at least one display on. | 270 // Returns true if there is at least one display on. |
| 283 bool IsDisplayOn() const; | 271 bool IsDisplayOn() const; |
| 284 | 272 |
| 285 void set_configure_display(bool configure_display) { | |
| 286 configure_display_ = configure_display; | |
| 287 } | |
| 288 | |
| 289 // Sets the gamma, degamma and correction matrix for |display_id| to the | 273 // Sets the gamma, degamma and correction matrix for |display_id| to the |
| 290 // values in |degamma_lut|, |gamma_lut| and |correction_matrix|. | 274 // values in |degamma_lut|, |gamma_lut| and |correction_matrix|. |
| 291 bool SetColorCorrection(int64_t display_id, | 275 bool SetColorCorrection(int64_t display_id, |
| 292 const std::vector<GammaRampRGBEntry>& degamma_lut, | 276 const std::vector<GammaRampRGBEntry>& degamma_lut, |
| 293 const std::vector<GammaRampRGBEntry>& gamma_lut, | 277 const std::vector<GammaRampRGBEntry>& gamma_lut, |
| 294 const std::vector<float>& correction_matrix); | 278 const std::vector<float>& correction_matrix); |
| 295 | 279 |
| 280 MultipleDisplayState display_state() const { return current_display_state_; } | |
|
Daniel Erat
2016/10/21 21:09:45
please move all of these back below the d'tor -- c
afakhry
2016/10/22 00:28:48
Really? I always thought it's the other way around
| |
| 281 chromeos::DisplayPowerState requested_power_state() const { | |
| 282 return requested_power_state_; | |
| 283 } | |
| 284 const gfx::Size framebuffer_size() const { return framebuffer_size_; } | |
| 285 const std::vector<DisplaySnapshot*>& cached_displays() const { | |
| 286 return cached_displays_; | |
| 287 } | |
| 288 void set_state_controller(StateController* controller) { | |
| 289 state_controller_ = controller; | |
| 290 } | |
| 291 void set_mirroring_controller(SoftwareMirroringController* controller) { | |
| 292 mirroring_controller_ = controller; | |
| 293 } | |
| 294 void set_configure_display(bool configure_display) { | |
| 295 configure_display_ = configure_display; | |
| 296 } | |
| 297 chromeos::DisplayPowerState current_power_state() const { | |
| 298 return current_power_state_; | |
| 299 } | |
| 300 | |
| 296 private: | 301 private: |
| 297 class DisplayLayoutManagerImpl; | 302 class DisplayLayoutManagerImpl; |
| 303 friend class test::DisplayConfiguratorTest; | |
|
Daniel Erat
2016/10/21 21:09:45
please avoid listing test classes as friends; it o
afakhry
2016/10/22 00:28:48
It was actually more needed for ResumeDisplaysInte
| |
| 304 | |
| 305 // The delay to perform configuration after RRNotify. See the comment for | |
| 306 // |configure_timer_|. | |
| 307 static const int kConfigureDelayMs = 500; | |
| 308 | |
| 309 // The delay to perform configuration after waking up from suspend when in | |
| 310 // multi display mode. Should be bigger than |kConfigureDelayMs|. Generally | |
| 311 // big enough for external displays to be detected and added. | |
| 312 // crbug.com/614624. | |
| 313 static const int kResumeConfigureMultiDisplayDelayMs = 2000; | |
| 298 | 314 |
| 299 // Mapping a client to its protection request. | 315 // Mapping a client to its protection request. |
| 300 typedef std::map<ContentProtectionClientId, ContentProtections> | 316 typedef std::map<ContentProtectionClientId, ContentProtections> |
| 301 ProtectionRequests; | 317 ProtectionRequests; |
| 302 | 318 |
| 303 // Updates |pending_*| members and applies the passed-in state. |callback| is | 319 // Updates |pending_*| members and applies the passed-in state. |callback| is |
| 304 // invoked (perhaps synchronously) on completion. | 320 // invoked (perhaps synchronously) on completion. |
| 305 void SetDisplayPowerInternal(chromeos::DisplayPowerState power_state, | 321 void SetDisplayPowerInternal(chromeos::DisplayPowerState power_state, |
| 306 int flags, | 322 int flags, |
| 307 const ConfigurationCallback& callback); | 323 const ConfigurationCallback& callback); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 bool success); | 377 bool success); |
| 362 void OnContentProtectionClientUnregistered(bool success); | 378 void OnContentProtectionClientUnregistered(bool success); |
| 363 | 379 |
| 364 // Callbacks used to signal when the native platform has released/taken | 380 // Callbacks used to signal when the native platform has released/taken |
| 365 // display control. | 381 // display control. |
| 366 void OnDisplayControlTaken(const DisplayControlCallback& callback, | 382 void OnDisplayControlTaken(const DisplayControlCallback& callback, |
| 367 bool success); | 383 bool success); |
| 368 void OnDisplayControlRelinquished(const DisplayControlCallback& callback, | 384 void OnDisplayControlRelinquished(const DisplayControlCallback& callback, |
| 369 bool success); | 385 bool success); |
| 370 | 386 |
| 387 void ResumeDisplaysInternal(const ConfigurationCallback& callback); | |
|
Daniel Erat
2016/10/21 21:09:45
document this method (what it does and who calls i
afakhry
2016/10/22 00:28:48
Done. I made it public and moved it next to Resume
| |
| 388 | |
| 371 StateController* state_controller_; | 389 StateController* state_controller_; |
| 372 SoftwareMirroringController* mirroring_controller_; | 390 SoftwareMirroringController* mirroring_controller_; |
| 373 std::unique_ptr<NativeDisplayDelegate> native_display_delegate_; | 391 std::unique_ptr<NativeDisplayDelegate> native_display_delegate_; |
| 374 | 392 |
| 375 // Used to enable modes which rely on panel fitting. | 393 // Used to enable modes which rely on panel fitting. |
| 376 bool is_panel_fitting_enabled_; | 394 bool is_panel_fitting_enabled_; |
| 377 | 395 |
| 378 // This is detected by the constructor to determine whether or not we should | 396 // This is detected by the constructor to determine whether or not we should |
| 379 // be enabled. If we aren't running on Chrome OS, we can't assume that the | 397 // be enabled. If we aren't running on Chrome OS, we can't assume that the |
| 380 // Xrandr X11 extension or the Ozone underlying display hotplug system are | 398 // Xrandr X11 extension or the Ozone underlying display hotplug system are |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 | 482 |
| 465 // This must be the last variable. | 483 // This must be the last variable. |
| 466 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; | 484 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; |
| 467 | 485 |
| 468 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); | 486 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); |
| 469 }; | 487 }; |
| 470 | 488 |
| 471 } // namespace ui | 489 } // namespace ui |
| 472 | 490 |
| 473 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 491 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
| OLD | NEW |