Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / ozone / platform / drm / gpu / hardware_display_plane_manager_atomic.cc
blob5a7eae3050f63577e208a0047f0cc4a53c3c43a5
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"
7 #include "base/bind.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"
12 namespace ui {
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,
27 bool is_sync) {
28 for (HardwareDisplayPlane* plane : plane_list->old_plane_list) {
29 bool found =
30 std::find(plane_list->plane_list.begin(), plane_list->plane_list.end(),
31 plane) != plane_list->plane_list.end();
32 if (!found) {
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";
47 return false;
49 return true;
52 bool HardwareDisplayPlaneManagerAtomic::AssignOverlayPlanes(
53 HardwareDisplayPlaneList* plane_list,
54 const OverlayPlaneList& overlay_list,
55 uint32_t crtc_id,
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,
68 uint32_t crtc_id,
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";
77 return false;
79 plane_list->plane_list.push_back(hw_plane);
80 return true;
83 scoped_ptr<HardwareDisplayPlane> HardwareDisplayPlaneManagerAtomic::CreatePlane(
84 uint32_t plane_id,
85 uint32_t possible_crtcs) {
86 return scoped_ptr<HardwareDisplayPlane>(
87 new HardwareDisplayPlaneAtomic(plane_id, possible_crtcs));
90 } // namespace ui