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

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

Issue 1157793004: ozone: Add overlay candidate implementation that queries support via IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
(Empty)
1 #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h"
2
3 #include <algorithm>
4
5 #include "ui/gfx/geometry/rect_conversions.h"
6 #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
7 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
8
9 namespace ui {
10
11 namespace {
12 const size_t kMaxCacheSize = 10000;
spang 2015/06/01 23:23:51 How likely do we expect a config to be reused >>10
achaulk 2015/06/02 14:37:43 Well it depends. The answers are generally conside
spang 2015/06/02 17:14:34 Yeah, the space of configurations is very large. S
achaulk 2015/06/02 19:38:38 Done.
13 } // namespace
14
15 bool DrmOverlayCandidatesHost::OverlayCompare::operator()(
16 const OverlayCheck_Params& l,
17 const OverlayCheck_Params& r) {
18 return l.plane_z_order < r.plane_z_order ||
spang 2015/06/01 23:23:51 Can you split this into multiple statements?
achaulk 2015/06/02 19:38:38 Done.
19 (l.plane_z_order == r.plane_z_order &&
20 (l.display_rect < r.display_rect ||
21 (l.display_rect == r.display_rect &&
22 (l.format < r.format ||
23 (l.format == r.format &&
24 (l.transform < r.transform ||
25 (l.transform == r.transform &&
26 (l.buffer_size.width() < r.buffer_size.width() ||
27 (l.buffer_size.width() == r.buffer_size.width() &&
28 l.buffer_size.height() < r.buffer_size.height())))))))));
29 }
30
31 DrmOverlayCandidatesHost::DrmOverlayCandidatesHost(
32 gfx::AcceleratedWidget widget,
33 DrmGpuPlatformSupportHost* platform_support)
34 : widget_(widget), platform_support_(platform_support) {
35 platform_support_->RegisterHandler(this);
36 }
37
38 DrmOverlayCandidatesHost::~DrmOverlayCandidatesHost() {
39 platform_support_->UnregisterHandler(this);
40 }
41
42 void DrmOverlayCandidatesHost::CheckOverlaySupport(
43 OverlaySurfaceCandidateList* candidates) {
44 if (candidates->size() == 2)
45 CheckSingleOverlay(candidates);
46 }
47
48 void DrmOverlayCandidatesHost::CheckSingleOverlay(
49 OverlaySurfaceCandidateList* candidates) {
50 OverlayCandidatesOzone::OverlaySurfaceCandidate* first = &(*candidates)[0];
51 OverlayCandidatesOzone::OverlaySurfaceCandidate* second = &(*candidates)[1];
52 OverlayCandidatesOzone::OverlaySurfaceCandidate* overlay;
53 if (first->plane_z_order == 0) {
54 overlay = second;
55 } else if (second->plane_z_order == 0) {
56 overlay = first;
57 } else {
58 return;
59 }
60 // 0.01 constant chosen to match DCHECKs in gfx::ToNearestRect and avoid
61 // that code asserting on quads that we accept.
62 if (!gfx::IsNearestRectWithinDistance(overlay->display_rect, 0.01f))
63 return;
64 if (overlay->transform == gfx::OVERLAY_TRANSFORM_INVALID)
65 return;
66
67 OverlayCheck_Params lookup(*overlay);
68 auto iter = cache_.find(lookup);
69 if (iter == cache_.end()) {
70 if (cache_.size() > kMaxCacheSize)
71 cache_.clear();
72 cache_[lookup] = false;
73 SendRequest(*candidates, lookup);
74 } else {
75 overlay->overlay_handled = iter->second;
76 }
77 }
78
79 void DrmOverlayCandidatesHost::OnChannelEstablished(
80 int host_id,
81 scoped_refptr<base::SingleThreadTaskRunner> send_runner,
82 const base::Callback<void(IPC::Message*)>& sender) {
83 }
84
85 void DrmOverlayCandidatesHost::OnChannelDestroyed(int host_id) {
86 }
87
88 bool DrmOverlayCandidatesHost::OnMessageReceived(const IPC::Message& message) {
89 bool handled = false;
90 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(DrmOverlayCandidatesHost, message, &handled)
91 IPC_MESSAGE_FORWARD(OzoneHostMsg_OverlayCapabilitiesReceived, this,
92 DrmOverlayCandidatesHost::OnOverlayResult)
93 IPC_END_MESSAGE_MAP()
94 return handled;
95 }
96
97 void DrmOverlayCandidatesHost::SendRequest(
98 const OverlaySurfaceCandidateList& candidates,
99 const OverlayCheck_Params& check) {
100 if (!platform_support_->IsConnected())
101 return;
102 pending_checks_.push_back(check);
103 std::vector<OverlayCheck_Params> list;
104 for (const auto& candidate : candidates)
105 list.push_back(OverlayCheck_Params(candidate));
106 platform_support_->Send(
107 new OzoneGpuMsg_CheckOverlayCapabilities(widget_, list));
108 }
109
110 void DrmOverlayCandidatesHost::OnOverlayResult(bool* handled,
111 gfx::AcceleratedWidget widget,
112 bool result) {
113 if (widget != widget_)
114 return;
115 *handled = true;
116 DCHECK(!pending_checks_.empty());
117 ProcessResult(pending_checks_.front(), result);
118 pending_checks_.pop_front();
119 }
120
121 void DrmOverlayCandidatesHost::ProcessResult(const OverlayCheck_Params& check,
122 bool result) {
123 if (result)
124 cache_[check] = true;
spang 2015/06/01 23:23:51 Should we also cache negative results?
achaulk 2015/06/02 14:37:43 Everything defaults to negative when it's added, s
spang 2015/06/02 17:14:34 Ah I see it now, thanks.
125 }
126
127 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_overlay_candidates_host.h ('k') | ui/ozone/platform/drm/host/drm_overlay_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698