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

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

Issue 2324163002: Add FakeDisplayDelegate for off device usage. (Closed)
Patch Set: Rebase and remove some debug logging. 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_
6 #define UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/observer_list.h"
13 #include "ui/display/display_export.h"
14 #include "ui/display/fake_display_snapshot.h"
15 #include "ui/display/types/fake_display_controller.h"
16 #include "ui/display/types/native_display_delegate.h"
17
18 namespace display {
19
20 // A NativeDisplayDelegate implementation that manages fake displays. Fake
21 // 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 // 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 // configuration and display management code.
26 //
27 // The size and number of displays can controlled via --display-config=X
28 // command line flag with the format:
29 // HxW[,]
30 // H: display height in pixels
31 // W: display width in pixels
32 //
33 // Two 800x800 displays:
34 // --display-config=800x800,800x800
rjkroege 2016/09/15 00:52:46 This is a screen config yes? I'd like us to follow
kylechar 2016/09/15 17:31:55 sgtm, changed to --screen-config.
35 // One 1820x1080 display and one 400x400 display:
36 // --display-config=1920x1080,400x400
37 //
38 // FakeDisplayDelegate also implements FakeDisplayController which provides a
39 // way to change the display state at runtime.
40 class DISPLAY_EXPORT FakeDisplayDelegate : public ui::NativeDisplayDelegate,
41 public FakeDisplayController {
42 public:
43 FakeDisplayDelegate();
44 ~FakeDisplayDelegate() override;
45
46 // FakeDisplayController:
47 int64_t AddDisplay(const gfx::Size& display_size) override;
48 bool RemoveDisplay(int64_t display_id) override;
49
50 // NativeDisplayDelegate overrides:
51 void Initialize() override;
52 void GrabServer() override;
53 void UngrabServer() override;
54 void TakeDisplayControl(const ui::DisplayControlCallback& callback) override;
55 void RelinquishDisplayControl(
56 const ui::DisplayControlCallback& callback) override;
57 void SyncWithServer() override;
58 void SetBackgroundColor(uint32_t color_argb) override;
59 void ForceDPMSOn() override;
60 void GetDisplays(const ui::GetDisplaysCallback& callback) override;
61 void AddMode(const ui::DisplaySnapshot& output,
62 const ui::DisplayMode* mode) override;
63 void Configure(const ui::DisplaySnapshot& output,
64 const ui::DisplayMode* mode,
65 const gfx::Point& origin,
66 const ui::ConfigureCallback& callback) override;
67 void CreateFrameBuffer(const gfx::Size& size) override;
68 void GetHDCPState(const ui::DisplaySnapshot& output,
69 const ui::GetHDCPStateCallback& callback) override;
70 void SetHDCPState(const ui::DisplaySnapshot& output,
71 ui::HDCPState state,
72 const ui::SetHDCPStateCallback& callback) override;
73 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles(
74 const ui::DisplaySnapshot& output) override;
75 bool SetColorCalibrationProfile(
76 const ui::DisplaySnapshot& output,
77 ui::ColorCalibrationProfile new_profile) override;
78 bool SetColorCorrection(const ui::DisplaySnapshot& output,
79 const std::vector<ui::GammaRampRGBEntry>& degamma_lut,
80 const std::vector<ui::GammaRampRGBEntry>& gamma_lut,
81 const std::vector<float>& correction_matrix) override;
82 void AddObserver(ui::NativeDisplayObserver* observer) override;
83 void RemoveObserver(ui::NativeDisplayObserver* observer) override;
84 FakeDisplayController* GetFakeDisplayController() override;
85
86 protected:
87 // Initializes display snapshots from command line flags if provided.
88 void InitFromCommandLine();
89
90 // Updates observers when display configuration has changed. Will not update
91 // until after |Initialize()| has been called.
92 void OnConfigurationChanged();
93
94 private:
95 base::ObserverList<ui::NativeDisplayObserver> observers_;
96 std::vector<std::unique_ptr<FakeDisplaySnapshot>> displays_;
97
98 // If |Initialize()| has been called.
99 bool initialized_ = false;
100
101 // The next available display id.
102 uint8_t next_display_id_ = 0;
103
104 DISALLOW_COPY_AND_ASSIGN(FakeDisplayDelegate);
105 };
106
107 } // namespace display
108 #endif // UI_DISPLAY_FAKE_DISPLAY_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698