| 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_DRM_GPU_DRM_DEVICE_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ |
| 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
| 20 #include "ui/gfx/overlay_transform.h" | 20 #include "ui/gfx/overlay_transform.h" |
| 21 #include "ui/ozone/platform/drm/common/scoped_drm_types.h" | 21 #include "ui/ozone/platform/drm/common/scoped_drm_types.h" |
| 22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" | 22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" |
| 23 | 23 |
| 24 typedef struct _drmEventContext drmEventContext; | 24 typedef struct _drmEventContext drmEventContext; |
| 25 typedef struct _drmModeModeInfo drmModeModeInfo; | 25 typedef struct _drmModeModeInfo drmModeModeInfo; |
| 26 | 26 |
| 27 struct SkImageInfo; | 27 struct SkImageInfo; |
| 28 | 28 |
| 29 namespace display { |
| 30 struct GammaRampRGBEntry; |
| 31 } |
| 32 |
| 29 namespace ui { | 33 namespace ui { |
| 30 | 34 |
| 31 class HardwareDisplayPlaneManager; | 35 class HardwareDisplayPlaneManager; |
| 32 struct GammaRampRGBEntry; | |
| 33 | 36 |
| 34 // Wraps DRM calls into a nice interface. Used to provide different | 37 // Wraps DRM calls into a nice interface. Used to provide different |
| 35 // implementations of the DRM calls. For the actual implementation the DRM API | 38 // implementations of the DRM calls. For the actual implementation the DRM API |
| 36 // would be called. In unit tests this interface would be stubbed. | 39 // would be called. In unit tests this interface would be stubbed. |
| 37 class DrmDevice : public base::RefCountedThreadSafe<DrmDevice> { | 40 class DrmDevice : public base::RefCountedThreadSafe<DrmDevice> { |
| 38 public: | 41 public: |
| 39 typedef base::Callback<void(unsigned int /* frame */, | 42 typedef base::Callback<void(unsigned int /* frame */, |
| 40 unsigned int /* seconds */, | 43 unsigned int /* seconds */, |
| 41 unsigned int /* useconds */)> PageFlipCallback; | 44 unsigned int /* useconds */)> PageFlipCallback; |
| 42 | 45 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 154 |
| 152 virtual bool CloseBufferHandle(uint32_t handle); | 155 virtual bool CloseBufferHandle(uint32_t handle); |
| 153 | 156 |
| 154 virtual bool CommitProperties(drmModeAtomicReq* properties, | 157 virtual bool CommitProperties(drmModeAtomicReq* properties, |
| 155 uint32_t flags, | 158 uint32_t flags, |
| 156 uint32_t crtc_count, | 159 uint32_t crtc_count, |
| 157 const PageFlipCallback& callback); | 160 const PageFlipCallback& callback); |
| 158 | 161 |
| 159 virtual bool SetColorCorrection( | 162 virtual bool SetColorCorrection( |
| 160 uint32_t crtc_id, | 163 uint32_t crtc_id, |
| 161 const std::vector<GammaRampRGBEntry>& degamma_lut, | 164 const std::vector<display::GammaRampRGBEntry>& degamma_lut, |
| 162 const std::vector<GammaRampRGBEntry>& gamma_lut, | 165 const std::vector<display::GammaRampRGBEntry>& gamma_lut, |
| 163 const std::vector<float>& correction_matrix); | 166 const std::vector<float>& correction_matrix); |
| 164 | 167 |
| 165 virtual bool SetCapability(uint64_t capability, uint64_t value); | 168 virtual bool SetCapability(uint64_t capability, uint64_t value); |
| 166 | 169 |
| 167 // Drm master related | 170 // Drm master related |
| 168 virtual bool SetMaster(); | 171 virtual bool SetMaster(); |
| 169 virtual bool DropMaster(); | 172 virtual bool DropMaster(); |
| 170 | 173 |
| 171 int get_fd() const { return file_.GetPlatformFile(); } | 174 int get_fd() const { return file_.GetPlatformFile(); } |
| 172 | 175 |
| 173 base::FilePath device_path() const { return device_path_; } | 176 base::FilePath device_path() const { return device_path_; } |
| 174 | 177 |
| 175 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } | 178 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } |
| 176 | 179 |
| 177 protected: | 180 protected: |
| 178 friend class base::RefCountedThreadSafe<DrmDevice>; | 181 friend class base::RefCountedThreadSafe<DrmDevice>; |
| 179 | 182 |
| 180 virtual ~DrmDevice(); | 183 virtual ~DrmDevice(); |
| 181 | 184 |
| 182 std::unique_ptr<HardwareDisplayPlaneManager> plane_manager_; | 185 std::unique_ptr<HardwareDisplayPlaneManager> plane_manager_; |
| 183 | 186 |
| 184 private: | 187 private: |
| 185 class IOWatcher; | 188 class IOWatcher; |
| 186 class PageFlipManager; | 189 class PageFlipManager; |
| 187 | 190 |
| 188 bool SetGammaRamp(uint32_t crtc_id, | 191 bool SetGammaRamp(uint32_t crtc_id, |
| 189 const std::vector<GammaRampRGBEntry>& lut); | 192 const std::vector<display::GammaRampRGBEntry>& lut); |
| 190 | 193 |
| 191 // Path to the DRM device (in sysfs). | 194 // Path to the DRM device (in sysfs). |
| 192 const base::FilePath device_path_; | 195 const base::FilePath device_path_; |
| 193 | 196 |
| 194 // DRM device. | 197 // DRM device. |
| 195 base::File file_; | 198 base::File file_; |
| 196 | 199 |
| 197 std::unique_ptr<PageFlipManager> page_flip_manager_; | 200 std::unique_ptr<PageFlipManager> page_flip_manager_; |
| 198 | 201 |
| 199 // Watcher for |fd_| listening for page flip events. | 202 // Watcher for |fd_| listening for page flip events. |
| 200 std::unique_ptr<IOWatcher> watcher_; | 203 std::unique_ptr<IOWatcher> watcher_; |
| 201 | 204 |
| 202 bool is_primary_device_; | 205 bool is_primary_device_; |
| 203 | 206 |
| 204 DISALLOW_COPY_AND_ASSIGN(DrmDevice); | 207 DISALLOW_COPY_AND_ASSIGN(DrmDevice); |
| 205 }; | 208 }; |
| 206 | 209 |
| 207 } // namespace ui | 210 } // namespace ui |
| 208 | 211 |
| 209 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ | 212 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ |
| OLD | NEW |