| 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_MANAGER_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 5 #ifndef UI_DISPLAY_MANAGER_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
| 6 #define UI_DISPLAY_MANAGER_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 6 #define UI_DISPLAY_MANAGER_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class DisplayLayoutManager; | 37 class DisplayLayoutManager; |
| 38 class DisplayMode; | 38 class DisplayMode; |
| 39 class DisplaySnapshot; | 39 class DisplaySnapshot; |
| 40 class NativeDisplayDelegate; | 40 class NativeDisplayDelegate; |
| 41 class UpdateDisplayConfigurationTask; | 41 class UpdateDisplayConfigurationTask; |
| 42 | 42 |
| 43 // This class interacts directly with the system display configurator. | 43 // This class interacts directly with the system display configurator. |
| 44 class DISPLAY_MANAGER_EXPORT DisplayConfigurator | 44 class DISPLAY_MANAGER_EXPORT DisplayConfigurator |
| 45 : public NativeDisplayObserver { | 45 : public NativeDisplayObserver { |
| 46 public: | 46 public: |
| 47 typedef uint64_t ContentProtectionClientId; | 47 enum : uint64_t { |
| 48 static const ContentProtectionClientId kInvalidClientId = 0; | 48 INVALID_CLIENT_ID = 0, |
| 49 | |
| 50 typedef base::Callback<void(bool /* success */)> ConfigurationCallback; | |
| 51 | |
| 52 typedef base::Callback<void(bool /* success */)> EnableProtectionCallback; | |
| 53 | |
| 54 struct QueryProtectionResponse { | |
| 55 // True if the query succeeded, false otherwise. | |
| 56 bool success = false; | |
| 57 | |
| 58 // The type of connected display links, which is a bitmask of | |
| 59 // DisplayConnectionType values. | |
| 60 uint32_t link_mask = 0; | |
| 61 | |
| 62 // The desired protection methods, which is a bitmask of the | |
| 63 // ContentProtectionMethod values. | |
| 64 uint32_t protection_mask = 0; | |
| 65 }; | 49 }; |
| 66 | 50 |
| 67 typedef base::Callback<void(const QueryProtectionResponse&)> | 51 using ConfigurationCallback = base::Callback<void(bool /* success */)>; |
| 68 QueryProtectionCallback; | |
| 69 | 52 |
| 70 typedef base::Callback<void(bool /* success */)> DisplayControlCallback; | 53 using SetProtectionCallback = base::Callback<void(bool /* success */)>; |
| 71 | 54 |
| 72 typedef std::vector<DisplaySnapshot*> DisplayStateList; | 55 // link_mask: The type of connected display links, which is a bitmask of |
| 56 // DisplayConnectionType values. |
| 57 // protection_mask: The desired protection methods, which is a bitmask of the |
| 58 // ContentProtectionMethod values. |
| 59 using QueryProtectionCallback = |
| 60 base::Callback<void(bool /* success */, |
| 61 uint32_t /* link_mask */, |
| 62 uint32_t /* protection_mask */)>; |
| 63 using DisplayControlCallback = base::Callback<void(bool /* success */)>; |
| 64 |
| 65 using DisplayStateList = std::vector<DisplaySnapshot*>; |
| 73 | 66 |
| 74 // Mapping a display_id to a protection request bitmask. | 67 // Mapping a display_id to a protection request bitmask. |
| 75 typedef std::map<int64_t, uint32_t> ContentProtections; | 68 using ContentProtections = std::map<int64_t, uint32_t>; |
| 76 | 69 |
| 77 class Observer { | 70 class Observer { |
| 78 public: | 71 public: |
| 79 virtual ~Observer() {} | 72 virtual ~Observer() {} |
| 80 | 73 |
| 81 // Called after the display mode has been changed. |display| contains the | 74 // Called after the display mode has been changed. |display| contains the |
| 82 // just-applied configuration. Note that the X server is no longer grabbed | 75 // just-applied configuration. Note that the X server is no longer grabbed |
| 83 // when this method is called, so the actual configuration could've changed | 76 // when this method is called, so the actual configuration could've changed |
| 84 // already. | 77 // already. |
| 85 virtual void OnDisplayModeChanged(const DisplayStateList& displays) {} | 78 virtual void OnDisplayModeChanged(const DisplayStateList& displays) {} |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // machines where display configuration is slow. On completion of the display | 249 // machines where display configuration is slow. On completion of the display |
| 257 // configuration |callback| is executed synchronously or asynchronously. | 250 // configuration |callback| is executed synchronously or asynchronously. |
| 258 void SuspendDisplays(const ConfigurationCallback& callback); | 251 void SuspendDisplays(const ConfigurationCallback& callback); |
| 259 | 252 |
| 260 // Reprobes displays to handle changes made while the system was | 253 // Reprobes displays to handle changes made while the system was |
| 261 // suspended. | 254 // suspended. |
| 262 void ResumeDisplays(); | 255 void ResumeDisplays(); |
| 263 | 256 |
| 264 // Registers a client for display protection and requests a client id. Returns | 257 // Registers a client for display protection and requests a client id. Returns |
| 265 // 0 if requesting failed. | 258 // 0 if requesting failed. |
| 266 ContentProtectionClientId RegisterContentProtectionClient(); | 259 uint64_t RegisterContentProtectionClient(); |
| 267 | 260 |
| 268 // Unregisters the client. | 261 // Unregisters the client. |
| 269 void UnregisterContentProtectionClient(ContentProtectionClientId client_id); | 262 void UnregisterContentProtectionClient(uint64_t client_id); |
| 270 | 263 |
| 271 // Queries link status and protection status. |callback| is used to respond | 264 // Queries link status and protection status. |callback| is used to respond |
| 272 // to the query. | 265 // to the query. |
| 273 void QueryContentProtectionStatus(ContentProtectionClientId client_id, | 266 void QueryContentProtectionStatus(uint64_t client_id, |
| 274 int64_t display_id, | 267 int64_t display_id, |
| 275 const QueryProtectionCallback& callback); | 268 const QueryProtectionCallback& callback); |
| 276 | 269 |
| 277 // Requests the desired protection methods. | 270 // Requests the desired protection methods. |
| 278 // |protection_mask| is the desired protection methods, which is a bitmask | 271 // |protection_mask| is the desired protection methods, which is a bitmask |
| 279 // of the ContentProtectionMethod values. | 272 // of the ContentProtectionMethod values. |
| 280 // Returns true when the protection request has been made. | 273 // Returns true when the protection request has been made. |
| 281 void EnableContentProtection(ContentProtectionClientId client_id, | 274 void SetContentProtection(uint64_t client_id, |
| 282 int64_t display_id, | 275 int64_t display_id, |
| 283 uint32_t protection_mask, | 276 uint32_t protection_mask, |
| 284 const EnableProtectionCallback& callback); | 277 const SetProtectionCallback& callback); |
| 285 | 278 |
| 286 // Checks the available color profiles for |display_id| and fills the result | 279 // Checks the available color profiles for |display_id| and fills the result |
| 287 // into |profiles|. | 280 // into |profiles|. |
| 288 std::vector<ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( | 281 std::vector<ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( |
| 289 int64_t display_id); | 282 int64_t display_id); |
| 290 | 283 |
| 291 // Updates the color calibration to |new_profile|. | 284 // Updates the color calibration to |new_profile|. |
| 292 bool SetColorCalibrationProfile(int64_t display_id, | 285 bool SetColorCalibrationProfile(int64_t display_id, |
| 293 ColorCalibrationProfile new_profile); | 286 ColorCalibrationProfile new_profile); |
| 294 | 287 |
| 295 // Enables/disables virtual display. | 288 // Enables/disables virtual display. |
| 296 int64_t AddVirtualDisplay(const gfx::Size& display_size); | 289 int64_t AddVirtualDisplay(const gfx::Size& display_size); |
| 297 bool RemoveVirtualDisplay(int64_t display_id); | 290 bool RemoveVirtualDisplay(int64_t display_id); |
| 298 | 291 |
| 299 // Returns true if there is at least one display on. | 292 // Returns true if there is at least one display on. |
| 300 bool IsDisplayOn() const; | 293 bool IsDisplayOn() const; |
| 301 | 294 |
| 302 // Sets the gamma, degamma and correction matrix for |display_id| to the | 295 // Sets the gamma, degamma and correction matrix for |display_id| to the |
| 303 // values in |degamma_lut|, |gamma_lut| and |correction_matrix|. | 296 // values in |degamma_lut|, |gamma_lut| and |correction_matrix|. |
| 304 bool SetColorCorrection(int64_t display_id, | 297 bool SetColorCorrection(int64_t display_id, |
| 305 const std::vector<GammaRampRGBEntry>& degamma_lut, | 298 const std::vector<GammaRampRGBEntry>& degamma_lut, |
| 306 const std::vector<GammaRampRGBEntry>& gamma_lut, | 299 const std::vector<GammaRampRGBEntry>& gamma_lut, |
| 307 const std::vector<float>& correction_matrix); | 300 const std::vector<float>& correction_matrix); |
| 308 | 301 |
| 309 private: | 302 private: |
| 310 class DisplayLayoutManagerImpl; | 303 class DisplayLayoutManagerImpl; |
| 311 | 304 |
| 312 // Mapping a client to its protection request. | 305 // Mapping a client to its protection request. |
| 313 typedef std::map<ContentProtectionClientId, ContentProtections> | 306 using ProtectionRequests = std::map<uint64_t, ContentProtections>; |
| 314 ProtectionRequests; | |
| 315 | 307 |
| 316 // Updates |pending_*| members and applies the passed-in state. |callback| is | 308 // Updates |pending_*| members and applies the passed-in state. |callback| is |
| 317 // invoked (perhaps synchronously) on completion. | 309 // invoked (perhaps synchronously) on completion. |
| 318 void SetDisplayPowerInternal(chromeos::DisplayPowerState power_state, | 310 void SetDisplayPowerInternal(chromeos::DisplayPowerState power_state, |
| 319 int flags, | 311 int flags, |
| 320 const ConfigurationCallback& callback); | 312 const ConfigurationCallback& callback); |
| 321 | 313 |
| 322 // Configures displays. Invoked by |configure_timer_|. | 314 // Configures displays. Invoked by |configure_timer_|. |
| 323 void ConfigureDisplays(); | 315 void ConfigureDisplays(); |
| 324 | 316 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // |in_progress_configuration_callbacks_| and | 350 // |in_progress_configuration_callbacks_| and |
| 359 // |queued_configuration_callbacks_| and clear the lists after. |success| is | 351 // |queued_configuration_callbacks_| and clear the lists after. |success| is |
| 360 // the configuration status used when calling the callbacks. | 352 // the configuration status used when calling the callbacks. |
| 361 void CallAndClearInProgressCallbacks(bool success); | 353 void CallAndClearInProgressCallbacks(bool success); |
| 362 void CallAndClearQueuedCallbacks(bool success); | 354 void CallAndClearQueuedCallbacks(bool success); |
| 363 | 355 |
| 364 // Content protection callbacks called by the tasks when they finish. These | 356 // Content protection callbacks called by the tasks when they finish. These |
| 365 // are responsible for destroying the task, replying to the caller that made | 357 // are responsible for destroying the task, replying to the caller that made |
| 366 // the task and starting the a new content protection task if one is queued. | 358 // the task and starting the a new content protection task if one is queued. |
| 367 void OnContentProtectionQueried( | 359 void OnContentProtectionQueried( |
| 368 ContentProtectionClientId client_id, | 360 uint64_t client_id, |
| 369 int64_t display_id, | 361 int64_t display_id, |
| 370 QueryContentProtectionTask::Response response); | 362 QueryContentProtectionTask::Response response); |
| 371 void OnContentProtectionEnabled(ContentProtectionClientId client_id, | 363 void OnSetContentProtectionCompleted(uint64_t client_id, |
| 372 int64_t display_id, | 364 int64_t display_id, |
| 373 uint32_t desired_method_mask, | 365 uint32_t desired_method_mask, |
| 374 bool success); | 366 bool success); |
| 375 void OnContentProtectionClientUnregistered(bool success); | 367 void OnContentProtectionClientUnregistered(bool success); |
| 376 | 368 |
| 377 // Callbacks used to signal when the native platform has released/taken | 369 // Callbacks used to signal when the native platform has released/taken |
| 378 // display control. | 370 // display control. |
| 379 void OnDisplayControlTaken(const DisplayControlCallback& callback, | 371 void OnDisplayControlTaken(const DisplayControlCallback& callback, |
| 380 bool success); | 372 bool success); |
| 381 void OnDisplayControlRelinquished(const DisplayControlCallback& callback, | 373 void OnDisplayControlRelinquished(const DisplayControlCallback& callback, |
| 382 bool success); | 374 bool success); |
| 383 | 375 |
| 384 // Helper function that sends the actual command. | 376 // Helper function that sends the actual command. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // start/finish. Note these callbacks belong to the pending request, not a | 422 // start/finish. Note these callbacks belong to the pending request, not a |
| 431 // request currently active. | 423 // request currently active. |
| 432 std::vector<ConfigurationCallback> queued_configuration_callbacks_; | 424 std::vector<ConfigurationCallback> queued_configuration_callbacks_; |
| 433 | 425 |
| 434 // List of callbacks belonging to the currently running display configuration | 426 // List of callbacks belonging to the currently running display configuration |
| 435 // task. | 427 // task. |
| 436 std::vector<ConfigurationCallback> in_progress_configuration_callbacks_; | 428 std::vector<ConfigurationCallback> in_progress_configuration_callbacks_; |
| 437 | 429 |
| 438 std::queue<base::Closure> content_protection_tasks_; | 430 std::queue<base::Closure> content_protection_tasks_; |
| 439 std::queue<QueryProtectionCallback> query_protection_callbacks_; | 431 std::queue<QueryProtectionCallback> query_protection_callbacks_; |
| 440 std::queue<EnableProtectionCallback> enable_protection_callbacks_; | 432 std::queue<SetProtectionCallback> set_protection_callbacks_; |
| 441 | 433 |
| 442 // True if the caller wants to force the display configuration process. | 434 // True if the caller wants to force the display configuration process. |
| 443 bool force_configure_; | 435 bool force_configure_; |
| 444 | 436 |
| 445 // Most-recently-used display configuration. Note that the actual | 437 // Most-recently-used display configuration. Note that the actual |
| 446 // configuration changes asynchronously. | 438 // configuration changes asynchronously. |
| 447 DisplayStateList cached_displays_; | 439 DisplayStateList cached_displays_; |
| 448 | 440 |
| 449 // Most-recently-used framebuffer size. | 441 // Most-recently-used framebuffer size. |
| 450 gfx::Size framebuffer_size_; | 442 gfx::Size framebuffer_size_; |
| 451 | 443 |
| 452 base::ObserverList<Observer> observers_; | 444 base::ObserverList<Observer> observers_; |
| 453 | 445 |
| 454 // The timer to delay configuring displays. This is used to aggregate multiple | 446 // The timer to delay configuring displays. This is used to aggregate multiple |
| 455 // display configuration events when they are reported in short time spans. | 447 // display configuration events when they are reported in short time spans. |
| 456 // See comment for NativeDisplayEventDispatcherX11 for more details. | 448 // See comment for NativeDisplayEventDispatcherX11 for more details. |
| 457 base::OneShotTimer configure_timer_; | 449 base::OneShotTimer configure_timer_; |
| 458 | 450 |
| 459 // Id for next display protection client. | 451 // Id for next display protection client. |
| 460 ContentProtectionClientId next_display_protection_client_id_; | 452 uint64_t next_display_protection_client_id_; |
| 461 | 453 |
| 462 // Display protection requests of each client. | 454 // Display protection requests of each client. |
| 463 ProtectionRequests client_protection_requests_; | 455 ProtectionRequests client_protection_requests_; |
| 464 | 456 |
| 465 // Display controlled by an external entity. | 457 // Display controlled by an external entity. |
| 466 bool display_externally_controlled_; | 458 bool display_externally_controlled_; |
| 467 | 459 |
| 468 // True if a TakeControl or RelinquishControl has been called but the response | 460 // True if a TakeControl or RelinquishControl has been called but the response |
| 469 // hasn't arrived yet. | 461 // hasn't arrived yet. |
| 470 bool display_control_changing_; | 462 bool display_control_changing_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 484 | 476 |
| 485 // This must be the last variable. | 477 // This must be the last variable. |
| 486 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; | 478 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; |
| 487 | 479 |
| 488 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); | 480 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); |
| 489 }; | 481 }; |
| 490 | 482 |
| 491 } // namespace display | 483 } // namespace display |
| 492 | 484 |
| 493 #endif // UI_DISPLAY_MANAGER_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 485 #endif // UI_DISPLAY_MANAGER_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
| OLD | NEW |