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 with the format: |
30 // HxW[^dpi][,] | 30 // HxW[%R][#HxW[%R][:HxW[%R]]][^D][/[a][c][i][o]][,...] |
Daniel Erat
2016/10/05 21:09:45
can you document what the #- and :-prefixed dimens
kylechar
2016/10/07 16:14:42
Improved this comment a bunch I hope.
| |
31 // H: display height in pixels [int] | 31 // H: display height in pixels [int] |
32 // W: display width in pixels [int] | 32 // W: display width in pixels [int] |
33 // dpi: display physical size set based on DPI [int] | 33 // R: display refresh rate [float] |
34 // D: display DPI, used to set physical size [int] | |
35 // Options: | |
36 // a: display is aspect preserving | |
37 // c: display has color correction matrix | |
38 // i: display is internal | |
39 // o: display has overscan | |
34 // | 40 // |
35 // Two 800x800 displays: | 41 // Two 800x800 displays, with first display as internal display: |
36 // --screen-config=800x800,800x800 | 42 // --screen-config=800x800/i,800x800 |
37 // One 1820x1080 display and one 400x400 display: | 43 // One 1920x1080 display as internal display with alternate resolutions: |
38 // --screen-config=1920x1080,400x400 | 44 // --screen-config=1920x1080#1600x900:1280x720/i |
45 // One 1600x900 display with 120 refresh rate and high-DPI: | |
46 // --screen-config=1600x900%120^300 | |
39 // No displays: | 47 // No displays: |
40 // --screen-config=none | 48 // --screen-config=none |
41 // | 49 // |
42 // FakeDisplayDelegate also implements FakeDisplayController which provides a | 50 // FakeDisplayDelegate also implements FakeDisplayController which provides a |
43 // way to change the display state at runtime. | 51 // way to change the display state at runtime. |
44 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, | 52 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate, |
45 public FakeDisplayController { | 53 public FakeDisplayController { |
46 public: | 54 public: |
47 FakeDisplayDelegate(); | 55 FakeDisplayDelegate(); |
48 ~FakeDisplayDelegate() override; | 56 ~FakeDisplayDelegate() override; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 ui::ColorCalibrationProfile new_profile) override; | 90 ui::ColorCalibrationProfile new_profile) override; |
83 bool SetColorCorrection(const ui::DisplaySnapshot& output, | 91 bool SetColorCorrection(const ui::DisplaySnapshot& output, |
84 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, | 92 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, |
85 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, | 93 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, |
86 const std::vector<float>& correction_matrix) override; | 94 const std::vector<float>& correction_matrix) override; |
87 void AddObserver(ui::NativeDisplayObserver* observer) override; | 95 void AddObserver(ui::NativeDisplayObserver* observer) override; |
88 void RemoveObserver(ui::NativeDisplayObserver* observer) override; | 96 void RemoveObserver(ui::NativeDisplayObserver* observer) override; |
89 FakeDisplayController* GetFakeDisplayController() override; | 97 FakeDisplayController* GetFakeDisplayController() override; |
90 | 98 |
91 protected: | 99 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 | 100 // Sets initial display snapshots from command line flag. Returns true if |
98 // command line flag was provided. | 101 // command line flag was provided. |
99 bool InitFromCommandLine(); | 102 bool InitFromCommandLine(); |
100 | 103 |
101 // Updates observers when display configuration has changed. Will not update | 104 // Updates observers when display configuration has changed. Will not update |
102 // until after |Initialize()| has been called. | 105 // until after |Initialize()| has been called. |
103 void OnConfigurationChanged(); | 106 void OnConfigurationChanged(); |
104 | 107 |
105 private: | 108 private: |
106 base::ObserverList<ui::NativeDisplayObserver> observers_; | 109 base::ObserverList<ui::NativeDisplayObserver> observers_; |
107 std::vector<std::unique_ptr<ui::DisplaySnapshot>> displays_; | 110 std::vector<std::unique_ptr<ui::DisplaySnapshot>> displays_; |
108 | 111 |
109 // If |Initialize()| has been called. | 112 // If |Initialize()| has been called. |
110 bool initialized_ = false; | 113 bool initialized_ = false; |
111 | 114 |
112 // The next available display id. | 115 // The next available display id. |
113 uint8_t next_display_id_ = 0; | 116 uint8_t next_display_id_ = 0; |
114 | 117 |
115 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); | 118 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate); |
116 }; | 119 }; |
117 | 120 |
118 } // namespace display | 121 } // namespace display |
119 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ | 122 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_ |
OLD | NEW |