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

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

Issue 821023003: [Ozone-DRI] Listen for swap events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-swap
Patch Set: Added comment Created 5 years, 11 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/ozone/platform/dri/dri_surface_unittest.cc ('k') | ui/ozone/platform/dri/dri_wrapper.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 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_DRI_WRAPPER_H_ 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_
6 #define UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ 6 #define UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/threading/thread.h"
13 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/rect_f.h" 17 #include "ui/gfx/geometry/rect_f.h"
15 #include "ui/gfx/overlay_transform.h" 18 #include "ui/gfx/overlay_transform.h"
16 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" 19 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h"
17 #include "ui/ozone/platform/dri/scoped_drm_types.h" 20 #include "ui/ozone/platform/dri/scoped_drm_types.h"
18 21
19 typedef struct _drmEventContext drmEventContext; 22 typedef struct _drmEventContext drmEventContext;
20 typedef struct _drmModeModeInfo drmModeModeInfo; 23 typedef struct _drmModeModeInfo drmModeModeInfo;
21 24
22 struct SkImageInfo; 25 struct SkImageInfo;
23 26
24 namespace ui { 27 namespace ui {
25 28
26 class HardwareDisplayPlaneManager; 29 class HardwareDisplayPlaneManager;
27 30
28 // Wraps DRM calls into a nice interface. Used to provide different 31 // Wraps DRM calls into a nice interface. Used to provide different
29 // implementations of the DRM calls. For the actual implementation the DRM API 32 // implementations of the DRM calls. For the actual implementation the DRM API
30 // would be called. In unit tests this interface would be stubbed. 33 // would be called. In unit tests this interface would be stubbed.
31 class DriWrapper { 34 class DriWrapper {
32 public: 35 public:
33 DriWrapper(const char* device_path); 36 typedef base::Callback<void(unsigned int /* frame */,
37 unsigned int /* seconds */,
38 unsigned int /* useconds */)> PageFlipCallback;
39
40 DriWrapper(const char* device_path, bool software_mode);
34 virtual ~DriWrapper(); 41 virtual ~DriWrapper();
35 42
36 // Open device. 43 // Open device.
37 virtual void Initialize(); 44 virtual void Initialize();
38 45
39 // Get the CRTC state. This is generally used to save state before using the 46 // Get the CRTC state. This is generally used to save state before using the
40 // CRTC. When the user finishes using the CRTC, the user should restore the 47 // CRTC. When the user finishes using the CRTC, the user should restore the
41 // CRTC to it's initial state. Use |SetCrtc| to restore the state. 48 // CRTC to it's initial state. Use |SetCrtc| to restore the state.
42 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id); 49 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id);
43 50
(...skipping 28 matching lines...) Expand all
72 79
73 // Deregister the given |framebuffer|. 80 // Deregister the given |framebuffer|.
74 virtual bool RemoveFramebuffer(uint32_t framebuffer); 81 virtual bool RemoveFramebuffer(uint32_t framebuffer);
75 82
76 // Get the DRM details associated with |framebuffer|. 83 // Get the DRM details associated with |framebuffer|.
77 virtual ScopedDrmFramebufferPtr GetFramebuffer(uint32_t framebuffer); 84 virtual ScopedDrmFramebufferPtr GetFramebuffer(uint32_t framebuffer);
78 85
79 // Schedules a pageflip for CRTC |crtc_id|. This function will return 86 // Schedules a pageflip for CRTC |crtc_id|. This function will return
80 // immediately. Upon completion of the pageflip event, the CRTC will be 87 // immediately. Upon completion of the pageflip event, the CRTC will be
81 // displaying the buffer with ID |framebuffer| and will have a DRM event 88 // displaying the buffer with ID |framebuffer| and will have a DRM event
82 // queued on |fd_|. |data| is a generic pointer to some information the user 89 // queued on |fd_|.
83 // will receive when processing the pageflip event. 90 virtual bool PageFlip(uint32_t crtc_id,
84 virtual bool PageFlip(uint32_t crtc_id, uint32_t framebuffer, void* data); 91 uint32_t framebuffer,
92 const PageFlipCallback& callback);
85 93
86 // Schedule an overlay to be show during the page flip for CRTC |crtc_id|. 94 // Schedule an overlay to be show during the page flip for CRTC |crtc_id|.
87 // |source| location from |framebuffer| will be shown on overlay 95 // |source| location from |framebuffer| will be shown on overlay
88 // |overlay_plane|, in the bounds specified by |location| on the screen. 96 // |overlay_plane|, in the bounds specified by |location| on the screen.
89 virtual bool PageFlipOverlay(uint32_t crtc_id, 97 virtual bool PageFlipOverlay(uint32_t crtc_id,
90 uint32_t framebuffer, 98 uint32_t framebuffer,
91 const gfx::Rect& location, 99 const gfx::Rect& location,
92 const gfx::Rect& source, 100 const gfx::Rect& source,
93 int overlay_plane); 101 int overlay_plane);
94 102
(...skipping 23 matching lines...) Expand all
118 // Set the cursor to be displayed in CRTC |crtc_id|. (width, height) is the 126 // Set the cursor to be displayed in CRTC |crtc_id|. (width, height) is the
119 // cursor size pointed by |handle|. 127 // cursor size pointed by |handle|.
120 virtual bool SetCursor(uint32_t crtc_id, 128 virtual bool SetCursor(uint32_t crtc_id,
121 uint32_t handle, 129 uint32_t handle,
122 const gfx::Size& size); 130 const gfx::Size& size);
123 131
124 132
125 // Move the cursor on CRTC |crtc_id| to (x, y); 133 // Move the cursor on CRTC |crtc_id| to (x, y);
126 virtual bool MoveCursor(uint32_t crtc_id, const gfx::Point& point); 134 virtual bool MoveCursor(uint32_t crtc_id, const gfx::Point& point);
127 135
128 virtual void HandleEvent(drmEventContext& event);
129
130 virtual bool CreateDumbBuffer(const SkImageInfo& info, 136 virtual bool CreateDumbBuffer(const SkImageInfo& info,
131 uint32_t* handle, 137 uint32_t* handle,
132 uint32_t* stride, 138 uint32_t* stride,
133 void** pixels); 139 void** pixels);
134 140
135 virtual void DestroyDumbBuffer(const SkImageInfo& info, 141 virtual void DestroyDumbBuffer(const SkImageInfo& info,
136 uint32_t handle, 142 uint32_t handle,
137 uint32_t stride, 143 uint32_t stride,
138 void* pixels); 144 void* pixels);
139 145
140 // Drm master related 146 // Drm master related
141 virtual bool SetMaster(); 147 virtual bool SetMaster();
142 virtual bool DropMaster(); 148 virtual bool DropMaster();
143 149
144 int get_fd() const { return fd_; } 150 int get_fd() const { return fd_; }
145 151
146 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } 152 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); }
147 153
148 protected: 154 protected:
155 // Responsible for late initialization of the IO thread. This needs to happen
156 // after the sandbox is up, thus the late initialization.
157 virtual void InitializeIOWatcher();
158
149 // The file descriptor associated with this wrapper. All DRM operations will 159 // The file descriptor associated with this wrapper. All DRM operations will
150 // be performed using this FD. 160 // be performed using this FD.
161 // TODO(dnicoara) Make this a base::File
151 int fd_; 162 int fd_;
152 163
153 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; 164 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_;
154 165
166 // If we're running in software mode this is true. In software mode we can't
167 // use the async page flip callbacks, so we need to block until the kernel
168 // responds to the page flip.
169 bool software_mode_;
170
155 private: 171 private:
172 class IOWatcher;
173
156 // Path to DRM device. 174 // Path to DRM device.
157 const char* device_path_; 175 const char* device_path_;
158 176
177 // Helper thread to perform IO listener operations.
178 // TODO(dnicoara) This should really be supported by the main thread.
179 // Alternatively we should have a way to access the IO thread's task runner.
180 base::Thread io_thread_;
181
182 // Watcher for |fd_| listening for page flip events.
183 scoped_refptr<IOWatcher> watcher_;
184
159 DISALLOW_COPY_AND_ASSIGN(DriWrapper); 185 DISALLOW_COPY_AND_ASSIGN(DriWrapper);
160 }; 186 };
161 187
162 } // namespace ui 188 } // namespace ui
163 189
164 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ 190 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/dri_surface_unittest.cc ('k') | ui/ozone/platform/dri/dri_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698