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 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h"
8 #include "ui/ozone/platform/drm/gpu/drm_device.h"
9 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h"
10 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
14 static void AtomicPageFlipCallback(unsigned int /* frame */,
15 unsigned int /* seconds */,
16 unsigned int /* useconds */) {
19 HardwareDisplayPlaneManagerAtomic::HardwareDisplayPlaneManagerAtomic() {
22 HardwareDisplayPlaneManagerAtomic::~HardwareDisplayPlaneManagerAtomic() {
25 bool HardwareDisplayPlaneManagerAtomic::Commit(
26 HardwareDisplayPlaneList
* plane_list
,
28 for (HardwareDisplayPlane
* plane
: plane_list
->old_plane_list
) {
30 std::find(plane_list
->plane_list
.begin(), plane_list
->plane_list
.end(),
31 plane
) != plane_list
->plane_list
.end();
33 // This plane is being released, so we need to zero it.
34 plane
->set_in_use(false);
35 HardwareDisplayPlaneAtomic
* atomic_plane
=
36 static_cast<HardwareDisplayPlaneAtomic
*>(plane
);
37 atomic_plane
->SetPlaneData(plane_list
->atomic_property_set
.get(), 0, 0,
38 gfx::Rect(), gfx::Rect());
42 plane_list
->plane_list
.swap(plane_list
->old_plane_list
);
43 plane_list
->plane_list
.clear();
44 if (!drm_
->CommitProperties(plane_list
->atomic_property_set
.get(), 0,
45 base::Bind(&AtomicPageFlipCallback
))) {
46 PLOG(ERROR
) << "Failed to commit properties";
52 bool HardwareDisplayPlaneManagerAtomic::AssignOverlayPlanes(
53 HardwareDisplayPlaneList
* plane_list
,
54 const OverlayPlaneList
& overlay_list
,
56 CrtcController
* crtc
) {
57 // Lazy-initialize the atomic property set.
58 if (!plane_list
->atomic_property_set
)
59 plane_list
->atomic_property_set
.reset(drmModePropertySetAlloc());
60 return HardwareDisplayPlaneManager::AssignOverlayPlanes(
61 plane_list
, overlay_list
, crtc_id
, crtc
);
64 bool HardwareDisplayPlaneManagerAtomic::SetPlaneData(
65 HardwareDisplayPlaneList
* plane_list
,
66 HardwareDisplayPlane
* hw_plane
,
67 const OverlayPlane
& overlay
,
69 const gfx::Rect
& src_rect
,
70 CrtcController
* crtc
) {
71 HardwareDisplayPlaneAtomic
* atomic_plane
=
72 static_cast<HardwareDisplayPlaneAtomic
*>(hw_plane
);
73 if (!atomic_plane
->SetPlaneData(plane_list
->atomic_property_set
.get(),
74 crtc_id
, overlay
.buffer
->GetFramebufferId(),
75 overlay
.display_bounds
, src_rect
)) {
76 LOG(ERROR
) << "Failed to set plane properties";
79 plane_list
->plane_list
.push_back(hw_plane
);
83 scoped_ptr
<HardwareDisplayPlane
> HardwareDisplayPlaneManagerAtomic::CreatePlane(
85 uint32_t possible_crtcs
) {
86 return scoped_ptr
<HardwareDisplayPlane
>(
87 new HardwareDisplayPlaneAtomic(plane_id
, possible_crtcs
));