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

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

Issue 1294113005: Atomic: Don’t keep track of Cursor planes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fix Created 5 years, 3 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 <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 uint32_t formats_size = drm_plane->count_formats; 95 uint32_t formats_size = drm_plane->count_formats;
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 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); 98 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs));
99 99
100 std::vector<uint32_t> supported_formats(formats_size); 100 std::vector<uint32_t> supported_formats(formats_size);
101 for (uint32_t j = 0; j < formats_size; j++) 101 for (uint32_t j = 0; j < formats_size; j++)
102 supported_formats.push_back(drm_plane->formats[j]); 102 supported_formats.push_back(drm_plane->formats[j]);
103 103
104 if (plane->Initialize(drm, supported_formats)) { 104 if (plane->Initialize(drm, supported_formats, false)) {
105 planes_.push_back(plane.Pass()); 105 // CRTC controllers always assume they have a cursor plane and the cursor
106 // plane is updated via cursor specific DRM API. Hence, we dont keep
107 // track of Cursor plane here to avoid re-using it for any other purpose.
108 if (plane->type() != HardwareDisplayPlane::kCursor)
109 planes_.push_back(plane.Pass());
106 } 110 }
107 } 111 }
108 112
109 // crbug.com/464085: if driver reports no primary planes for a crtc, create a 113 // crbug.com/464085: if driver reports no primary planes for a crtc, create a
110 // dummy plane for which we can assign exactly one overlay. 114 // dummy plane for which we can assign exactly one overlay.
111 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move 115 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move
112 // this workaround into HardwareDisplayPlaneLegacy. 116 // this workaround into HardwareDisplayPlaneLegacy.
113 if (!has_universal_planes) { 117 if (!has_universal_planes) {
114 for (int i = 0; i < resources->count_crtcs; ++i) { 118 for (int i = 0; i < resources->count_crtcs; ++i) {
115 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { 119 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) {
116 scoped_ptr<HardwareDisplayPlane> dummy_plane( 120 scoped_ptr<HardwareDisplayPlane> dummy_plane(
117 CreatePlane(resources->crtcs[i] - 1, (1 << i))); 121 CreatePlane(resources->crtcs[i] - 1, (1 << i)));
118 dummy_plane->set_is_dummy(true); 122 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true)) {
119 if (dummy_plane->Initialize(drm, std::vector<uint32_t>())) {
120 planes_.push_back(dummy_plane.Pass()); 123 planes_.push_back(dummy_plane.Pass());
121 } 124 }
122 } 125 }
123 } 126 }
124 } 127 }
125 128
126 std::sort(planes_.begin(), planes_.end(), 129 std::sort(planes_.begin(), planes_.end(),
127 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { 130 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) {
128 return l->plane_id() < r->plane_id(); 131 return l->plane_id() < r->plane_id();
129 }); 132 });
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 size_t plane_idx = 0; 183 size_t plane_idx = 0;
181 for (const auto& plane : overlay_list) { 184 for (const auto& plane : overlay_list) {
182 HardwareDisplayPlane* hw_plane = 185 HardwareDisplayPlane* hw_plane =
183 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat()); 186 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat());
184 if (!hw_plane) { 187 if (!hw_plane) {
185 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; 188 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id;
186 return false; 189 return false;
187 } 190 }
188 191
189 gfx::Rect fixed_point_rect; 192 gfx::Rect fixed_point_rect;
190 if (!hw_plane->is_dummy()) { 193 if (hw_plane->type() != HardwareDisplayPlane::kDummy) {
191 const gfx::Size& size = plane.buffer->GetSize(); 194 const gfx::Size& size = plane.buffer->GetSize();
192 gfx::RectF crop_rect = plane.crop_rect; 195 gfx::RectF crop_rect = plane.crop_rect;
193 crop_rect.Scale(size.width(), size.height()); 196 crop_rect.Scale(size.width(), size.height());
194 197
195 // This returns a number in 16.16 fixed point, required by the DRM overlay 198 // This returns a number in 16.16 fixed point, required by the DRM overlay
196 // APIs. 199 // APIs.
197 auto to_fixed_point = 200 auto to_fixed_point =
198 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; 201 [](double v) -> uint32_t { return v * kFixedPointScaleValue; };
199 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), 202 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()),
200 to_fixed_point(crop_rect.y()), 203 to_fixed_point(crop_rect.y()),
201 to_fixed_point(crop_rect.width()), 204 to_fixed_point(crop_rect.width()),
202 to_fixed_point(crop_rect.height())); 205 to_fixed_point(crop_rect.height()));
203 } 206 }
204 207
205 plane_list->plane_list.push_back(hw_plane); 208 plane_list->plane_list.push_back(hw_plane);
206 hw_plane->set_owning_crtc(crtc_id); 209 hw_plane->set_owning_crtc(crtc_id);
207 if (SetPlaneData(plane_list, hw_plane, plane, crtc_id, fixed_point_rect, 210 if (SetPlaneData(plane_list, hw_plane, plane, crtc_id, fixed_point_rect,
208 crtc)) { 211 crtc)) {
209 hw_plane->set_in_use(true); 212 hw_plane->set_in_use(true);
210 } else { 213 } else {
211 return false; 214 return false;
212 } 215 }
213 } 216 }
214 return true; 217 return true;
215 } 218 }
216 219
217 } // namespace ui 220 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698