| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/host/drm_overlay_candidates_host.h" | 5 #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/gfx/geometry/rect_conversions.h" | 9 #include "ui/gfx/geometry/rect_conversions.h" |
| 10 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 10 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const std::vector<OverlayCheck_Params>& params) { | 174 const std::vector<OverlayCheck_Params>& params) { |
| 175 if (widget != window_->GetAcceleratedWidget()) | 175 if (widget != window_->GetAcceleratedWidget()) |
| 176 return; | 176 return; |
| 177 | 177 |
| 178 *handled = true; | 178 *handled = true; |
| 179 for (const auto& check : params) { | 179 for (const auto& check : params) { |
| 180 // We expect params to contain only supported configurations. | 180 // We expect params to contain only supported configurations. |
| 181 cache_.Put(check, true); | 181 cache_.Put(check, true); |
| 182 for (const auto& plane_id : check.plane_ids) { | 182 for (const auto& plane_id : check.plane_ids) { |
| 183 bool plane_found = false; | 183 bool plane_found = false; |
| 184 for (const auto* plane : hardware_plane_proxy_) { | 184 for (const auto& plane : hardware_plane_proxy_) { |
| 185 if (plane->plane_id == plane_id) { | 185 if (plane->plane_id == plane_id) { |
| 186 plane_found = true; | 186 plane_found = true; |
| 187 break; | 187 break; |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (!plane_found) { | 191 if (!plane_found) { |
| 192 hardware_plane_proxy_.push_back( | 192 hardware_plane_proxy_.push_back( |
| 193 make_scoped_ptr(new HardwareDisplayPlaneProxy(plane_id))); | 193 make_scoped_ptr(new HardwareDisplayPlaneProxy(plane_id))); |
| 194 } | 194 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 auto iter = cache_.Peek(lookup); | 260 auto iter = cache_.Peek(lookup); |
| 261 DCHECK(iter != cache_.end()); | 261 DCHECK(iter != cache_.end()); |
| 262 if (!iter->second) | 262 if (!iter->second) |
| 263 continue; | 263 continue; |
| 264 | 264 |
| 265 in_use_compatible_params_[iter->first] = false; | 265 in_use_compatible_params_[iter->first] = false; |
| 266 compatible_candidates.push_back(std::make_pair(&candidate, iter->first)); | 266 compatible_candidates.push_back(std::make_pair(&candidate, iter->first)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 uint32_t available_overlays = hardware_plane_proxy_.size(); | 269 uint32_t available_overlays = hardware_plane_proxy_.size(); |
| 270 for (auto* plane : hardware_plane_proxy_) | 270 for (const auto& plane : hardware_plane_proxy_) |
| 271 plane->in_use = false; | 271 plane->in_use = false; |
| 272 | 272 |
| 273 // Sort in decending order w.r.t weight. | 273 // Sort in decending order w.r.t weight. |
| 274 std::sort(compatible_candidates.begin(), compatible_candidates.end(), | 274 std::sort(compatible_candidates.begin(), compatible_candidates.end(), |
| 275 [](const CandidatePair& l, const CandidatePair& r) { | 275 [](const CandidatePair& l, const CandidatePair& r) { |
| 276 return l.second.weight > r.second.weight; | 276 return l.second.weight > r.second.weight; |
| 277 }); | 277 }); |
| 278 | 278 |
| 279 // Make sure we don't handle more candidates than what we can support in | 279 // Make sure we don't handle more candidates than what we can support in |
| 280 // GPU side. | 280 // GPU side. |
| 281 for (const auto& candidate : compatible_candidates) { | 281 for (const auto& candidate : compatible_candidates) { |
| 282 for (auto* plane : hardware_plane_proxy_) { | 282 for (const auto& plane : hardware_plane_proxy_) { |
| 283 // Plane is already in use. | 283 // Plane is already in use. |
| 284 if (plane->in_use) | 284 if (plane->in_use) |
| 285 continue; | 285 continue; |
| 286 | 286 |
| 287 for (const auto& plane_id : candidate.second.plane_ids) { | 287 for (const auto& plane_id : candidate.second.plane_ids) { |
| 288 if (plane->plane_id == plane_id) { | 288 if (plane->plane_id == plane_id) { |
| 289 available_overlays--; | 289 available_overlays--; |
| 290 auto iter = in_use_compatible_params_.find(candidate.second); | 290 auto iter = in_use_compatible_params_.find(candidate.second); |
| 291 DCHECK(iter != in_use_compatible_params_.end()); | 291 DCHECK(iter != in_use_compatible_params_.end()); |
| 292 iter->second = true; | 292 iter->second = true; |
| 293 candidate.first->overlay_handled = true; | 293 candidate.first->overlay_handled = true; |
| 294 plane->in_use = true; | 294 plane->in_use = true; |
| 295 break; | 295 break; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 // We have succefully found a plane. | 299 // We have succefully found a plane. |
| 300 if (plane->in_use) | 300 if (plane->in_use) |
| 301 break; | 301 break; |
| 302 } | 302 } |
| 303 | 303 |
| 304 // We dont have any free hardware resources. | 304 // We dont have any free hardware resources. |
| 305 if (!available_overlays) | 305 if (!available_overlays) |
| 306 break; | 306 break; |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace ui | 310 } // namespace ui |
| OLD | NEW |