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

Side by Side Diff: ui/ozone/platform/dri/hardware_display_controller.h

Issue 393233005: [Ozone-DRI] Convert HardwareDisplayController to use scanout buffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ 5 #ifndef UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_
6 #define UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ 6 #define UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <xf86drmMode.h> 10 #include <xf86drmMode.h>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "ui/ozone/platform/dri/dri_wrapper.h" 16 #include "ui/ozone/platform/dri/dri_wrapper.h"
17 17
18 namespace gfx { 18 namespace gfx {
19 class Point; 19 class Point;
20 } 20 }
21 21
22 namespace ui { 22 namespace ui {
23 23
24 class NativePixmap;
25 class ScanoutBuffer; 24 class ScanoutBuffer;
26 class ScanoutSurface;
27 25
28 typedef std::vector<scoped_refptr<NativePixmap> > NativePixmapList; 26 struct OverlayPlane {
27 // Simpler constructor for the primary plane.
28 explicit OverlayPlane(scoped_refptr<ScanoutBuffer> buffer);
29 29
30 struct OzoneOverlayPlane { 30 OverlayPlane(scoped_refptr<ScanoutBuffer> buffer,
31 OzoneOverlayPlane(ScanoutSurface* scanout, 31 int z_order,
32 int z_order, 32 gfx::OverlayTransform plane_transform,
33 gfx::OverlayTransform plane_transform, 33 const gfx::Rect& display_bounds,
34 const gfx::Rect& display_bounds, 34 const gfx::RectF& crop_rect);
35 const gfx::RectF& crop_rect);
36 35
37 ScanoutSurface* scanout; 36 ~OverlayPlane();
37
38 scoped_refptr<ScanoutBuffer> buffer;
38 int z_order; 39 int z_order;
39 gfx::OverlayTransform plane_transform; 40 gfx::OverlayTransform plane_transform;
40 gfx::Rect display_bounds; 41 gfx::Rect display_bounds;
41 gfx::RectF crop_rect; 42 gfx::RectF crop_rect;
42 int overlay_plane; 43 int overlay_plane;
43 }; 44 };
44 45
46 typedef std::vector<OverlayPlane> OverlayPlaneList;
47
45 // The HDCOz will handle modesettings and scannout operations for hardware 48 // The HDCOz will handle modesettings and scannout operations for hardware
46 // devices. 49 // devices.
47 // 50 //
48 // In the DRM world there are 3 components that need to be paired up to be able 51 // In the DRM world there are 3 components that need to be paired up to be able
49 // to display an image to the monitor: CRTC (cathode ray tube controller), 52 // to display an image to the monitor: CRTC (cathode ray tube controller),
50 // encoder and connector. The CRTC determines which framebuffer to read, when 53 // encoder and connector. The CRTC determines which framebuffer to read, when
51 // to scanout and where to scanout. Encoders converts the stream from the CRTC 54 // to scanout and where to scanout. Encoders converts the stream from the CRTC
52 // to the appropriate format for the connector. The connector is the physical 55 // to the appropriate format for the connector. The connector is the physical
53 // connection that monitors connect to. 56 // connection that monitors connect to.
54 // 57 //
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // connectors active if some use the same CRTC to mirror the display. 101 // connectors active if some use the same CRTC to mirror the display.
99 class HardwareDisplayController 102 class HardwareDisplayController
100 : public base::SupportsWeakPtr<HardwareDisplayController> { 103 : public base::SupportsWeakPtr<HardwareDisplayController> {
101 public: 104 public:
102 HardwareDisplayController(DriWrapper* drm, 105 HardwareDisplayController(DriWrapper* drm,
103 uint32_t connector_id, 106 uint32_t connector_id,
104 uint32_t crtc_id); 107 uint32_t crtc_id);
105 108
106 ~HardwareDisplayController(); 109 ~HardwareDisplayController();
107 110
108 // Associate the HDCO with a surface implementation and initialize it. 111 // Performs the initial CRTC configuration. If successful, it will display the
109 bool BindSurfaceToController(scoped_ptr<ScanoutSurface> surface, 112 // framebuffer for |primary| with |mode|.
110 drmModeModeInfo mode); 113 bool Modeset(const OverlayPlane& primary,
111 114 drmModeModeInfo mode);
112 void UnbindSurfaceFromController();
113 115
114 // Reconfigures the CRTC with the current surface and mode. 116 // Reconfigures the CRTC with the current surface and mode.
115 bool Enable(); 117 bool Enable();
116 118
117 // Disables the CRTC. 119 // Disables the CRTC.
118 void Disable(); 120 void Disable();
119 121
120 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync 122 // Schedules the |overlays|' framebuffers to be displayed on the next vsync
121 // event. The event will be posted on the graphics card file descriptor |fd_| 123 // event. The event will be posted on the graphics card file descriptor |fd_|
122 // and it can be read and processed by |drmHandleEvent|. That function can 124 // and it can be read and processed by |drmHandleEvent|. That function can
123 // define the callback for the page flip event. A generic data argument will 125 // define the callback for the page flip event. A generic data argument will
124 // be presented to the callback. We use that argument to pass in the HDCO 126 // be presented to the callback. We use that argument to pass in the HDCO
125 // object the event belongs to. 127 // object the event belongs to.
126 // 128 //
127 // Between this call and the callback, the framebuffer used in this call 129 // Between this call and the callback, the framebuffers used in this call
128 // should not be modified in any way as it would cause screen tearing if the 130 // should not be modified in any way as it would cause screen tearing if the
129 // hardware performed the flip. Note that the frontbuffer should also not 131 // hardware performed the flip. Note that the frontbuffer should also not
130 // be modified as it could still be displayed. 132 // be modified as it could still be displayed.
131 // 133 //
132 // Note that this function does not block. Also, this function should not be 134 // Note that this function does not block. Also, this function should not be
133 // called again before the page flip occurrs. 135 // called again before the page flip occurrs.
134 // 136 //
135 // Returns true if the page flip was successfully registered, false otherwise. 137 // Returns true if the page flip was successfully registered, false otherwise.
136 bool SchedulePageFlip(const std::vector<OzoneOverlayPlane>& overlays, 138 bool SchedulePageFlip(const OverlayPlaneList& overlays);
137 NativePixmapList* references);
138 139
139 // TODO(dnicoara) This should be on the MessageLoop when Ozone can have 140 // TODO(dnicoara) This should be on the MessageLoop when Ozone can have
140 // BeginFrame can be triggered explicitly by Ozone. 141 // BeginFrame can be triggered explicitly by Ozone.
141 void WaitForPageFlipEvent(); 142 void WaitForPageFlipEvent();
142 143
143 // Called when the page flip event occurred. The event is provided by the 144 // Called when the page flip event occurred. The event is provided by the
144 // kernel when a VBlank event finished. This allows the controller to 145 // kernel when a VBlank event finished. This allows the controller to
145 // update internal state and propagate the update to the surface. 146 // update internal state and propagate the update to the surface.
146 // The tuple (seconds, useconds) represents the event timestamp. |seconds| 147 // The tuple (seconds, useconds) represents the event timestamp. |seconds|
147 // represents the number of seconds while |useconds| represents the 148 // represents the number of seconds while |useconds| represents the
148 // microseconds (< 1 second) in the timestamp. 149 // microseconds (< 1 second) in the timestamp.
149 void OnPageFlipEvent(unsigned int frame, 150 void OnPageFlipEvent(unsigned int frame,
150 unsigned int seconds, 151 unsigned int seconds,
151 unsigned int useconds); 152 unsigned int useconds);
152 153
153 // Set the hardware cursor to show the contents of |surface|. 154 // Set the hardware cursor to show the contents of |surface|.
154 bool SetCursor(scoped_refptr<ScanoutBuffer> buffer); 155 bool SetCursor(scoped_refptr<ScanoutBuffer> buffer);
155 156
156 bool UnsetCursor(); 157 bool UnsetCursor();
157 158
158 // Moves the hardware cursor to |location|. 159 // Moves the hardware cursor to |location|.
159 bool MoveCursor(const gfx::Point& location); 160 bool MoveCursor(const gfx::Point& location);
160 161
161 const drmModeModeInfo& get_mode() const { return mode_; }; 162 const drmModeModeInfo& get_mode() const { return mode_; };
162 uint32_t connector_id() const { return connector_id_; } 163 uint32_t connector_id() const { return connector_id_; }
163 uint32_t crtc_id() const { return crtc_id_; } 164 uint32_t crtc_id() const { return crtc_id_; }
164 ScanoutSurface* surface() const {
165 return surface_.get();
166 };
167 165
168 uint64_t get_time_of_last_flip() const { 166 uint64_t get_time_of_last_flip() const {
169 return time_of_last_flip_; 167 return time_of_last_flip_;
170 }; 168 };
171 169
172 private: 170 private:
173 ScanoutSurface* GetPrimaryPlane( 171 OverlayPlaneList current_planes_;
174 const std::vector<OzoneOverlayPlane>& overlays); 172 OverlayPlaneList pending_planes_;
175
176 NativePixmapList current_overlay_references_;
177 173
178 // Object containing the connection to the graphics device and wraps the API 174 // Object containing the connection to the graphics device and wraps the API
179 // calls to control it. 175 // calls to control it.
180 DriWrapper* drm_; 176 DriWrapper* drm_;
181 177
182 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. 178 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors.
183 uint32_t connector_id_; 179 uint32_t connector_id_;
184 180
185 uint32_t crtc_id_; 181 uint32_t crtc_id_;
186 182
187 drmModeModeInfo mode_; 183 drmModeModeInfo mode_;
188 184
189 scoped_ptr<ScanoutSurface> surface_;
190
191 scoped_refptr<ScanoutBuffer> cursor_buffer_; 185 scoped_refptr<ScanoutBuffer> cursor_buffer_;
192 186
193 uint64_t time_of_last_flip_; 187 uint64_t time_of_last_flip_;
194 188
195 // Keeps track of the CRTC state. If a surface has been bound, then the value 189 // Keeps track of the CRTC state. If a surface has been bound, then the value
196 // is set to false. Otherwise it is true. 190 // is set to false. Otherwise it is true.
197 bool is_disabled_; 191 bool is_disabled_;
198 192
199 // Store the state of the CRTC before we took over. Used to restore the CRTC 193 // Store the state of the CRTC before we took over. Used to restore the CRTC
200 // once we no longer need it. 194 // once we no longer need it.
201 ScopedDrmCrtcPtr saved_crtc_; 195 ScopedDrmCrtcPtr saved_crtc_;
202 196
203 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); 197 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController);
204 }; 198 };
205 199
206 } // namespace ui 200 } // namespace ui
207 201
208 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ 202 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_surface_factory.cc ('k') | ui/ozone/platform/dri/hardware_display_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698