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 <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "ui/display/display_export.h" | 14 #include "ui/display/display_export.h" |
15 #include "ui/display/fake_display_snapshot.h" | 15 #include "ui/display/fake_display_snapshot.h" |
16 #include "ui/display/types/fake_display_controller.h" | 16 #include "ui/display/types/fake_display_controller.h" |
17 #include "ui/display/types/native_display_delegate.h" | 17 #include "ui/display/types/native_display_delegate.h" |
18 | 18 |
19 namespace display { | 19 namespace display { |
20 | 20 |
21 // A NativeDisplayDelegate implementation that manages fake displays. Fake | 21 // A NativeDisplayDelegate implementation that manages fake displays. Fake |
22 // 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 |
23 // 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 |
24 // 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 |
25 // 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 |
26 // configuration and display management code. | 26 // configuration and display management code. |
27 // | 27 // |
28 // 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 |
29 // command line flag with the format: | 29 // command line flag. There format is as follows, where [] are optional: |
30 // HxW[^dpi][,] | 30 // native_mode[#other_modes][^dpi][/options] |
| 31 // |
| 32 // native_mode: the native display mode, with format: |
| 33 // HxW[%R] |
31 // H: display height in pixels [int] | 34 // H: display height in pixels [int] |
32 // W: display width in pixels [int] | 35 // W: display width in pixels [int] |
33 // dpi: display physical size set based on DPI [int] | 36 // R: display refresh rate [float] |
34 // | 37 // |
35 // Two 800x800 displays: | 38 // other_modes: list of other of display modes, with format: |
36 // --screen-config=800x800,800x800 | 39 // #HxW[%R][:HxW[%R]] |
37 // One 1820x1080 display and one 400x400 display: | 40 // H,W,R: same meaning as in native_mode. |
38 // --screen-config=1920x1080,400x400 | 41 // Note: The first mode is delimited with '#' and any subsequent modes are |
| 42 // delimited with ':'. |
| 43 // |
| 44 // dpi: display DPI used to set physical size, with format: |
| 45 // ^D |
| 46 // D: display DPI [int] |
| 47 // |
| 48 // options: options to set on display snapshot, with format: |
| 49 // /[a][c][i][o] |
| 50 // a: display is aspect preserving [literal a] |
| 51 // c: display has color correction matrix [literal c] |
| 52 // i: display is internal [literal i] |
| 53 // o: display has overscan [literal o] |
| 54 // |
| 55 // Examples: |
| 56 // |
| 57 // Two 800x800 displays, with first display as internal display: |
| 58 // --screen-config=800x800/i,800x800 |
| 59 // One 1920x1080 display as internal display with alternate resolutions: |
| 60 // --screen-config=1920x1080#1600x900:1280x720/i |
| 61 // One 1600x900 display with 120 refresh rate and high-DPI: |
| 62 // --screen-config=1600x900%120^300 |
39 // No displays: | 63 // No displays: |
40 // --screen-config=none | 64 // --screen-config=none |
41 // | 65 // |
42 // FakeDisplayDelegate also implements FakeDisplayController which provides a | 66 // FakeDisplayDelegate also implements FakeDisplayController which provides a |
43 // way to change the display state at runtime. | 67 // way to change the display state at runtime. |
44 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, | 68 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, |
45 public FakeDisplayController { | 69 public FakeDisplayController { |
46 public: | 70 public: |
47 FakeDisplayDelegate(); | 71 FakeDisplayDelegate(); |
48 ~FakeDisplayDelegate() override; | 72 ~FakeDisplayDelegate() override; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 ui::ColorCalibrationProfile new_profile) override; | 106 ui::ColorCalibrationProfile new_profile) override; |
83 bool SetColorCorrection(const ui::DisplaySnapshot& output, | 107 bool SetColorCorrection(const ui::DisplaySnapshot& output, |
84 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, | 108 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, |
85 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, | 109 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, |
86 const std::vector<float>& correction_matrix) override; | 110 const std::vector<float>& correction_matrix) override; |
87 void AddObserver(ui::NativeDisplayObserver* observer) override; | 111 void AddObserver(ui::NativeDisplayObserver* observer) override; |
88 void RemoveObserver(ui::NativeDisplayObserver* observer) override; | 112 void RemoveObserver(ui::NativeDisplayObserver* observer) override; |
89 FakeDisplayController* GetFakeDisplayController() override; | 113 FakeDisplayController* GetFakeDisplayController() override; |
90 | 114 |
91 protected: | 115 protected: |
92 // Creates a display snapshot from the provided |spec| string. Return null if | |
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 | 116 // Sets initial display snapshots from command line flag. Returns true if |
98 // command line flag was provided. | 117 // command line flag was provided. |
99 bool InitFromCommandLine(); | 118 bool InitFromCommandLine(); |
100 | 119 |
101 // Updates observers when display configuration has changed. Will not update | 120 // Updates observers when display configuration has changed. Will not update |
102 // until after |Initialize()| has been called. | 121 // until after |Initialize()| has been called. |
103 void OnConfigurationChanged(); | 122 void OnConfigurationChanged(); |
104 | 123 |
105 private: | 124 private: |
106 base::ObserverList<ui::NativeDisplayObserver> observers_; | 125 base::ObserverList<ui::NativeDisplayObserver> observers_; |
107 std::vector<std::unique_ptr<ui::DisplaySnapshot>> displays_; | 126 std::vector<std::unique_ptr<ui::DisplaySnapshot>> displays_; |
108 | 127 |
109 // If |Initialize()| has been called. | 128 // If |Initialize()| has been called. |
110 bool initialized_ = false; | 129 bool initialized_ = false; |
111 | 130 |
112 // The next available display id. | 131 // The next available display id. |
113 uint8_t next_display_id_ = 0; | 132 uint8_t next_display_id_ = 0; |
114 | 133 |
115 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); | 134 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); |
116 }; | 135 }; |
117 | 136 |
118 } // namespace display | 137 } // namespace display |
119 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ | 138 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ |
OLD | NEW |