Chromium Code Reviews| Index: ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| diff --git a/ui/ozone/platform/drm/host/drm_overlay_manager.cc b/ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| index c6795d36e6ebfdcceb4566f34c406d4327a0188c..b45a6645c4bf982777a3e4c6bc89e0ae03fea7bd 100644 |
| --- a/ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| +++ b/ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| @@ -60,45 +60,53 @@ void DrmOverlayManager::CheckOverlaySupport( |
| candidate.buffer_size = gfx::ToNearestRect(candidate.display_rect).size(); |
| overlay_params.push_back(OverlayCheck_Params(candidate)); |
| - } |
| - const auto& iter = cache_.Get(overlay_params); |
| - // We are still waiting on results for this candidate list from GPU. |
| - if (iter != cache_.end() && iter->second) |
| - return; |
| + if (!CanHandleCandidate(candidate, widget)) { |
| + DCHECK(candidate.plane_z_order != 0); |
| + overlay_params.back().is_overlay_candidate = false; |
|
dshwang
2017/06/02 23:59:00
move this logic to here. now the key is same, no m
dnicoara
2017/06/05 21:05:09
Nice cleanup! Thanks :)
|
| + } |
| + } |
| size_t size = candidates->size(); |
| - |
| - if (iter == cache_.end()) { |
| - // We can skip GPU side validation in case all candidates are invalid. |
| - bool needs_gpu_validation = false; |
| + const auto& iter = cache_.Get(overlay_params); |
| + if (iter != cache_.end()) { |
| + // We are still waiting on results for this candidate list from GPU. |
| + if (iter->second.back().status == |
| + OverlayCheckReturn_Params::Status::PENDING) |
| + return; |
| + |
| + const std::vector<OverlayCheckReturn_Params>& returns = iter->second; |
| + DCHECK(size == returns.size()); |
| for (size_t i = 0; i < size; i++) { |
| - if (!overlay_params.at(i).is_overlay_candidate) |
| - continue; |
| - |
| - const OverlaySurfaceCandidate& candidate = candidates->at(i); |
| - if (!CanHandleCandidate(candidate, widget)) { |
| - DCHECK(candidate.plane_z_order != 0); |
| - overlay_params.at(i).is_overlay_candidate = false; |
| - continue; |
| - } |
| - |
| - needs_gpu_validation = true; |
| + DCHECK(returns[i].status == OverlayCheckReturn_Params::Status::ABLE || |
| + returns[i].status == OverlayCheckReturn_Params::Status::NOT); |
| + candidates->at(i).overlay_handled = |
| + returns[i].status == OverlayCheckReturn_Params::Status::ABLE ? true |
| + : false; |
| } |
| + return; |
| + } |
| - cache_.Put(overlay_params, needs_gpu_validation); |
| + // We can skip GPU side validation in case all candidates are invalid. |
| + bool needs_gpu_validation = false; |
| + for (size_t i = 0; i < size; i++) { |
| + if (!overlay_params.at(i).is_overlay_candidate) |
| + continue; |
| - if (needs_gpu_validation) |
| - SendOverlayValidationRequest(overlay_params, widget); |
| - } else { |
| - const std::vector<OverlayCheck_Params>& validated_params = iter->first; |
| - DCHECK(size == validated_params.size()); |
| + needs_gpu_validation = true; |
| + } |
| - for (size_t i = 0; i < size; i++) { |
| - candidates->at(i).overlay_handled = |
| - validated_params.at(i).is_overlay_candidate; |
| + std::vector<OverlayCheckReturn_Params> returns(overlay_params.size()); |
| + if (needs_gpu_validation) { |
| + for (auto param : returns) { |
| + param.status = OverlayCheckReturn_Params::Status::NOT; |
| } |
| } |
| + |
| + cache_.Put(overlay_params, returns); |
| + |
| + if (needs_gpu_validation) |
| + SendOverlayValidationRequest(overlay_params, widget); |
| } |
| void DrmOverlayManager::ResetCache() { |
| @@ -116,8 +124,9 @@ void DrmOverlayManager::SendOverlayValidationRequest( |
| void DrmOverlayManager::GpuSentOverlayResult( |
| gfx::AcceleratedWidget widget, |
| - const std::vector<OverlayCheck_Params>& params) { |
| - cache_.Put(params, false); |
| + const std::vector<OverlayCheck_Params>& params, |
| + const std::vector<OverlayCheckReturn_Params>& returns) { |
| + cache_.Put(params, returns); |
| } |
| bool DrmOverlayManager::CanHandleCandidate( |