| 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_HARDWARE_DISPLAY_CONTROLLER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_CONTROLLER_H_ |
| 6 #define UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_CONTROLLER_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_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 | 11 |
| 12 #include <deque> | 12 #include <deque> |
| 13 #include <map> | 13 #include <map> |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <unordered_map> | 15 #include <unordered_map> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "ui/gfx/swap_result.h" | 20 #include "ui/gfx/swap_result.h" |
| 21 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" | 21 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" |
| 22 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" | 22 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" |
| 23 #include "ui/ozone/public/swap_completion_callback.h" |
| 23 | 24 |
| 24 namespace gfx { | 25 namespace gfx { |
| 25 class Point; | 26 class Point; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace ui { | 29 namespace ui { |
| 29 | 30 |
| 30 class CrtcController; | 31 class CrtcController; |
| 31 class ScanoutBuffer; | 32 class ScanoutBuffer; |
| 32 class DrmDevice; | 33 class DrmDevice; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // | | | 80 // | | |
| 80 // ---------------------- | 81 // ---------------------- |
| 81 // | CRTC1 | | 82 // | CRTC1 | |
| 82 // ---------------------- | 83 // ---------------------- |
| 83 // | 84 // |
| 84 // Note that it is possible to have more connectors than CRTCs which means that | 85 // Note that it is possible to have more connectors than CRTCs which means that |
| 85 // only a subset of connectors can be active independently, showing different | 86 // only a subset of connectors can be active independently, showing different |
| 86 // framebuffers. Though, in this case, it would be possible to have all | 87 // framebuffers. Though, in this case, it would be possible to have all |
| 87 // connectors active if some use the same CRTC to mirror the display. | 88 // connectors active if some use the same CRTC to mirror the display. |
| 88 class HardwareDisplayController { | 89 class HardwareDisplayController { |
| 89 typedef base::Callback<void(gfx::SwapResult)> PageFlipCallback; | |
| 90 | |
| 91 public: | 90 public: |
| 92 HardwareDisplayController(std::unique_ptr<CrtcController> controller, | 91 HardwareDisplayController(std::unique_ptr<CrtcController> controller, |
| 93 const gfx::Point& origin); | 92 const gfx::Point& origin); |
| 94 ~HardwareDisplayController(); | 93 ~HardwareDisplayController(); |
| 95 | 94 |
| 96 // Performs the initial CRTC configuration. If successful, it will display the | 95 // Performs the initial CRTC configuration. If successful, it will display the |
| 97 // framebuffer for |primary| with |mode|. | 96 // framebuffer for |primary| with |mode|. |
| 98 bool Modeset(const OverlayPlane& primary, drmModeModeInfo mode); | 97 bool Modeset(const OverlayPlane& primary, drmModeModeInfo mode); |
| 99 | 98 |
| 100 // Performs a CRTC configuration re-using the modes from the CRTCs. | 99 // Performs a CRTC configuration re-using the modes from the CRTCs. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 // object the event belongs to. | 110 // object the event belongs to. |
| 112 // | 111 // |
| 113 // Between this call and the callback, the framebuffers used in this call | 112 // Between this call and the callback, the framebuffers used in this call |
| 114 // should not be modified in any way as it would cause screen tearing if the | 113 // should not be modified in any way as it would cause screen tearing if the |
| 115 // hardware performed the flip. Note that the frontbuffer should also not | 114 // hardware performed the flip. Note that the frontbuffer should also not |
| 116 // be modified as it could still be displayed. | 115 // be modified as it could still be displayed. |
| 117 // | 116 // |
| 118 // Note that this function does not block. Also, this function should not be | 117 // Note that this function does not block. Also, this function should not be |
| 119 // called again before the page flip occurrs. | 118 // called again before the page flip occurrs. |
| 120 void SchedulePageFlip(const OverlayPlaneList& plane_list, | 119 void SchedulePageFlip(const OverlayPlaneList& plane_list, |
| 121 const PageFlipCallback& callback); | 120 SwapCompletionOnceCallback callback); |
| 122 | 121 |
| 123 // Returns true if the page flip with the |plane_list| would succeed. This | 122 // Returns true if the page flip with the |plane_list| would succeed. This |
| 124 // doesn't change any state. | 123 // doesn't change any state. |
| 125 bool TestPageFlip(const OverlayPlaneList& plane_list); | 124 bool TestPageFlip(const OverlayPlaneList& plane_list); |
| 126 | 125 |
| 127 bool IsFormatSupported(uint32_t fourcc_format, uint32_t z_order) const; | 126 bool IsFormatSupported(uint32_t fourcc_format, uint32_t z_order) const; |
| 128 | 127 |
| 129 // Return the supported modifiers for |fourcc_format| for this | 128 // Return the supported modifiers for |fourcc_format| for this |
| 130 // controller. | 129 // controller. |
| 131 std::vector<uint64_t> GetFormatModifiers(uint32_t fourcc_format); | 130 std::vector<uint64_t> GetFormatModifiers(uint32_t fourcc_format); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 | 153 |
| 155 const std::vector<std::unique_ptr<CrtcController>>& crtc_controllers() const { | 154 const std::vector<std::unique_ptr<CrtcController>>& crtc_controllers() const { |
| 156 return crtc_controllers_; | 155 return crtc_controllers_; |
| 157 } | 156 } |
| 158 | 157 |
| 159 scoped_refptr<DrmDevice> GetAllocationDrmDevice() const; | 158 scoped_refptr<DrmDevice> GetAllocationDrmDevice() const; |
| 160 | 159 |
| 161 private: | 160 private: |
| 162 bool ActualSchedulePageFlip(const OverlayPlaneList& plane_list, | 161 bool ActualSchedulePageFlip(const OverlayPlaneList& plane_list, |
| 163 bool test_only, | 162 bool test_only, |
| 164 const PageFlipCallback& callback); | 163 SwapCompletionOnceCallback callback); |
| 165 | 164 |
| 166 std::unordered_map<DrmDevice*, std::unique_ptr<HardwareDisplayPlaneList>> | 165 std::unordered_map<DrmDevice*, std::unique_ptr<HardwareDisplayPlaneList>> |
| 167 owned_hardware_planes_; | 166 owned_hardware_planes_; |
| 168 | 167 |
| 169 // Stores the CRTC configuration. This is used to identify monitors and | 168 // Stores the CRTC configuration. This is used to identify monitors and |
| 170 // configure them. | 169 // configure them. |
| 171 std::vector<std::unique_ptr<CrtcController>> crtc_controllers_; | 170 std::vector<std::unique_ptr<CrtcController>> crtc_controllers_; |
| 172 | 171 |
| 173 // Location of the controller on the screen. | 172 // Location of the controller on the screen. |
| 174 gfx::Point origin_; | 173 gfx::Point origin_; |
| 175 | 174 |
| 176 bool is_disabled_; | 175 bool is_disabled_; |
| 177 | 176 |
| 178 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); | 177 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); |
| 179 }; | 178 }; |
| 180 | 179 |
| 181 } // namespace ui | 180 } // namespace ui |
| 182 | 181 |
| 183 #endif // UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_CONTROLLER_H_ | 182 #endif // UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_CONTROLLER_H_ |
| OLD | NEW |