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

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

Issue 2896173002: ozone: introduce OverlayCheckReturn_Params (Closed)
Patch Set: refactoring 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } 63 }
64 64
65 size_t size = candidates->size();
65 const auto& iter = cache_.Get(overlay_params); 66 const auto& iter = cache_.Get(overlay_params);
66 // We are still waiting on results for this candidate list from GPU. 67 if (iter != cache_.end()) {
67 if (iter != cache_.end() && iter->second) 68 // We are still waiting on results for this candidate list from GPU.
69 if (iter->second.back().status ==
70 OverlayCheckReturn_Params::Status::Pending)
71 return;
72
73 const std::vector<OverlayCheckReturn_Params>& returns = iter->second;
74 DCHECK(size == returns.size());
75 for (size_t i = 0; i < size; i++) {
76 DCHECK(returns[i].status == OverlayCheckReturn_Params::Status::Able ||
77 returns[i].status == OverlayCheckReturn_Params::Status::Not);
78 candidates->at(i).overlay_handled =
79 returns[i].status == OverlayCheckReturn_Params::Status::Able ? true
80 : false;
81 }
68 return; 82 return;
83 }
69 84
70 size_t size = candidates->size(); 85 // We can skip GPU side validation in case all candidates are invalid.
86 bool needs_gpu_validation = false;
87 for (size_t i = 0; i < size; i++) {
88 if (!overlay_params.at(i).is_overlay_candidate)
89 continue;
71 90
72 if (iter == cache_.end()) { 91 const OverlaySurfaceCandidate& candidate = candidates->at(i);
73 // We can skip GPU side validation in case all candidates are invalid. 92 if (!CanHandleCandidate(candidate, widget)) {
74 bool needs_gpu_validation = false; 93 DCHECK(candidate.plane_z_order != 0);
dnicoara 2017/06/02 21:31:25 Why did you removed the "overlay_params.at(i).is_o
dshwang 2017/06/02 23:59:00 I didn't like to change the key after querying `ca
75 for (size_t i = 0; i < size; i++) { 94 continue;
76 if (!overlay_params.at(i).is_overlay_candidate)
77 continue;
78
79 const OverlaySurfaceCandidate& candidate = candidates->at(i);
80 if (!CanHandleCandidate(candidate, widget)) {
81 DCHECK(candidate.plane_z_order != 0);
82 overlay_params.at(i).is_overlay_candidate = false;
83 continue;
84 }
85
86 needs_gpu_validation = true;
87 } 95 }
88 96
89 cache_.Put(overlay_params, needs_gpu_validation); 97 needs_gpu_validation = true;
98 }
90 99
91 if (needs_gpu_validation) 100 std::vector<OverlayCheckReturn_Params> returns(overlay_params.size());
92 SendOverlayValidationRequest(overlay_params, widget); 101 if (needs_gpu_validation) {
93 } else { 102 for (auto param : returns) {
94 const std::vector<OverlayCheck_Params>& validated_params = iter->first; 103 param.status = OverlayCheckReturn_Params::Status::Not;
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 } 104 }
101 } 105 }
106
107 cache_.Put(overlay_params, returns);
108
109 if (needs_gpu_validation)
110 SendOverlayValidationRequest(overlay_params, widget);
102 } 111 }
103 112
104 void DrmOverlayManager::ResetCache() { 113 void DrmOverlayManager::ResetCache() {
105 cache_.Clear(); 114 cache_.Clear();
106 } 115 }
107 116
108 void DrmOverlayManager::SendOverlayValidationRequest( 117 void DrmOverlayManager::SendOverlayValidationRequest(
109 const std::vector<OverlayCheck_Params>& new_params, 118 const std::vector<OverlayCheck_Params>& new_params,
110 gfx::AcceleratedWidget widget) const { 119 gfx::AcceleratedWidget widget) const {
111 if (!proxy_->IsConnected()) 120 if (!proxy_->IsConnected())
112 return; 121 return;
113 122
114 proxy_->GpuCheckOverlayCapabilities(widget, new_params); 123 proxy_->GpuCheckOverlayCapabilities(widget, new_params);
115 } 124 }
116 125
117 void DrmOverlayManager::GpuSentOverlayResult( 126 void DrmOverlayManager::GpuSentOverlayResult(
118 gfx::AcceleratedWidget widget, 127 gfx::AcceleratedWidget widget,
119 const std::vector<OverlayCheck_Params>& params) { 128 const std::vector<OverlayCheck_Params>& params,
120 cache_.Put(params, false); 129 const std::vector<OverlayCheckReturn_Params>& returns) {
dshwang 2017/05/31 21:05:11 It's the root of potential bug. params.back().is_
130 cache_.Put(params, returns);
121 } 131 }
122 132
123 bool DrmOverlayManager::CanHandleCandidate( 133 bool DrmOverlayManager::CanHandleCandidate(
124 const OverlaySurfaceCandidate& candidate, 134 const OverlaySurfaceCandidate& candidate,
125 gfx::AcceleratedWidget widget) const { 135 gfx::AcceleratedWidget widget) const {
126 if (candidate.buffer_size.IsEmpty()) 136 if (candidate.buffer_size.IsEmpty())
127 return false; 137 return false;
128 138
129 if (candidate.transform == gfx::OVERLAY_TRANSFORM_INVALID) 139 if (candidate.transform == gfx::OVERLAY_TRANSFORM_INVALID)
130 return false; 140 return false;
(...skipping 12 matching lines...) Expand all
143 } 153 }
144 154
145 if (candidate.is_clipped && 155 if (candidate.is_clipped &&
146 !candidate.clip_rect.Contains(candidate.quad_rect_in_target_space)) 156 !candidate.clip_rect.Contains(candidate.quad_rect_in_target_space))
147 return false; 157 return false;
148 158
149 return true; 159 return true;
150 } 160 }
151 161
152 } // namespace ui 162 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698