| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_FAKE_DISPLAY_DELEGATE_H_ | 5 #ifndef UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ |
| 6 #define UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ | 6 #define UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // --screen-config=800x800/i,800x800 | 61 // --screen-config=800x800/i,800x800 |
| 62 // One 1600x900 display as internal display with 120 refresh rate and high-DPI: | 62 // One 1600x900 display as internal display with 120 refresh rate and high-DPI: |
| 63 // --screen-config=1600x900%120^300/i | 63 // --screen-config=1600x900%120^300/i |
| 64 // One 1920x1080 display with alternate resolutions: | 64 // One 1920x1080 display with alternate resolutions: |
| 65 // --screen-config=1920x1080#1600x900:1280x720 | 65 // --screen-config=1920x1080#1600x900:1280x720 |
| 66 // No displays: | 66 // No displays: |
| 67 // --screen-config=none | 67 // --screen-config=none |
| 68 // | 68 // |
| 69 // FakeDisplayDelegate also implements FakeDisplayController which provides a | 69 // FakeDisplayDelegate also implements FakeDisplayController which provides a |
| 70 // way to change the display state at runtime. | 70 // way to change the display state at runtime. |
| 71 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, | 71 class DISPLAY_EXPORT FakeDisplayDelegate : public NativeDisplayDelegate, |
| 72 public FakeDisplayController { | 72 public FakeDisplayController { |
| 73 public: | 73 public: |
| 74 FakeDisplayDelegate(); | 74 FakeDisplayDelegate(); |
| 75 ~FakeDisplayDelegate() override; | 75 ~FakeDisplayDelegate() override; |
| 76 | 76 |
| 77 // FakeDisplayController: | 77 // FakeDisplayController: |
| 78 int64_t AddDisplay(const gfx::Size& display_size) override; | 78 int64_t AddDisplay(const gfx::Size& display_size) override; |
| 79 bool AddDisplay(std::unique_ptr<ui::DisplaySnapshot> display) override; | 79 bool AddDisplay(std::unique_ptr<DisplaySnapshot> display) override; |
| 80 bool RemoveDisplay(int64_t display_id) override; | 80 bool RemoveDisplay(int64_t display_id) override; |
| 81 | 81 |
| 82 // NativeDisplayDelegate overrides: | 82 // NativeDisplayDelegate overrides: |
| 83 void Initialize() override; | 83 void Initialize() override; |
| 84 void GrabServer() override; | 84 void GrabServer() override; |
| 85 void UngrabServer() override; | 85 void UngrabServer() override; |
| 86 void TakeDisplayControl(const ui::DisplayControlCallback& callback) override; | 86 void TakeDisplayControl(const DisplayControlCallback& callback) override; |
| 87 void RelinquishDisplayControl( | 87 void RelinquishDisplayControl( |
| 88 const ui::DisplayControlCallback& callback) override; | 88 const DisplayControlCallback& callback) override; |
| 89 void SyncWithServer() override; | 89 void SyncWithServer() override; |
| 90 void SetBackgroundColor(uint32_t color_argb) override; | 90 void SetBackgroundColor(uint32_t color_argb) override; |
| 91 void ForceDPMSOn() override; | 91 void ForceDPMSOn() override; |
| 92 void GetDisplays(const ui::GetDisplaysCallback& callback) override; | 92 void GetDisplays(const GetDisplaysCallback& callback) override; |
| 93 void AddMode(const ui::DisplaySnapshot& output, | 93 void AddMode(const DisplaySnapshot& output, const DisplayMode* mode) override; |
| 94 const ui::DisplayMode* mode) override; | 94 void Configure(const DisplaySnapshot& output, |
| 95 void Configure(const ui::DisplaySnapshot& output, | 95 const DisplayMode* mode, |
| 96 const ui::DisplayMode* mode, | |
| 97 const gfx::Point& origin, | 96 const gfx::Point& origin, |
| 98 const ui::ConfigureCallback& callback) override; | 97 const ConfigureCallback& callback) override; |
| 99 void CreateFrameBuffer(const gfx::Size& size) override; | 98 void CreateFrameBuffer(const gfx::Size& size) override; |
| 100 void GetHDCPState(const ui::DisplaySnapshot& output, | 99 void GetHDCPState(const DisplaySnapshot& output, |
| 101 const ui::GetHDCPStateCallback& callback) override; | 100 const GetHDCPStateCallback& callback) override; |
| 102 void SetHDCPState(const ui::DisplaySnapshot& output, | 101 void SetHDCPState(const DisplaySnapshot& output, |
| 103 ui::HDCPState state, | 102 HDCPState state, |
| 104 const ui::SetHDCPStateCallback& callback) override; | 103 const SetHDCPStateCallback& callback) override; |
| 105 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( | 104 std::vector<ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( |
| 106 const ui::DisplaySnapshot& output) override; | 105 const DisplaySnapshot& output) override; |
| 107 bool SetColorCalibrationProfile( | 106 bool SetColorCalibrationProfile(const DisplaySnapshot& output, |
| 108 const ui::DisplaySnapshot& output, | 107 ColorCalibrationProfile new_profile) override; |
| 109 ui::ColorCalibrationProfile new_profile) override; | 108 bool SetColorCorrection(const DisplaySnapshot& output, |
| 110 bool SetColorCorrection(const ui::DisplaySnapshot& output, | 109 const std::vector<GammaRampRGBEntry>& degamma_lut, |
| 111 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, | 110 const std::vector<GammaRampRGBEntry>& gamma_lut, |
| 112 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, | |
| 113 const std::vector<float>& correction_matrix) override; | 111 const std::vector<float>& correction_matrix) override; |
| 114 void AddObserver(ui::NativeDisplayObserver* observer) override; | 112 void AddObserver(NativeDisplayObserver* observer) override; |
| 115 void RemoveObserver(ui::NativeDisplayObserver* observer) override; | 113 void RemoveObserver(NativeDisplayObserver* observer) override; |
| 116 FakeDisplayController* GetFakeDisplayController() override; | 114 FakeDisplayController* GetFakeDisplayController() override; |
| 117 | 115 |
| 118 protected: | 116 protected: |
| 119 // Sets initial display snapshots from command line flag. Returns true if the | 117 // Sets initial display snapshots from command line flag. Returns true if the |
| 120 // spec was parsed successfully. | 118 // spec was parsed successfully. |
| 121 bool InitializeFromSpecString(const std::string& str); | 119 bool InitializeFromSpecString(const std::string& str); |
| 122 | 120 |
| 123 // Updates observers when display configuration has changed. Will not update | 121 // Updates observers when display configuration has changed. Will not update |
| 124 // until after |Initialize()| has been called. | 122 // until after |Initialize()| has been called. |
| 125 void OnConfigurationChanged(); | 123 void OnConfigurationChanged(); |
| 126 | 124 |
| 127 private: | 125 private: |
| 128 // Performs callback for Configure(). | 126 // Performs callback for Configure(). |
| 129 void ConfigureDone(); | 127 void ConfigureDone(); |
| 130 | 128 |
| 131 base::ObserverList<ui::NativeDisplayObserver> observers_; | 129 base::ObserverList<NativeDisplayObserver> observers_; |
| 132 std::vector<std::unique_ptr<ui::DisplaySnapshot>> displays_; | 130 std::vector<std::unique_ptr<DisplaySnapshot>> displays_; |
| 133 | 131 |
| 134 // Add delay before finishing Configure() and running callback. | 132 // Add delay before finishing Configure() and running callback. |
| 135 base::OneShotTimer configure_timer_; | 133 base::OneShotTimer configure_timer_; |
| 136 std::queue<base::Closure> configure_callbacks_; | 134 std::queue<base::Closure> configure_callbacks_; |
| 137 | 135 |
| 138 // If Initialize() has been called. | 136 // If Initialize() has been called. |
| 139 bool initialized_ = false; | 137 bool initialized_ = false; |
| 140 | 138 |
| 141 // The next available display id. | 139 // The next available display id. |
| 142 uint8_t next_display_id_ = 0; | 140 uint8_t next_display_id_ = 0; |
| 143 | 141 |
| 144 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); | 142 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); |
| 145 }; | 143 }; |
| 146 | 144 |
| 147 } // namespace display | 145 } // namespace display |
| 148 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ | 146 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ |
| OLD | NEW |