| 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/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; |
| 24 class ScanoutSurface; | 25 class ScanoutSurface; |
| 25 | 26 |
| 27 struct OzoneOverlayPlane { |
| 28 OzoneOverlayPlane(ScanoutSurface* scanout, |
| 29 int z_order, |
| 30 gfx::OverlayTransform plane_transform, |
| 31 const gfx::Rect& display_bounds, |
| 32 const gfx::RectF& crop_rect) |
| 33 : scanout(scanout), |
| 34 z_order(z_order), |
| 35 plane_transform(plane_transform), |
| 36 display_bounds(display_bounds), |
| 37 crop_rect(crop_rect), |
| 38 overlay_plane(0) {} |
| 39 |
| 40 ScanoutSurface* scanout; |
| 41 int z_order; |
| 42 gfx::OverlayTransform plane_transform; |
| 43 gfx::Rect display_bounds; |
| 44 gfx::RectF crop_rect; |
| 45 int overlay_plane; |
| 46 }; |
| 47 |
| 26 // The HDCOz will handle modesettings and scannout operations for hardware | 48 // The HDCOz will handle modesettings and scannout operations for hardware |
| 27 // devices. | 49 // devices. |
| 28 // | 50 // |
| 29 // 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 |
| 30 // 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), |
| 31 // encoder and connector. The CRTC determines which framebuffer to read, when | 53 // encoder and connector. The CRTC determines which framebuffer to read, when |
| 32 // 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 |
| 33 // 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 |
| 34 // connection that monitors connect to. | 56 // connection that monitors connect to. |
| 35 // | 57 // |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // | 129 // |
| 108 // Between this call and the callback, the framebuffer used in this call | 130 // Between this call and the callback, the framebuffer used in this call |
| 109 // should not be modified in any way as it would cause screen tearing if the | 131 // should not be modified in any way as it would cause screen tearing if the |
| 110 // hardware performed the flip. Note that the frontbuffer should also not | 132 // hardware performed the flip. Note that the frontbuffer should also not |
| 111 // be modified as it could still be displayed. | 133 // be modified as it could still be displayed. |
| 112 // | 134 // |
| 113 // Note that this function does not block. Also, this function should not be | 135 // Note that this function does not block. Also, this function should not be |
| 114 // called again before the page flip occurrs. | 136 // called again before the page flip occurrs. |
| 115 // | 137 // |
| 116 // Returns true if the page flip was successfully registered, false otherwise. | 138 // Returns true if the page flip was successfully registered, false otherwise. |
| 117 bool SchedulePageFlip(); | 139 bool SchedulePageFlip(std::vector<OzoneOverlayPlane>* overlays, |
| 140 std::vector<scoped_refptr<NativePixmap> >* references); |
| 118 | 141 |
| 119 // TODO(dnicoara) This should be on the MessageLoop when Ozone can have | 142 // TODO(dnicoara) This should be on the MessageLoop when Ozone can have |
| 120 // BeginFrame can be triggered explicitly by Ozone. | 143 // BeginFrame can be triggered explicitly by Ozone. |
| 121 void WaitForPageFlipEvent(); | 144 void WaitForPageFlipEvent(); |
| 122 | 145 |
| 123 // Called when the page flip event occurred. The event is provided by the | 146 // Called when the page flip event occurred. The event is provided by the |
| 124 // kernel when a VBlank event finished. This allows the controller to | 147 // kernel when a VBlank event finished. This allows the controller to |
| 125 // update internal state and propagate the update to the surface. | 148 // update internal state and propagate the update to the surface. |
| 126 // The tuple (seconds, useconds) represents the event timestamp. |seconds| | 149 // The tuple (seconds, useconds) represents the event timestamp. |seconds| |
| 127 // represents the number of seconds while |useconds| represents the | 150 // represents the number of seconds while |useconds| represents the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 143 uint32_t crtc_id() const { return crtc_id_; } | 166 uint32_t crtc_id() const { return crtc_id_; } |
| 144 ScanoutSurface* surface() const { | 167 ScanoutSurface* surface() const { |
| 145 return surface_.get(); | 168 return surface_.get(); |
| 146 }; | 169 }; |
| 147 | 170 |
| 148 uint64_t get_time_of_last_flip() const { | 171 uint64_t get_time_of_last_flip() const { |
| 149 return time_of_last_flip_; | 172 return time_of_last_flip_; |
| 150 }; | 173 }; |
| 151 | 174 |
| 152 private: | 175 private: |
| 176 // Assign overlay IDs to each overlay in the list, returning the primary |
| 177 // plane's surface (z-index 0, or surface_.get()). |
| 178 ScanoutSurface* AssignOverlayPlanes(std::vector<OzoneOverlayPlane>* overlays); |
| 179 |
| 180 std::vector<scoped_refptr<NativePixmap> > current_overlay_references_; |
| 181 |
| 153 // Object containing the connection to the graphics device and wraps the API | 182 // Object containing the connection to the graphics device and wraps the API |
| 154 // calls to control it. | 183 // calls to control it. |
| 155 DriWrapper* drm_; | 184 DriWrapper* drm_; |
| 156 | 185 |
| 157 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. | 186 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. |
| 158 uint32_t connector_id_; | 187 uint32_t connector_id_; |
| 159 | 188 |
| 160 uint32_t crtc_id_; | 189 uint32_t crtc_id_; |
| 161 | 190 |
| 162 drmModeModeInfo mode_; | 191 drmModeModeInfo mode_; |
| 163 | 192 |
| 164 scoped_ptr<ScanoutSurface> surface_; | 193 scoped_ptr<ScanoutSurface> surface_; |
| 165 | 194 |
| 166 uint64_t time_of_last_flip_; | 195 uint64_t time_of_last_flip_; |
| 167 | 196 |
| 168 // Keeps track of the CRTC state. If a surface has been bound, then the value | 197 // Keeps track of the CRTC state. If a surface has been bound, then the value |
| 169 // is set to false. Otherwise it is true. | 198 // is set to false. Otherwise it is true. |
| 170 bool is_disabled_; | 199 bool is_disabled_; |
| 171 | 200 |
| 172 // Store the state of the CRTC before we took over. Used to restore the CRTC | 201 // Store the state of the CRTC before we took over. Used to restore the CRTC |
| 173 // once we no longer need it. | 202 // once we no longer need it. |
| 174 ScopedDrmCrtcPtr saved_crtc_; | 203 ScopedDrmCrtcPtr saved_crtc_; |
| 175 | 204 |
| 176 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); | 205 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); |
| 177 }; | 206 }; |
| 178 | 207 |
| 179 } // namespace ui | 208 } // namespace ui |
| 180 | 209 |
| 181 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ | 210 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ |
| OLD | NEW |