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

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

Issue 2340383002: Add FakeDisplaySnapshot builder and related changes. (Closed)
Patch Set: Fixes for comments. Created 4 years, 3 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
« no previous file with comments | « ui/display/fake_display_delegate.cc ('k') | ui/display/fake_display_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #include <string> 11 #include <string>
12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "ui/display/display.h"
14 #include "ui/display/display_export.h" 16 #include "ui/display/display_export.h"
15 #include "ui/display/types/display_mode.h" 17 #include "ui/display/types/display_mode.h"
16 #include "ui/display/types/display_snapshot.h" 18 #include "ui/display/types/display_snapshot.h"
19 #include "ui/gfx/geometry/point.h"
17 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
18 21
19 namespace display { 22 namespace display {
20 23
21 // A display snapshot that doesn't correspond to a physical display, used when 24 // A display snapshot that doesn't correspond to a physical display, used when
22 // running off device. 25 // running off device.
23 class FakeDisplaySnapshot : public ui::DisplaySnapshot { 26 class DISPLAY_EXPORT FakeDisplaySnapshot : public ui::DisplaySnapshot {
24 public: 27 public:
25 // TODO(kylechar): Add a builder. 28 class Builder {
29 public:
30 Builder();
31 ~Builder();
32
33 // Builds new FakeDisplaySnapshot. At the very minimum you must set id and
34 // native display mode before building or it will fail.
35 std::unique_ptr<FakeDisplaySnapshot> Build();
36
37 Builder& SetId(int64_t id);
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.
40 Builder& SetNativeMode(const gfx::Size& size);
41 // Adds display mode with |size| and set as current mode. If a display mode
42 // with |size| already exists then it will be reused.
43 Builder& SetCurrentMode(const gfx::Size& size);
44 // Adds display mode with |size| if it doesn't exist.
45 Builder& AddMode(const gfx::Size& size);
46 Builder& SetOrigin(const gfx::Point& origin);
47 Builder& SetType(ui::DisplayConnectionType type);
48 Builder& SetIsAspectPerservingScaling(bool is_aspect_preserving_scaling);
49 Builder& SetHasOverscan(bool has_overscan);
50 Builder& SetHasColorCorrectionMatrix(bool val);
51 Builder& SetName(const std::string& name);
52 Builder& SetProductId(int64_t product_id);
53 // Sets physical_size so that the screen has the specified DPI using the
54 // native resolution.
55 Builder& SetDPI(int dpi);
56 // Sets physical_size for low DPI display.
57 Builder& SetLowDPI();
58 // Sets physical_size for high DPI display.
59 Builder& SetHighDPI();
60
61 private:
62 // Returns a display mode with |size|. If there is no existing mode, insert
63 // a display mode with |size|.
64 const ui::DisplayMode* AddOrFindDisplayMode(const gfx::Size& size);
65
66 int64_t id_ = Display::kInvalidDisplayID;
67 gfx::Point origin_;
68 float dpi_ = 96.0;
69 ui::DisplayConnectionType type_ = ui::DISPLAY_CONNECTION_TYPE_UNKNOWN;
70 bool is_aspect_preserving_scaling_ = false;
71 bool has_overscan_ = false;
72 bool has_color_correction_matrix_ = false;
73 std::string name_ = "Fake Display";
74 int64_t product_id_ = DisplaySnapshot::kInvalidProductID;
75 std::vector<std::unique_ptr<const ui::DisplayMode>> modes_;
76 const ui::DisplayMode* current_mode_ = nullptr;
77 const ui::DisplayMode* native_mode_ = nullptr;
78
79 DISALLOW_COPY_AND_ASSIGN(Builder);
80 };
26 81
27 FakeDisplaySnapshot(int64_t display_id, 82 FakeDisplaySnapshot(int64_t display_id,
28 const gfx::Size& display_size, 83 const gfx::Point& origin,
84 const gfx::Size& physical_size,
29 ui::DisplayConnectionType type, 85 ui::DisplayConnectionType type,
30 std::string name); 86 bool is_aspect_preserving_scaling,
87 bool has_overscan,
88 bool has_color_correction_matrix,
89 std::string display_name,
90 int64_t product_id,
91 std::vector<std::unique_ptr<const ui::DisplayMode>> modes,
92 const ui::DisplayMode* current_mode,
93 const ui::DisplayMode* native_mode);
31 ~FakeDisplaySnapshot() override; 94 ~FakeDisplaySnapshot() override;
32 95
33 // DisplaySnapshot: 96 // DisplaySnapshot:
34 std::string ToString() const override; 97 std::string ToString() const override;
35 98
36 private: 99 private:
37 DISALLOW_COPY_AND_ASSIGN(FakeDisplaySnapshot); 100 DISALLOW_COPY_AND_ASSIGN(FakeDisplaySnapshot);
38 }; 101 };
39 102
40 } // namespace display 103 } // namespace display
41 104
42 #endif // UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_ 105 #endif // UI_DISPLAY_FAKE_DISPLAY_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « ui/display/fake_display_delegate.cc ('k') | ui/display/fake_display_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698