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.
5 #ifndef UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_MANAGER_H_
6 #define UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_MANAGER_H_
10 #include <xf86drmMode.h>
13 #include "base/basictypes.h"
14 #include "base/memory/scoped_vector.h"
15 #include "ui/ozone/ozone_export.h"
16 #include "ui/ozone/platform/dri/hardware_display_plane.h"
17 #include "ui/ozone/platform/dri/overlay_plane.h"
18 #include "ui/ozone/platform/dri/scoped_drm_types.h"
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();
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
;
41 PageFlipInfo(uint32_t crtc_id
,
44 CrtcController
* crtc
);
55 const gfx::Rect
& bounds
,
56 const gfx::Rect
& src_rect
);
63 std::vector
<Plane
> planes
;
65 // In the case of non-atomic operation, this info will be used for
67 std::vector
<PageFlipInfo
> legacy_page_flips
;
69 // Set if the last operation on this list was a Commit().
73 class OZONE_EXPORT HardwareDisplayPlaneManager
{
75 HardwareDisplayPlaneManager();
76 virtual ~HardwareDisplayPlaneManager();
78 // This parses information from the drm driver, adding any new planes
80 bool Initialize(DrmDevice
* drm
);
82 // Assign hardware planes from the |planes_| list to |overlay_list| entries,
83 // recording the plane IDs in the |plane_list|. Only planes compatible with
84 // |crtc_id| will be used. |overlay_list| must be sorted bottom-to-top.
85 virtual bool AssignOverlayPlanes(HardwareDisplayPlaneList
* plane_list
,
86 const OverlayPlaneList
& overlay_list
,
88 CrtcController
* crtc
);
90 // Commit the plane states in |plane_list|.
91 virtual bool Commit(HardwareDisplayPlaneList
* plane_list
, bool is_sync
) = 0;
93 // Set all planes in |plane_list| owned by |crtc_id| to free.
94 static void ResetPlanes(HardwareDisplayPlaneList
* plane_list
,
97 const ScopedVector
<HardwareDisplayPlane
>& planes() { return planes_
; }
100 virtual bool SetPlaneData(HardwareDisplayPlaneList
* plane_list
,
101 HardwareDisplayPlane
* hw_plane
,
102 const OverlayPlane
& overlay
,
104 const gfx::Rect
& src_rect
,
105 CrtcController
* crtc
) = 0;
106 // Finds the plane located at or after |*index| that is not in use and can
107 // be used with |crtc_index|.
108 HardwareDisplayPlane
* FindNextUnusedPlane(size_t* index
, uint32_t crtc_index
);
110 // Convert |crtc_id| into an index, returning -1 if the ID couldn't be found.
111 int LookupCrtcIndex(uint32_t crtc_id
);
113 // Object containing the connection to the graphics device and wraps the API
114 // calls to control it. Not owned.
117 ScopedVector
<HardwareDisplayPlane
> planes_
;
118 std::vector
<uint32_t> crtcs_
;
120 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayPlaneManager
);
125 #endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_MANAGER_H_