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 <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
13 #include "ui/display/display_export.h" | 14 #include "ui/display/display_export.h" |
14 #include "ui/display/fake_display_snapshot.h" | 15 #include "ui/display/fake_display_snapshot.h" |
15 #include "ui/display/types/fake_display_controller.h" | 16 #include "ui/display/types/fake_display_controller.h" |
16 #include "ui/display/types/native_display_delegate.h" | 17 #include "ui/display/types/native_display_delegate.h" |
17 | 18 |
18 namespace display { | 19 namespace display { |
19 | 20 |
20 // A NativeDisplayDelegate implementation that manages fake displays. Fake | 21 // A NativeDisplayDelegate implementation that manages fake displays. Fake |
21 // displays mimic physical displays but do not actually exist. This is because | 22 // displays mimic physical displays but do not actually exist. This is because |
22 // Chrome OS does not take over the entire display when running off device and | 23 // Chrome OS does not take over the entire display when running off device and |
23 // instead runs inside windows provided by the parent OS. Fake displays allow us | 24 // instead runs inside windows provided by the parent OS. Fake displays allow us |
24 // to simulate different connected display states off device and to test display | 25 // to simulate different connected display states off device and to test display |
25 // configuration and display management code. | 26 // configuration and display management code. |
26 // | 27 // |
27 // The size and number of displays can controlled via --screen-config=X | 28 // The size and number of displays can controlled via --screen-config=X |
28 // command line flag with the format: | 29 // command line flag with the format: |
29 // HxW[,] | 30 // HxW[^dpi][,] |
30 // H: display height in pixels | 31 // H: display height in pixels [int] |
31 // W: display width in pixels | 32 // W: display width in pixels [int] |
| 33 // dpi: display physical size set based on DPI [int] |
32 // | 34 // |
33 // Two 800x800 displays: | 35 // Two 800x800 displays: |
34 // --screen-config=800x800,800x800 | 36 // --screen-config=800x800,800x800 |
35 // One 1820x1080 display and one 400x400 display: | 37 // One 1820x1080 display and one 400x400 display: |
36 // --screen-config=1920x1080,400x400 | 38 // --screen-config=1920x1080,400x400 |
| 39 // No displays: |
| 40 // --screen-config=none |
37 // | 41 // |
38 // FakeDisplayDelegate also implements FakeDisplayController which provides a | 42 // FakeDisplayDelegate also implements FakeDisplayController which provides a |
39 // way to change the display state at runtime. | 43 // way to change the display state at runtime. |
40 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, | 44 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, |
41 public FakeDisplayController { | 45 public FakeDisplayController { |
42 public: | 46 public: |
43 FakeDisplayDelegate(); | 47 FakeDisplayDelegate(); |
44 ~FakeDisplayDelegate() override; | 48 ~FakeDisplayDelegate() override; |
45 | 49 |
46 // FakeDisplayController: | 50 // FakeDisplayController: |
47 int64_t AddDisplay(const gfx::Size& display_size) override; | 51 int64_t AddDisplay(const gfx::Size& display_size) override; |
| 52 bool AddDisplay(std::unique_ptr<ui::DisplaySnapshot> display) override; |
48 bool RemoveDisplay(int64_t display_id) override; | 53 bool RemoveDisplay(int64_t display_id) override; |
49 | 54 |
50 // NativeDisplayDelegate overrides: | 55 // NativeDisplayDelegate overrides: |
51 void Initialize() override; | 56 void Initialize() override; |
52 void GrabServer() override; | 57 void GrabServer() override; |
53 void UngrabServer() override; | 58 void UngrabServer() override; |
54 void TakeDisplayControl(const ui::DisplayControlCallback& callback) override; | 59 void TakeDisplayControl(const ui::DisplayControlCallback& callback) override; |
55 void RelinquishDisplayControl( | 60 void RelinquishDisplayControl( |
56 const ui::DisplayControlCallback& callback) override; | 61 const ui::DisplayControlCallback& callback) override; |
57 void SyncWithServer() override; | 62 void SyncWithServer() override; |
(...skipping 19 matching lines...) Expand all Loading... |
77 ui::ColorCalibrationProfile new_profile) override; | 82 ui::ColorCalibrationProfile new_profile) override; |
78 bool SetColorCorrection(const ui::DisplaySnapshot& output, | 83 bool SetColorCorrection(const ui::DisplaySnapshot& output, |
79 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, | 84 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, |
80 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, | 85 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, |
81 const std::vector<float>& correction_matrix) override; | 86 const std::vector<float>& correction_matrix) override; |
82 void AddObserver(ui::NativeDisplayObserver* observer) override; | 87 void AddObserver(ui::NativeDisplayObserver* observer) override; |
83 void RemoveObserver(ui::NativeDisplayObserver* observer) override; | 88 void RemoveObserver(ui::NativeDisplayObserver* observer) override; |
84 FakeDisplayController* GetFakeDisplayController() override; | 89 FakeDisplayController* GetFakeDisplayController() override; |
85 | 90 |
86 protected: | 91 protected: |
87 // Initializes display snapshots from command line flags if provided. | 92 // Creates a display snapshot from the provided |spec| string. Return null if |
88 void InitFromCommandLine(); | 93 // |spec| is invalid. |
| 94 std::unique_ptr<ui::DisplaySnapshot> CreateSnapshotFromSpec( |
| 95 const std::string& spec); |
| 96 |
| 97 // Sets initial display snapshots from command line flag. Returns true if |
| 98 // command line flag was provided. |
| 99 bool InitFromCommandLine(); |
89 | 100 |
90 // Updates observers when display configuration has changed. Will not update | 101 // Updates observers when display configuration has changed. Will not update |
91 // until after |Initialize()| has been called. | 102 // until after |Initialize()| has been called. |
92 void OnConfigurationChanged(); | 103 void OnConfigurationChanged(); |
93 | 104 |
94 private: | 105 private: |
95 base::ObserverList<ui::NativeDisplayObserver> observers_; | 106 base::ObserverList<ui::NativeDisplayObserver> observers_; |
96 std::vector<std::unique_ptr<FakeDisplaySnapshot>> displays_; | 107 std::vector<std::unique_ptr<ui::DisplaySnapshot>> displays_; |
97 | 108 |
98 // If |Initialize()| has been called. | 109 // If |Initialize()| has been called. |
99 bool initialized_ = false; | 110 bool initialized_ = false; |
100 | 111 |
101 // The next available display id. | 112 // The next available display id. |
102 uint8_t next_display_id_ = 0; | 113 uint8_t next_display_id_ = 0; |
103 | 114 |
104 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); | 115 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); |
105 }; | 116 }; |
106 | 117 |
107 } // namespace display | 118 } // namespace display |
108 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ | 119 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ |
OLD | NEW |