| OLD | NEW |
| 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/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/threading/thread.h" | |
| 16 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/gfx/geometry/rect_f.h" | 16 #include "ui/gfx/geometry/rect_f.h" |
| 18 #include "ui/gfx/overlay_transform.h" | 17 #include "ui/gfx/overlay_transform.h" |
| 19 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" | 18 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" |
| 20 #include "ui/ozone/platform/dri/scoped_drm_types.h" | 19 #include "ui/ozone/platform/dri/scoped_drm_types.h" |
| 21 | 20 |
| 22 typedef struct _drmEventContext drmEventContext; | 21 typedef struct _drmEventContext drmEventContext; |
| 23 typedef struct _drmModeModeInfo drmModeModeInfo; | 22 typedef struct _drmModeModeInfo drmModeModeInfo; |
| 24 | 23 |
| 25 struct SkImageInfo; | 24 struct SkImageInfo; |
| 26 | 25 |
| 26 namespace base { |
| 27 class SingleThreadTaskRunner; |
| 28 } // namespace base |
| 29 |
| 27 namespace ui { | 30 namespace ui { |
| 28 | 31 |
| 29 class HardwareDisplayPlaneManager; | 32 class HardwareDisplayPlaneManager; |
| 30 | 33 |
| 31 // Wraps DRM calls into a nice interface. Used to provide different | 34 // Wraps DRM calls into a nice interface. Used to provide different |
| 32 // implementations of the DRM calls. For the actual implementation the DRM API | 35 // implementations of the DRM calls. For the actual implementation the DRM API |
| 33 // would be called. In unit tests this interface would be stubbed. | 36 // would be called. In unit tests this interface would be stubbed. |
| 34 class DriWrapper { | 37 class DriWrapper { |
| 35 public: | 38 public: |
| 36 typedef base::Callback<void(unsigned int /* frame */, | 39 typedef base::Callback<void(unsigned int /* frame */, |
| 37 unsigned int /* seconds */, | 40 unsigned int /* seconds */, |
| 38 unsigned int /* useconds */)> PageFlipCallback; | 41 unsigned int /* useconds */)> PageFlipCallback; |
| 39 | 42 |
| 40 DriWrapper(const char* device_path, bool use_sync_flips); | 43 DriWrapper(const char* device_path); |
| 41 virtual ~DriWrapper(); | 44 virtual ~DriWrapper(); |
| 42 | 45 |
| 43 // Open device. | 46 // Open device. |
| 44 virtual void Initialize(); | 47 virtual void Initialize(); |
| 45 | 48 |
| 49 // |task_runner| will be used to asynchronously page flip. |
| 50 virtual void InitializeTaskRunner( |
| 51 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 52 |
| 46 // Get the CRTC state. This is generally used to save state before using the | 53 // Get the CRTC state. This is generally used to save state before using the |
| 47 // CRTC. When the user finishes using the CRTC, the user should restore the | 54 // CRTC. When the user finishes using the CRTC, the user should restore the |
| 48 // CRTC to it's initial state. Use |SetCrtc| to restore the state. | 55 // CRTC to it's initial state. Use |SetCrtc| to restore the state. |
| 49 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id); | 56 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id); |
| 50 | 57 |
| 51 // Used to configure CRTC with ID |crtc_id| to use the connector in | 58 // Used to configure CRTC with ID |crtc_id| to use the connector in |
| 52 // |connectors|. The CRTC will be configured with mode |mode| and will display | 59 // |connectors|. The CRTC will be configured with mode |mode| and will display |
| 53 // the framebuffer with ID |framebuffer|. Before being able to display the | 60 // the framebuffer with ID |framebuffer|. Before being able to display the |
| 54 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|. | 61 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|. |
| 55 virtual bool SetCrtc(uint32_t crtc_id, | 62 virtual bool SetCrtc(uint32_t crtc_id, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 152 |
| 146 // Drm master related | 153 // Drm master related |
| 147 virtual bool SetMaster(); | 154 virtual bool SetMaster(); |
| 148 virtual bool DropMaster(); | 155 virtual bool DropMaster(); |
| 149 | 156 |
| 150 int get_fd() const { return fd_; } | 157 int get_fd() const { return fd_; } |
| 151 | 158 |
| 152 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } | 159 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } |
| 153 | 160 |
| 154 protected: | 161 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 | |
| 159 // The file descriptor associated with this wrapper. All DRM operations will | 162 // The file descriptor associated with this wrapper. All DRM operations will |
| 160 // be performed using this FD. | 163 // be performed using this FD. |
| 161 // TODO(dnicoara) Make this a base::File | 164 // TODO(dnicoara) Make this a base::File |
| 162 int fd_; | 165 int fd_; |
| 163 | 166 |
| 164 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; | 167 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; |
| 165 | 168 |
| 166 // If we need to block when performing page flips this is set to true. | |
| 167 bool use_sync_flips_; | |
| 168 | |
| 169 private: | 169 private: |
| 170 class IOWatcher; | 170 class IOWatcher; |
| 171 | 171 |
| 172 // Path to DRM device. | 172 // Path to DRM device. |
| 173 const char* device_path_; | 173 const char* device_path_; |
| 174 | 174 |
| 175 // Helper thread to perform IO listener operations. | 175 // Helper thread to perform IO listener operations. |
| 176 // TODO(dnicoara) This should really be supported by the main thread. | 176 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 177 // Alternatively we should have a way to access the IO thread's task runner. | |
| 178 base::Thread io_thread_; | |
| 179 | 177 |
| 180 // Watcher for |fd_| listening for page flip events. | 178 // Watcher for |fd_| listening for page flip events. |
| 181 scoped_refptr<IOWatcher> watcher_; | 179 scoped_refptr<IOWatcher> watcher_; |
| 182 | 180 |
| 183 DISALLOW_COPY_AND_ASSIGN(DriWrapper); | 181 DISALLOW_COPY_AND_ASSIGN(DriWrapper); |
| 184 }; | 182 }; |
| 185 | 183 |
| 186 } // namespace ui | 184 } // namespace ui |
| 187 | 185 |
| 188 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ | 186 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ |
| OLD | NEW |