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

Side by Side Diff: ui/ozone/platform/drm/host/drm_overlay_manager.cc

Issue 2896173002: ozone: introduce OverlayCheckReturn_Params (Closed)
Patch Set: ozone: fix broken overlay promotion. Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_manager.h" 5 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 overlay_params.back().is_overlay_candidate = false; 53 overlay_params.back().is_overlay_candidate = false;
54 continue; 54 continue;
55 } 55 }
56 56
57 // Compositor doesn't have information about the total size of primary 57 // Compositor doesn't have information about the total size of primary
58 // candidate. We get this information from display rect. 58 // candidate. We get this information from display rect.
59 if (candidate.plane_z_order == 0) 59 if (candidate.plane_z_order == 0)
60 candidate.buffer_size = gfx::ToNearestRect(candidate.display_rect).size(); 60 candidate.buffer_size = gfx::ToNearestRect(candidate.display_rect).size();
61 61
62 overlay_params.push_back(OverlayCheck_Params(candidate)); 62 overlay_params.push_back(OverlayCheck_Params(candidate));
63
64 if (!CanHandleCandidate(candidate, widget)) {
65 DCHECK(candidate.plane_z_order != 0);
66 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 :)
67 }
63 } 68 }
64 69
70 size_t size = candidates->size();
65 const auto& iter = cache_.Get(overlay_params); 71 const auto& iter = cache_.Get(overlay_params);
66 // We are still waiting on results for this candidate list from GPU. 72 if (iter != cache_.end()) {
67 if (iter != cache_.end() && iter->second) 73 // We are still waiting on results for this candidate list from GPU.
74 if (iter->second.back().status ==
75 OverlayCheckReturn_Params::Status::PENDING)
76 return;
77
78 const std::vector<OverlayCheckReturn_Params>& returns = iter->second;
79 DCHECK(size == returns.size());
80 for (size_t i = 0; i < size; i++) {
81 DCHECK(returns[i].status == OverlayCheckReturn_Params::Status::ABLE ||
82 returns[i].status == OverlayCheckReturn_Params::Status::NOT);
83 candidates->at(i).overlay_handled =
84 returns[i].status == OverlayCheckReturn_Params::Status::ABLE ? true
85 : false;
86 }
68 return; 87 return;
88 }
69 89
70 size_t size = candidates->size(); 90 // We can skip GPU side validation in case all candidates are invalid.
91 bool needs_gpu_validation = false;
92 for (size_t i = 0; i < size; i++) {
93 if (!overlay_params.at(i).is_overlay_candidate)
94 continue;
71 95
72 if (iter == cache_.end()) { 96 needs_gpu_validation = true;
73 // We can skip GPU side validation in case all candidates are invalid. 97 }
74 bool needs_gpu_validation = false;
75 for (size_t i = 0; i < size; i++) {
76 if (!overlay_params.at(i).is_overlay_candidate)
77 continue;
78 98
79 const OverlaySurfaceCandidate& candidate = candidates->at(i); 99 std::vector<OverlayCheckReturn_Params> returns(overlay_params.size());
80 if (!CanHandleCandidate(candidate, widget)) { 100 if (needs_gpu_validation) {
81 DCHECK(candidate.plane_z_order != 0); 101 for (auto param : returns) {
82 overlay_params.at(i).is_overlay_candidate = false; 102 param.status = OverlayCheckReturn_Params::Status::NOT;
83 continue;
84 }
85
86 needs_gpu_validation = true;
87 }
88
89 cache_.Put(overlay_params, needs_gpu_validation);
90
91 if (needs_gpu_validation)
92 SendOverlayValidationRequest(overlay_params, widget);
93 } else {
94 const std::vector<OverlayCheck_Params>& validated_params = iter->first;
95 DCHECK(size == validated_params.size());
96
97 for (size_t i = 0; i < size; i++) {
98 candidates->at(i).overlay_handled =
99 validated_params.at(i).is_overlay_candidate;
100 } 103 }
101 } 104 }
105
106 cache_.Put(overlay_params, returns);
107
108 if (needs_gpu_validation)
109 SendOverlayValidationRequest(overlay_params, widget);
102 } 110 }
103 111
104 void DrmOverlayManager::ResetCache() { 112 void DrmOverlayManager::ResetCache() {
105 cache_.Clear(); 113 cache_.Clear();
106 } 114 }
107 115
108 void DrmOverlayManager::SendOverlayValidationRequest( 116 void DrmOverlayManager::SendOverlayValidationRequest(
109 const std::vector<OverlayCheck_Params>& new_params, 117 const std::vector<OverlayCheck_Params>& new_params,
110 gfx::AcceleratedWidget widget) const { 118 gfx::AcceleratedWidget widget) const {
111 if (!proxy_->IsConnected()) 119 if (!proxy_->IsConnected())
112 return; 120 return;
113 121
114 proxy_->GpuCheckOverlayCapabilities(widget, new_params); 122 proxy_->GpuCheckOverlayCapabilities(widget, new_params);
115 } 123 }
116 124
117 void DrmOverlayManager::GpuSentOverlayResult( 125 void DrmOverlayManager::GpuSentOverlayResult(
118 gfx::AcceleratedWidget widget, 126 gfx::AcceleratedWidget widget,
119 const std::vector<OverlayCheck_Params>& params) { 127 const std::vector<OverlayCheck_Params>& params,
120 cache_.Put(params, false); 128 const std::vector<OverlayCheckReturn_Params>& returns) {
129 cache_.Put(params, returns);
121 } 130 }
122 131
123 bool DrmOverlayManager::CanHandleCandidate( 132 bool DrmOverlayManager::CanHandleCandidate(
124 const OverlaySurfaceCandidate& candidate, 133 const OverlaySurfaceCandidate& candidate,
125 gfx::AcceleratedWidget widget) const { 134 gfx::AcceleratedWidget widget) const {
126 if (candidate.buffer_size.IsEmpty()) 135 if (candidate.buffer_size.IsEmpty())
127 return false; 136 return false;
128 137
129 if (candidate.transform == gfx::OVERLAY_TRANSFORM_INVALID) 138 if (candidate.transform == gfx::OVERLAY_TRANSFORM_INVALID)
130 return false; 139 return false;
(...skipping 12 matching lines...) Expand all
143 } 152 }
144 153
145 if (candidate.is_clipped && 154 if (candidate.is_clipped &&
146 !candidate.clip_rect.Contains(candidate.quad_rect_in_target_space)) 155 !candidate.clip_rect.Contains(candidate.quad_rect_in_target_space))
147 return false; 156 return false;
148 157
149 return true; 158 return true;
150 } 159 }
151 160
152 } // namespace ui 161 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_overlay_manager.h ('k') | ui/ozone/platform/drm/mus_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698