OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_PLANE_MANAGER_H_ |
| 6 #define UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_PLANE_MANAGER_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 #include <xf86drmMode.h> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/basictypes.h" |
| 14 #include "base/memory/scoped_vector.h" |
| 15 #include "ui/ozone/ozone_export.h" |
| 16 #include "ui/ozone/platform/drm/common/scoped_drm_types.h" |
| 17 #include "ui/ozone/platform/drm/gpu/hardware_display_plane.h" |
| 18 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" |
| 19 |
| 20 namespace gfx { |
| 21 class Rect; |
| 22 } // namespace gfx |
| 23 |
| 24 namespace ui { |
| 25 |
| 26 class CrtcController; |
| 27 class DrmDevice; |
| 28 |
| 29 // This contains the list of planes controlled by one HDC on a given DRM fd. |
| 30 // It is owned by the HDC and filled by the CrtcController. |
| 31 struct OZONE_EXPORT HardwareDisplayPlaneList { |
| 32 HardwareDisplayPlaneList(); |
| 33 ~HardwareDisplayPlaneList(); |
| 34 |
| 35 // This is the list of planes to be committed this time. |
| 36 std::vector<HardwareDisplayPlane*> plane_list; |
| 37 // This is the list of planes that was committed last time. |
| 38 std::vector<HardwareDisplayPlane*> old_plane_list; |
| 39 |
| 40 struct PageFlipInfo { |
| 41 PageFlipInfo(uint32_t crtc_id, uint32_t framebuffer, CrtcController* crtc); |
| 42 ~PageFlipInfo(); |
| 43 |
| 44 uint32_t crtc_id; |
| 45 uint32_t framebuffer; |
| 46 CrtcController* crtc; |
| 47 |
| 48 struct Plane { |
| 49 Plane(int plane, |
| 50 int framebuffer, |
| 51 const gfx::Rect& bounds, |
| 52 const gfx::Rect& src_rect); |
| 53 ~Plane(); |
| 54 int plane; |
| 55 int framebuffer; |
| 56 gfx::Rect bounds; |
| 57 gfx::Rect src_rect; |
| 58 }; |
| 59 std::vector<Plane> planes; |
| 60 }; |
| 61 // In the case of non-atomic operation, this info will be used for |
| 62 // pageflipping. |
| 63 std::vector<PageFlipInfo> legacy_page_flips; |
| 64 |
| 65 #if defined(USE_DRM_ATOMIC) |
| 66 ScopedDrmPropertySetPtr atomic_property_set; |
| 67 #endif // defined(USE_DRM_ATOMIC) |
| 68 }; |
| 69 |
| 70 class OZONE_EXPORT HardwareDisplayPlaneManager { |
| 71 public: |
| 72 HardwareDisplayPlaneManager(); |
| 73 virtual ~HardwareDisplayPlaneManager(); |
| 74 |
| 75 // This parses information from the drm driver, adding any new planes |
| 76 // or crtcs found. |
| 77 bool Initialize(DrmDevice* drm); |
| 78 |
| 79 // Clears old frame state out. Must be called before any AssignOverlayPlanes |
| 80 // calls. |
| 81 void BeginFrame(HardwareDisplayPlaneList* plane_list); |
| 82 |
| 83 // Assign hardware planes from the |planes_| list to |overlay_list| entries, |
| 84 // recording the plane IDs in the |plane_list|. Only planes compatible with |
| 85 // |crtc_id| will be used. |overlay_list| must be sorted bottom-to-top. |
| 86 virtual bool AssignOverlayPlanes(HardwareDisplayPlaneList* plane_list, |
| 87 const OverlayPlaneList& overlay_list, |
| 88 uint32_t crtc_id, |
| 89 CrtcController* crtc); |
| 90 |
| 91 // Commit the plane states in |plane_list|. |
| 92 virtual bool Commit(HardwareDisplayPlaneList* plane_list, |
| 93 bool is_sync, |
| 94 bool test_only) = 0; |
| 95 |
| 96 // Set all planes in |plane_list| owned by |crtc_id| to free. |
| 97 static void ResetPlanes(HardwareDisplayPlaneList* plane_list, |
| 98 uint32_t crtc_id); |
| 99 |
| 100 const ScopedVector<HardwareDisplayPlane>& planes() { return planes_; } |
| 101 |
| 102 protected: |
| 103 virtual bool SetPlaneData(HardwareDisplayPlaneList* plane_list, |
| 104 HardwareDisplayPlane* hw_plane, |
| 105 const OverlayPlane& overlay, |
| 106 uint32_t crtc_id, |
| 107 const gfx::Rect& src_rect, |
| 108 CrtcController* crtc) = 0; |
| 109 |
| 110 virtual scoped_ptr<HardwareDisplayPlane> CreatePlane(uint32_t plane_id, |
| 111 uint32_t possible_crtcs); |
| 112 |
| 113 // Finds the plane located at or after |*index| that is not in use and can |
| 114 // be used with |crtc_index|. |
| 115 HardwareDisplayPlane* FindNextUnusedPlane(size_t* index, uint32_t crtc_index); |
| 116 |
| 117 // Convert |crtc_id| into an index, returning -1 if the ID couldn't be found. |
| 118 int LookupCrtcIndex(uint32_t crtc_id); |
| 119 |
| 120 // Object containing the connection to the graphics device and wraps the API |
| 121 // calls to control it. Not owned. |
| 122 DrmDevice* drm_; |
| 123 |
| 124 ScopedVector<HardwareDisplayPlane> planes_; |
| 125 std::vector<uint32_t> crtcs_; |
| 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayPlaneManager); |
| 128 }; |
| 129 |
| 130 } // namespace ui |
| 131 |
| 132 #endif // UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_PLANE_MANAGER_H_ |
OLD | NEW |