Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: ui/display/fake_display_snapshot.h

Issue 2395873002: Add more options to --screen-config flag. (Closed)
Patch Set: Small fixes after once over. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SNAPSHOT_H_ 5 #ifndef UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_
6 #define UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_ 6 #define UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 20 matching lines...) Expand all
31 ~Builder(); 31 ~Builder();
32 32
33 // Builds new FakeDisplaySnapshot. At the very minimum you must set id and 33 // Builds new FakeDisplaySnapshot. At the very minimum you must set id and
34 // native display mode before building or it will fail. 34 // native display mode before building or it will fail.
35 std::unique_ptr<FakeDisplaySnapshot> Build(); 35 std::unique_ptr<FakeDisplaySnapshot> Build();
36 36
37 Builder& SetId(int64_t id); 37 Builder& SetId(int64_t id);
38 // Adds display mode with |size| and set as native mode. If a display mode 38 // Adds display mode with |size| and set as native mode. If a display mode
39 // with |size| already exists then it will be reused. 39 // with |size| already exists then it will be reused.
40 Builder& SetNativeMode(const gfx::Size& size); 40 Builder& SetNativeMode(const gfx::Size& size);
41 // Adds display mode and set as native mode. If an existing display mode is
42 // equivalent to |mode| it will be set as native mode instead.
43 Builder& SetNativeMode(std::unique_ptr<ui::DisplayMode> mode);
41 // Adds display mode with |size| and set as current mode. If a display mode 44 // Adds display mode with |size| and set as current mode. If a display mode
42 // with |size| already exists then it will be reused. 45 // with |size| already exists then it will be reused.
43 Builder& SetCurrentMode(const gfx::Size& size); 46 Builder& SetCurrentMode(const gfx::Size& size);
44 // Adds display mode with |size| if it doesn't exist. 47 // Adds display mode and set as current mode. If an existing display mode is
48 // equivalent to |mode| it will be set as current mode instead.
49 Builder& SetCurrentMode(std::unique_ptr<ui::DisplayMode> mode);
50 // Adds display mode with |size| if necessary. If a display mode with |size|
51 // already exists then it will be reused.
45 Builder& AddMode(const gfx::Size& size); 52 Builder& AddMode(const gfx::Size& size);
53 // Adds |mode| if necessary. If an existing display mode is equivalent to
54 // |mode| it will not be added.
55 Builder& AddMode(std::unique_ptr<ui::DisplayMode> mode);
46 Builder& SetOrigin(const gfx::Point& origin); 56 Builder& SetOrigin(const gfx::Point& origin);
47 Builder& SetType(ui::DisplayConnectionType type); 57 Builder& SetType(ui::DisplayConnectionType type);
48 Builder& SetIsAspectPerservingScaling(bool is_aspect_preserving_scaling); 58 Builder& SetIsAspectPerservingScaling(bool is_aspect_preserving_scaling);
49 Builder& SetHasOverscan(bool has_overscan); 59 Builder& SetHasOverscan(bool has_overscan);
50 Builder& SetHasColorCorrectionMatrix(bool val); 60 Builder& SetHasColorCorrectionMatrix(bool val);
51 Builder& SetName(const std::string& name); 61 Builder& SetName(const std::string& name);
52 Builder& SetProductId(int64_t product_id); 62 Builder& SetProductId(int64_t product_id);
53 // Sets physical_size so that the screen has the specified DPI using the 63 // Sets physical_size so that the screen has the specified DPI using the
54 // native resolution. 64 // native resolution.
55 Builder& SetDPI(int dpi); 65 Builder& SetDPI(int dpi);
56 // Sets physical_size for low DPI display. 66 // Sets physical_size for low DPI display.
57 Builder& SetLowDPI(); 67 Builder& SetLowDPI();
58 // Sets physical_size for high DPI display. 68 // Sets physical_size for high DPI display.
59 Builder& SetHighDPI(); 69 Builder& SetHighDPI();
60 70
61 private: 71 private:
62 // Returns a display mode with |size|. If there is no existing mode, insert 72 // Returns a display mode with |size|. If there is no existing mode, insert
63 // a display mode with |size|. 73 // a display mode with |size| first.
64 const ui::DisplayMode* AddOrFindDisplayMode(const gfx::Size& size); 74 const ui::DisplayMode* AddOrFindDisplayMode(const gfx::Size& size);
75 // Returns a display mode equivalent to |mode|. If there is no equivalent
76 // display mode, insert |mode| first.
77 const ui::DisplayMode* AddOrFindDisplayMode(
78 std::unique_ptr<ui::DisplayMode> mode);
65 79
66 int64_t id_ = Display::kInvalidDisplayID; 80 int64_t id_ = Display::kInvalidDisplayID;
67 gfx::Point origin_; 81 gfx::Point origin_;
68 float dpi_ = 96.0; 82 float dpi_ = 96.0;
69 ui::DisplayConnectionType type_ = ui::DISPLAY_CONNECTION_TYPE_UNKNOWN; 83 ui::DisplayConnectionType type_ = ui::DISPLAY_CONNECTION_TYPE_UNKNOWN;
70 bool is_aspect_preserving_scaling_ = false; 84 bool is_aspect_preserving_scaling_ = false;
71 bool has_overscan_ = false; 85 bool has_overscan_ = false;
72 bool has_color_correction_matrix_ = false; 86 bool has_color_correction_matrix_ = false;
73 std::string name_ = "Fake Display"; 87 std::string name_ = "Fake Display";
74 int64_t product_id_ = DisplaySnapshot::kInvalidProductID; 88 int64_t product_id_ = DisplaySnapshot::kInvalidProductID;
75 std::vector<std::unique_ptr<const ui::DisplayMode>> modes_; 89 DisplayModeList modes_;
76 const ui::DisplayMode* current_mode_ = nullptr; 90 const ui::DisplayMode* current_mode_ = nullptr;
77 const ui::DisplayMode* native_mode_ = nullptr; 91 const ui::DisplayMode* native_mode_ = nullptr;
78 92
79 DISALLOW_COPY_AND_ASSIGN(Builder); 93 DISALLOW_COPY_AND_ASSIGN(Builder);
80 }; 94 };
81 95
82 FakeDisplaySnapshot(int64_t display_id, 96 FakeDisplaySnapshot(int64_t display_id,
83 const gfx::Point& origin, 97 const gfx::Point& origin,
84 const gfx::Size& physical_size, 98 const gfx::Size& physical_size,
85 ui::DisplayConnectionType type, 99 ui::DisplayConnectionType type,
86 bool is_aspect_preserving_scaling, 100 bool is_aspect_preserving_scaling,
87 bool has_overscan, 101 bool has_overscan,
88 bool has_color_correction_matrix, 102 bool has_color_correction_matrix,
89 std::string display_name, 103 std::string display_name,
90 int64_t product_id, 104 int64_t product_id,
91 std::vector<std::unique_ptr<const ui::DisplayMode>> modes, 105 DisplayModeList modes,
92 const ui::DisplayMode* current_mode, 106 const ui::DisplayMode* current_mode,
93 const ui::DisplayMode* native_mode); 107 const ui::DisplayMode* native_mode);
94 ~FakeDisplaySnapshot() override; 108 ~FakeDisplaySnapshot() override;
95 109
110 // Creates a display snapshot from the provided |spec| string. Returns null if
Daniel Erat 2016/10/05 21:09:46 mention the header where the spec format is descri
kylechar 2016/10/07 16:14:43 Done.
111 // |spec| is invalid.
112 static std::unique_ptr<ui::DisplaySnapshot> CreateFromSpec(
113 int64_t id,
114 const std::string& spec);
115
96 // DisplaySnapshot: 116 // DisplaySnapshot:
97 std::string ToString() const override; 117 std::string ToString() const override;
98 118
99 private: 119 private:
100 DISALLOW_COPY_AND_ASSIGN(FakeDisplaySnapshot); 120 DISALLOW_COPY_AND_ASSIGN(FakeDisplaySnapshot);
101 }; 121 };
102 122
103 } // namespace display 123 } // namespace display
104 124
105 #endif // UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_ 125 #endif // UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698