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

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

Issue 1314553002: Move Format checks to HardwareDisplayPlane (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes 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, false)) { 104 if (plane->Initialize(drm, supported_formats, false, false)) {
105 // CRTC controllers always assume they have a cursor plane and the cursor 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 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. 107 // track of Cursor plane here to avoid re-using it for any other purpose.
108 if (plane->type() != HardwareDisplayPlane::kCursor) 108 if (plane->type() != HardwareDisplayPlane::kCursor)
109 planes_.push_back(plane.Pass()); 109 planes_.push_back(plane.Pass());
110 } 110 }
111 } 111 }
112 112
113 // 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
114 // dummy plane for which we can assign exactly one overlay. 114 // dummy plane for which we can assign exactly one overlay.
115 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move 115 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move
116 // this workaround into HardwareDisplayPlaneLegacy. 116 // this workaround into HardwareDisplayPlaneLegacy.
117 if (!has_universal_planes) { 117 if (!has_universal_planes) {
118 for (int i = 0; i < resources->count_crtcs; ++i) { 118 for (int i = 0; i < resources->count_crtcs; ++i) {
119 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { 119 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) {
120 scoped_ptr<HardwareDisplayPlane> dummy_plane( 120 scoped_ptr<HardwareDisplayPlane> dummy_plane(
121 CreatePlane(resources->crtcs[i] - 1, (1 << i))); 121 CreatePlane(resources->crtcs[i] - 1, (1 << i)));
122 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true)) { 122 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true,
123 false)) {
123 planes_.push_back(dummy_plane.Pass()); 124 planes_.push_back(dummy_plane.Pass());
124 } 125 }
125 } 126 }
126 } 127 }
127 } 128 }
128 129
129 std::sort(planes_.begin(), planes_.end(), 130 std::sort(planes_.begin(), planes_.end(),
130 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { 131 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) {
131 return l->plane_id() < r->plane_id(); 132 return l->plane_id() < r->plane_id();
132 }); 133 });
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 uint32_t crtc_id, 176 uint32_t crtc_id,
176 CrtcController* crtc) { 177 CrtcController* crtc) {
177 int crtc_index = LookupCrtcIndex(crtc_id); 178 int crtc_index = LookupCrtcIndex(crtc_id);
178 if (crtc_index < 0) { 179 if (crtc_index < 0) {
179 LOG(ERROR) << "Cannot find crtc " << crtc_id; 180 LOG(ERROR) << "Cannot find crtc " << crtc_id;
180 return false; 181 return false;
181 } 182 }
182 183
183 size_t plane_idx = 0; 184 size_t plane_idx = 0;
184 for (const auto& plane : overlay_list) { 185 for (const auto& plane : overlay_list) {
185 HardwareDisplayPlane* hw_plane = 186 HardwareDisplayPlane* hw_plane = FindNextUnusedPlane(
186 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat()); 187 &plane_idx, crtc_index, plane.buffer->GetFramebufferPixelFormat());
187 if (!hw_plane) { 188 if (!hw_plane) {
188 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; 189 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id;
189 return false; 190 return false;
190 } 191 }
191 192
192 gfx::Rect fixed_point_rect; 193 gfx::Rect fixed_point_rect;
193 if (hw_plane->type() != HardwareDisplayPlane::kDummy) { 194 if (hw_plane->type() != HardwareDisplayPlane::kDummy) {
194 const gfx::Size& size = plane.buffer->GetSize(); 195 const gfx::Size& size = plane.buffer->GetSize();
195 gfx::RectF crop_rect = plane.crop_rect; 196 gfx::RectF crop_rect = plane.crop_rect;
196 crop_rect.Scale(size.width(), size.height()); 197 crop_rect.Scale(size.width(), size.height());
(...skipping 14 matching lines...) Expand all
211 crtc)) { 212 crtc)) {
212 hw_plane->set_in_use(true); 213 hw_plane->set_in_use(true);
213 } else { 214 } else {
214 return false; 215 return false;
215 } 216 }
216 } 217 }
217 return true; 218 return true;
218 } 219 }
219 220
220 } // namespace ui 221 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698