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

Side by Side Diff: ui/display/chromeos/x11/native_display_delegate_x11.h

Issue 2540313002: Split //ui/display and create //ui/display/manager. (Closed)
Patch Set: Cleanup export header. Created 4 years 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 2014 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_CHROMEOS_X11_NATIVE_DISPLAY_DELEGATE_X11_H_
6 #define UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_DELEGATE_X11_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <memory>
12 #include <set>
13 #include <vector>
14
15 #include "base/compiler_specific.h"
16 #include "base/event_types.h"
17 #include "base/macros.h"
18 #include "base/memory/scoped_vector.h"
19 #include "base/observer_list.h"
20 #include "ui/display/display_export.h"
21 #include "ui/display/types/native_display_delegate.h"
22 #include "ui/gfx/geometry/point.h"
23 #include "ui/gfx/geometry/size.h"
24 #include "ui/gfx/x/x11_types.h"
25
26 // Forward declarations for Xlib and Xrandr.
27 // This is so unused X definitions don't pollute the namespace.
28 typedef XID RROutput;
29 typedef XID RRCrtc;
30 typedef XID RRMode;
31 typedef XID _Window;
32
33 struct _XRROutputInfo;
34 typedef _XRROutputInfo XRROutputInfo;
35 struct _XRRScreenResources;
36 typedef _XRRScreenResources XRRScreenResources;
37 struct _XRRCrtcGamma;
38 typedef _XRRCrtcGamma XRRCrtcGamma;
39
40 extern "C" {
41 void XRRFreeScreenResources(XRRScreenResources* resources);
42 }
43
44 namespace ui {
45
46 class DisplayModeX11;
47 class DisplaySnapshotX11;
48 class NativeDisplayEventDispatcherX11;
49
50 class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate {
51 public:
52 // Helper class that allows NativeDisplayEventDispatcherX11 and
53 // NativeDisplayDelegateX11::PlatformEventObserverX11 to interact with this
54 // class or with mocks in tests.
55 class HelperDelegate {
56 public:
57 virtual ~HelperDelegate() {}
58
59 // Tells XRandR to update its configuration in response to |event|, an
60 // RRScreenChangeNotify event.
61 virtual void UpdateXRandRConfiguration(const base::NativeEvent& event) = 0;
62
63 // Returns the list of current outputs. This is used to discard duplicate
64 // events.
65 virtual const std::vector<DisplaySnapshot*>& GetCachedDisplays() const = 0;
66
67 // Notify |observers_| that a change in configuration has occurred.
68 virtual void NotifyDisplayObservers() = 0;
69 };
70
71 NativeDisplayDelegateX11();
72 ~NativeDisplayDelegateX11() override;
73
74 // NativeDisplayDelegate overrides:
75 void Initialize() override;
76 void GrabServer() override;
77 void UngrabServer() override;
78 void TakeDisplayControl(const DisplayControlCallback& callback) override;
79 void RelinquishDisplayControl(
80 const DisplayControlCallback& callback) override;
81 void SyncWithServer() override;
82 void SetBackgroundColor(uint32_t color_argb) override;
83 void ForceDPMSOn() override;
84 void GetDisplays(const GetDisplaysCallback& callback) override;
85 void AddMode(const DisplaySnapshot& output, const DisplayMode* mode) override;
86 void Configure(const DisplaySnapshot& output,
87 const DisplayMode* mode,
88 const gfx::Point& origin,
89 const ConfigureCallback& callback) override;
90 void CreateFrameBuffer(const gfx::Size& size) override;
91 void GetHDCPState(const DisplaySnapshot& output,
92 const GetHDCPStateCallback& callback) override;
93 void SetHDCPState(const DisplaySnapshot& output,
94 HDCPState state,
95 const SetHDCPStateCallback& callback) override;
96 std::vector<ColorCalibrationProfile> GetAvailableColorCalibrationProfiles(
97 const DisplaySnapshot& output) override;
98 bool SetColorCalibrationProfile(const DisplaySnapshot& output,
99 ColorCalibrationProfile new_profile) override;
100 bool SetColorCorrection(const ui::DisplaySnapshot& output,
101 const std::vector<GammaRampRGBEntry>& degamma_lut,
102 const std::vector<GammaRampRGBEntry>& gamma_lut,
103 const std::vector<float>& correction_matrix) override;
104 void AddObserver(NativeDisplayObserver* observer) override;
105 void RemoveObserver(NativeDisplayObserver* observer) override;
106 display::FakeDisplayController* GetFakeDisplayController() override;
107
108 private:
109 class HelperDelegateX11;
110
111 // Parses all the modes made available by |screen_|.
112 void InitModes();
113
114 // Helper method for GetOutputs() that returns an OutputSnapshot struct based
115 // on the passed-in information.
116 DisplaySnapshotX11* InitDisplaySnapshot(RROutput id,
117 XRROutputInfo* info,
118 std::set<RRCrtc>* last_used_crtcs,
119 int index);
120
121 // Destroys unused CRTCs.
122 void DestroyUnusedCrtcs();
123
124 // Parks used CRTCs in a way which allows a framebuffer resize. This is faster
125 // than turning them off, resizing, then turning them back on.
126 // |min_screen_size| represent the smallest size between the current
127 // framebuffer size and the requested framebuffer size.
128 void UpdateCrtcsForNewFramebuffer(const gfx::Size& min_screen_size);
129
130 bool ConfigureCrtc(RRCrtc crtc, RRMode mode, RROutput output, int x, int y);
131
132 // Helper functions that perform the actual HDCP requests.
133 bool GetHDCPState(const DisplaySnapshot& output, HDCPState* state);
134 bool SetHDCPState(const DisplaySnapshot& output, HDCPState state);
135
136 // Returns whether |id| is configured to preserve aspect when scaling.
137 bool IsOutputAspectPreservingScaling(RROutput id);
138
139 // Creates the gamma ramp for |new_profile|, or NULL if it doesn't exist.
140 // The caller should take the ownership.
141 XRRCrtcGamma* CreateGammaRampForProfile(
142 const DisplaySnapshotX11& x11_output,
143 ColorCalibrationProfile new_profile);
144
145 void DrawBackground();
146
147 XDisplay* display_;
148 _Window window_;
149
150 // Initialized when the server is grabbed and freed when it's ungrabbed.
151 gfx::XScopedPtr<
152 XRRScreenResources,
153 gfx::XObjectDeleter<XRRScreenResources, void, XRRFreeScreenResources>>
154 screen_;
155
156 std::map<RRMode, std::unique_ptr<DisplayModeX11>> modes_;
157
158 // Every time GetOutputs() is called we cache the updated list of outputs in
159 // |cached_outputs_| so that we can check for duplicate events rather than
160 // propagate them.
161 ScopedVector<DisplaySnapshot> cached_outputs_;
162
163 std::unique_ptr<HelperDelegate> helper_delegate_;
164
165 // Processes X11 display events associated with the root window and notifies
166 // |observers_| when a display change has occurred.
167 std::unique_ptr<NativeDisplayEventDispatcherX11> platform_event_dispatcher_;
168
169 // List of observers waiting for display configuration change events.
170 base::ObserverList<NativeDisplayObserver> observers_;
171
172 // A background color used during boot time + multi displays.
173 uint32_t background_color_argb_;
174
175 DISALLOW_COPY_AND_ASSIGN(NativeDisplayDelegateX11);
176 };
177
178 } // namespace ui
179
180 #endif // UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_DELEGATE_X11_H_
OLDNEW
« no previous file with comments | « ui/display/chromeos/x11/display_util_x11_unittest.cc ('k') | ui/display/chromeos/x11/native_display_delegate_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698