| 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_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/ozone_export.h" | 16 #include "ui/ozone/ozone_export.h" |
| 17 #include "ui/ozone/platform/dri/dri_wrapper.h" | 17 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 18 | 18 |
| 19 namespace gfx { | 19 namespace gfx { |
| 20 class Point; | 20 class Point; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 | 24 |
| 25 class DriSurface; | 25 class ScanoutSurface; |
| 26 | 26 |
| 27 // The HDCOz will handle modesettings and scannout operations for hardware | 27 // The HDCOz will handle modesettings and scannout operations for hardware |
| 28 // devices. | 28 // devices. |
| 29 // | 29 // |
| 30 // In the DRM world there are 3 components that need to be paired up to be able | 30 // In the DRM world there are 3 components that need to be paired up to be able |
| 31 // to display an image to the monitor: CRTC (cathode ray tube controller), | 31 // to display an image to the monitor: CRTC (cathode ray tube controller), |
| 32 // encoder and connector. The CRTC determines which framebuffer to read, when | 32 // encoder and connector. The CRTC determines which framebuffer to read, when |
| 33 // to scanout and where to scanout. Encoders converts the stream from the CRTC | 33 // to scanout and where to scanout. Encoders converts the stream from the CRTC |
| 34 // to the appropriate format for the connector. The connector is the physical | 34 // to the appropriate format for the connector. The connector is the physical |
| 35 // connection that monitors connect to. | 35 // connection that monitors connect to. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 class OZONE_EXPORT HardwareDisplayController | 84 class OZONE_EXPORT HardwareDisplayController |
| 85 : public base::SupportsWeakPtr<HardwareDisplayController> { | 85 : public base::SupportsWeakPtr<HardwareDisplayController> { |
| 86 public: | 86 public: |
| 87 HardwareDisplayController(DriWrapper* drm, | 87 HardwareDisplayController(DriWrapper* drm, |
| 88 uint32_t connector_id, | 88 uint32_t connector_id, |
| 89 uint32_t crtc_id); | 89 uint32_t crtc_id); |
| 90 | 90 |
| 91 ~HardwareDisplayController(); | 91 ~HardwareDisplayController(); |
| 92 | 92 |
| 93 // Associate the HDCO with a surface implementation and initialize it. | 93 // Associate the HDCO with a surface implementation and initialize it. |
| 94 bool BindSurfaceToController(scoped_ptr<DriSurface> surface, | 94 bool BindSurfaceToController(scoped_ptr<ScanoutSurface> surface, |
| 95 drmModeModeInfo mode); | 95 drmModeModeInfo mode); |
| 96 | 96 |
| 97 void UnbindSurfaceFromController(); | 97 void UnbindSurfaceFromController(); |
| 98 | 98 |
| 99 // Unbinds the surface and disables the CRTC. | 99 // Unbinds the surface and disables the CRTC. |
| 100 void Disable(); | 100 void Disable(); |
| 101 | 101 |
| 102 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync | 102 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync |
| 103 // event. The event will be posted on the graphics card file descriptor |fd_| | 103 // event. The event will be posted on the graphics card file descriptor |fd_| |
| 104 // and it can be read and processed by |drmHandleEvent|. That function can | 104 // and it can be read and processed by |drmHandleEvent|. That function can |
| (...skipping 20 matching lines...) Expand all Loading... |
| 125 // kernel when a VBlank event finished. This allows the controller to | 125 // kernel when a VBlank event finished. This allows the controller to |
| 126 // update internal state and propagate the update to the surface. | 126 // update internal state and propagate the update to the surface. |
| 127 // The tuple (seconds, useconds) represents the event timestamp. |seconds| | 127 // The tuple (seconds, useconds) represents the event timestamp. |seconds| |
| 128 // represents the number of seconds while |useconds| represents the | 128 // represents the number of seconds while |useconds| represents the |
| 129 // microseconds (< 1 second) in the timestamp. | 129 // microseconds (< 1 second) in the timestamp. |
| 130 void OnPageFlipEvent(unsigned int frame, | 130 void OnPageFlipEvent(unsigned int frame, |
| 131 unsigned int seconds, | 131 unsigned int seconds, |
| 132 unsigned int useconds); | 132 unsigned int useconds); |
| 133 | 133 |
| 134 // Set the hardware cursor to show the contents of |surface|. | 134 // Set the hardware cursor to show the contents of |surface|. |
| 135 bool SetCursor(DriSurface* surface); | 135 bool SetCursor(ScanoutSurface* surface); |
| 136 | 136 |
| 137 bool UnsetCursor(); | 137 bool UnsetCursor(); |
| 138 | 138 |
| 139 // Moves the hardware cursor to |location|. | 139 // Moves the hardware cursor to |location|. |
| 140 bool MoveCursor(const gfx::Point& location); | 140 bool MoveCursor(const gfx::Point& location); |
| 141 | 141 |
| 142 const drmModeModeInfo& get_mode() const { return mode_; }; | 142 const drmModeModeInfo& get_mode() const { return mode_; }; |
| 143 uint32_t connector_id() const { return connector_id_; } | 143 uint32_t connector_id() const { return connector_id_; } |
| 144 uint32_t crtc_id() const { return crtc_id_; } | 144 uint32_t crtc_id() const { return crtc_id_; } |
| 145 DriSurface* surface() const { | 145 ScanoutSurface* surface() const { |
| 146 return surface_.get(); | 146 return surface_.get(); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 uint64_t get_time_of_last_flip() const { | 149 uint64_t get_time_of_last_flip() const { |
| 150 return time_of_last_flip_; | 150 return time_of_last_flip_; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 // Object containing the connection to the graphics device and wraps the API | 154 // Object containing the connection to the graphics device and wraps the API |
| 155 // calls to control it. | 155 // calls to control it. |
| 156 DriWrapper* drm_; | 156 DriWrapper* drm_; |
| 157 | 157 |
| 158 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. | 158 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. |
| 159 uint32_t connector_id_; | 159 uint32_t connector_id_; |
| 160 | 160 |
| 161 uint32_t crtc_id_; | 161 uint32_t crtc_id_; |
| 162 | 162 |
| 163 // TODO(dnicoara) Need to store all the modes. | 163 // TODO(dnicoara) Need to store all the modes. |
| 164 drmModeModeInfo mode_; | 164 drmModeModeInfo mode_; |
| 165 | 165 |
| 166 scoped_ptr<DriSurface> surface_; | 166 scoped_ptr<ScanoutSurface> surface_; |
| 167 | 167 |
| 168 uint64_t time_of_last_flip_; | 168 uint64_t time_of_last_flip_; |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); | 170 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 } // namespace ui | 173 } // namespace ui |
| 174 | 174 |
| 175 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ | 175 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ |
| OLD | NEW |