Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc

Issue 1147553003: ozone: Add atomic initialization path (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove flag for now Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h" 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
8 #include "ui/ozone/platform/drm/gpu/drm_device.h" 9 #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/hardware_display_plane_atomic.h"
10 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 11 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
11 12
12 namespace ui { 13 namespace ui {
13 14
14 static void AtomicPageFlipCallback(unsigned int /* frame */, 15 static void AtomicPageFlipCallback(
15 unsigned int /* seconds */, 16 std::vector<base::WeakPtr<CrtcController>> crtcs,
16 unsigned int /* useconds */) { 17 unsigned int frame,
18 unsigned int seconds,
19 unsigned int useconds) {
20 for (auto& crtc : crtcs) {
21 auto* crtc_ptr = crtc.get();
22 if (crtc_ptr)
23 crtc_ptr->OnPageFlipEvent(frame, seconds, useconds);
24 }
17 } 25 }
18 26
19 HardwareDisplayPlaneManagerAtomic::HardwareDisplayPlaneManagerAtomic() { 27 HardwareDisplayPlaneManagerAtomic::HardwareDisplayPlaneManagerAtomic() {
20 } 28 }
21 29
22 HardwareDisplayPlaneManagerAtomic::~HardwareDisplayPlaneManagerAtomic() { 30 HardwareDisplayPlaneManagerAtomic::~HardwareDisplayPlaneManagerAtomic() {
23 } 31 }
24 32
25 bool HardwareDisplayPlaneManagerAtomic::Commit( 33 bool HardwareDisplayPlaneManagerAtomic::Commit(
26 HardwareDisplayPlaneList* plane_list, 34 HardwareDisplayPlaneList* plane_list,
27 bool is_sync) { 35 bool is_sync) {
28 for (HardwareDisplayPlane* plane : plane_list->old_plane_list) { 36 for (HardwareDisplayPlane* plane : plane_list->old_plane_list) {
29 bool found = 37 bool found =
30 std::find(plane_list->plane_list.begin(), plane_list->plane_list.end(), 38 std::find(plane_list->plane_list.begin(), plane_list->plane_list.end(),
31 plane) != plane_list->plane_list.end(); 39 plane) != plane_list->plane_list.end();
32 if (!found) { 40 if (!found) {
33 // This plane is being released, so we need to zero it. 41 // This plane is being released, so we need to zero it.
34 plane->set_in_use(false); 42 plane->set_in_use(false);
35 HardwareDisplayPlaneAtomic* atomic_plane = 43 HardwareDisplayPlaneAtomic* atomic_plane =
36 static_cast<HardwareDisplayPlaneAtomic*>(plane); 44 static_cast<HardwareDisplayPlaneAtomic*>(plane);
37 atomic_plane->SetPlaneData(plane_list->atomic_property_set.get(), 0, 0, 45 atomic_plane->SetPlaneData(plane_list->atomic_property_set.get(), 0, 0,
38 gfx::Rect(), gfx::Rect()); 46 gfx::Rect(), gfx::Rect());
39 } 47 }
40 } 48 }
41 49
50 std::vector<base::WeakPtr<CrtcController>> crtcs;
51 for (HardwareDisplayPlane* plane : plane_list->plane_list) {
52 HardwareDisplayPlaneAtomic* atomic_plane =
53 static_cast<HardwareDisplayPlaneAtomic*>(plane);
54 if (crtcs.empty() || crtcs.back().get() != atomic_plane->crtc())
55 crtcs.push_back(atomic_plane->crtc()->AsWeakPtr());
56 }
57
42 plane_list->plane_list.swap(plane_list->old_plane_list); 58 plane_list->plane_list.swap(plane_list->old_plane_list);
43 plane_list->plane_list.clear(); 59 plane_list->plane_list.clear();
44 if (!drm_->CommitProperties(plane_list->atomic_property_set.get(), 0, is_sync, 60 if (!drm_->CommitProperties(plane_list->atomic_property_set.get(), 0, is_sync,
45 base::Bind(&AtomicPageFlipCallback))) { 61 base::Bind(&AtomicPageFlipCallback, crtcs))) {
46 PLOG(ERROR) << "Failed to commit properties"; 62 PLOG(ERROR) << "Failed to commit properties";
47 return false; 63 return false;
48 } 64 }
65 plane_list->committed = true;
49 return true; 66 return true;
50 } 67 }
51 68
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);
62 }
63
64 bool HardwareDisplayPlaneManagerAtomic::SetPlaneData( 69 bool HardwareDisplayPlaneManagerAtomic::SetPlaneData(
65 HardwareDisplayPlaneList* plane_list, 70 HardwareDisplayPlaneList* plane_list,
66 HardwareDisplayPlane* hw_plane, 71 HardwareDisplayPlane* hw_plane,
67 const OverlayPlane& overlay, 72 const OverlayPlane& overlay,
68 uint32_t crtc_id, 73 uint32_t crtc_id,
69 const gfx::Rect& src_rect, 74 const gfx::Rect& src_rect,
70 CrtcController* crtc) { 75 CrtcController* crtc) {
71 HardwareDisplayPlaneAtomic* atomic_plane = 76 HardwareDisplayPlaneAtomic* atomic_plane =
72 static_cast<HardwareDisplayPlaneAtomic*>(hw_plane); 77 static_cast<HardwareDisplayPlaneAtomic*>(hw_plane);
73 if (!atomic_plane->SetPlaneData(plane_list->atomic_property_set.get(), 78 if (!atomic_plane->SetPlaneData(plane_list->atomic_property_set.get(),
74 crtc_id, overlay.buffer->GetFramebufferId(), 79 crtc_id, overlay.buffer->GetFramebufferId(),
75 overlay.display_bounds, src_rect)) { 80 overlay.display_bounds, src_rect)) {
76 LOG(ERROR) << "Failed to set plane properties"; 81 LOG(ERROR) << "Failed to set plane properties";
77 return false; 82 return false;
78 } 83 }
79 plane_list->plane_list.push_back(hw_plane); 84 atomic_plane->set_crtc(crtc);
80 return true; 85 return true;
81 } 86 }
82 87
83 scoped_ptr<HardwareDisplayPlane> HardwareDisplayPlaneManagerAtomic::CreatePlane( 88 scoped_ptr<HardwareDisplayPlane> HardwareDisplayPlaneManagerAtomic::CreatePlane(
84 uint32_t plane_id, 89 uint32_t plane_id,
85 uint32_t possible_crtcs) { 90 uint32_t possible_crtcs) {
86 return scoped_ptr<HardwareDisplayPlane>( 91 return scoped_ptr<HardwareDisplayPlane>(
87 new HardwareDisplayPlaneAtomic(plane_id, possible_crtcs)); 92 new HardwareDisplayPlaneAtomic(plane_id, possible_crtcs));
88 } 93 }
89 94
90 } // namespace ui 95 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698