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

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

Issue 994503004: Preliminary atomic patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change gyp var Created 5 years, 9 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.h" 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <xf86drm.h> 8 #include <xf86drm.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::set<uint32_t> plane_ids; 88 std::set<uint32_t> plane_ids;
89 for (uint32_t i = 0; i < num_planes; ++i) { 89 for (uint32_t i = 0; i < num_planes; ++i) {
90 ScopedDrmPlanePtr drm_plane( 90 ScopedDrmPlanePtr drm_plane(
91 drmModeGetPlane(drm->get_fd(), plane_resources->planes[i])); 91 drmModeGetPlane(drm->get_fd(), plane_resources->planes[i]));
92 if (!drm_plane) { 92 if (!drm_plane) {
93 PLOG(ERROR) << "Failed to get plane " << i; 93 PLOG(ERROR) << "Failed to get plane " << i;
94 return false; 94 return false;
95 } 95 }
96 plane_ids.insert(drm_plane->plane_id); 96 plane_ids.insert(drm_plane->plane_id);
97 scoped_ptr<HardwareDisplayPlane> plane( 97 scoped_ptr<HardwareDisplayPlane> plane(
98 new HardwareDisplayPlane(drm_plane.Pass())); 98 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs));
99 if (plane->Initialize(drm)) 99 if (plane->Initialize(drm))
100 planes_.push_back(plane.release()); 100 planes_.push_back(plane.release());
101 } 101 }
102 102
103 // crbug.com/464085: if driver reports no primary planes for a crtc, create a 103 // crbug.com/464085: if driver reports no primary planes for a crtc, create a
104 // dummy plane for which we can assign exactly one overlay. 104 // dummy plane for which we can assign exactly one overlay.
105 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move 105 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move
106 // this workaround into HardwareDisplayPlaneLegacy. 106 // this workaround into HardwareDisplayPlaneLegacy.
107 for (int i = 0; i < resources->count_crtcs; ++i) { 107 for (int i = 0; i < resources->count_crtcs; ++i) {
108 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { 108 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) {
109 scoped_ptr<HardwareDisplayPlane> dummy_plane( 109 scoped_ptr<HardwareDisplayPlane> dummy_plane(
110 new HardwareDisplayPlane(0, (1 << i))); 110 CreatePlane(resources->crtcs[i] - 1, (1 << i)));
111 dummy_plane->set_is_dummy(true); 111 dummy_plane->set_is_dummy(true);
112 if (dummy_plane->Initialize(drm)) 112 if (dummy_plane->Initialize(drm))
113 planes_.push_back(dummy_plane.release()); 113 planes_.push_back(dummy_plane.release());
114 } 114 }
115 } 115 }
116 116
117 std::sort(planes_.begin(), planes_.end(), 117 std::sort(planes_.begin(), planes_.end(),
118 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { 118 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) {
119 return l->plane_id() < r->plane_id(); 119 return l->plane_id() < r->plane_id();
120 }); 120 });
121 return true; 121 return true;
122 } 122 }
123 123
124 scoped_ptr<HardwareDisplayPlane> HardwareDisplayPlaneManager::CreatePlane(
125 uint32_t plane_id,
126 uint32_t possible_crtcs) {
127 return scoped_ptr<HardwareDisplayPlane>(
128 new HardwareDisplayPlane(plane_id, possible_crtcs));
129 }
130
124 HardwareDisplayPlane* HardwareDisplayPlaneManager::FindNextUnusedPlane( 131 HardwareDisplayPlane* HardwareDisplayPlaneManager::FindNextUnusedPlane(
125 size_t* index, 132 size_t* index,
126 uint32_t crtc_index) { 133 uint32_t crtc_index) {
127 for (size_t i = *index; i < planes_.size(); ++i) { 134 for (size_t i = *index; i < planes_.size(); ++i) {
128 auto plane = planes_[i]; 135 auto plane = planes_[i];
129 if (!plane->in_use() && plane->CanUseForCrtc(crtc_index)) { 136 if (!plane->in_use() && plane->CanUseForCrtc(crtc_index)) {
130 *index = i + 1; 137 *index = i + 1;
131 return plane; 138 return plane;
132 } 139 }
133 } 140 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (plane->owning_crtc() == crtc_id) { 213 if (plane->owning_crtc() == crtc_id) {
207 plane->set_owning_crtc(0); 214 plane->set_owning_crtc(0);
208 plane->set_in_use(false); 215 plane->set_in_use(false);
209 } else { 216 } else {
210 plane_list->old_plane_list.push_back(plane); 217 plane_list->old_plane_list.push_back(plane);
211 } 218 }
212 } 219 }
213 } 220 }
214 221
215 } // namespace ui 222 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698