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

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

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 years, 4 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 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h"
6
7 #include <algorithm>
8
9 #include "ui/gfx/geometry/rect_conversions.h"
10 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
11 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
12
13 namespace ui {
14
15 namespace {
16 const size_t kMaxCacheSize = 100;
17 } // namespace
18
19 bool DrmOverlayCandidatesHost::OverlayCompare::operator()(
20 const OverlayCheck_Params& l,
21 const OverlayCheck_Params& r) {
22 if (l.plane_z_order < r.plane_z_order)
23 return true;
24 if (l.plane_z_order > r.plane_z_order)
25 return false;
26 if (l.display_rect < r.display_rect)
27 return true;
28 if (l.display_rect != r.display_rect)
29 return false;
30 if (l.format < r.format)
31 return true;
32 if (l.format > r.format)
33 return false;
34 if (l.transform < r.transform)
35 return true;
36 if (l.transform > r.transform)
37 return false;
38 if (l.buffer_size.width() < r.buffer_size.width())
39 return true;
40 if (l.buffer_size.width() > r.buffer_size.width())
41 return false;
42 return l.buffer_size.height() < r.buffer_size.height();
43 }
44
45 DrmOverlayCandidatesHost::DrmOverlayCandidatesHost(
46 gfx::AcceleratedWidget widget,
47 DrmGpuPlatformSupportHost* platform_support)
48 : widget_(widget),
49 platform_support_(platform_support),
50 cache_(kMaxCacheSize) {
51 }
52
53 DrmOverlayCandidatesHost::~DrmOverlayCandidatesHost() {
54 }
55
56 void DrmOverlayCandidatesHost::CheckOverlaySupport(
57 OverlaySurfaceCandidateList* candidates) {
58 if (candidates->size() == 2)
59 CheckSingleOverlay(candidates);
60 }
61
62 void DrmOverlayCandidatesHost::CheckSingleOverlay(
63 OverlaySurfaceCandidateList* candidates) {
64 OverlayCandidatesOzone::OverlaySurfaceCandidate* first = &(*candidates)[0];
65 OverlayCandidatesOzone::OverlaySurfaceCandidate* second = &(*candidates)[1];
66 OverlayCandidatesOzone::OverlaySurfaceCandidate* overlay;
67 if (first->plane_z_order == 0) {
68 overlay = second;
69 } else if (second->plane_z_order == 0) {
70 overlay = first;
71 } else {
72 return;
73 }
74 // 0.01 constant chosen to match DCHECKs in gfx::ToNearestRect and avoid
75 // that code asserting on quads that we accept.
76 if (!gfx::IsNearestRectWithinDistance(overlay->display_rect, 0.01f))
77 return;
78 if (overlay->transform == gfx::OVERLAY_TRANSFORM_INVALID)
79 return;
80
81 OverlayCheck_Params lookup(*overlay);
82 auto iter = cache_.Get(lookup);
83 if (iter == cache_.end()) {
84 cache_.Put(lookup, false);
85 SendRequest(*candidates, lookup);
86 } else {
87 overlay->overlay_handled = iter->second;
88 }
89 }
90
91 void DrmOverlayCandidatesHost::SendRequest(
92 const OverlaySurfaceCandidateList& candidates,
93 const OverlayCheck_Params& check) {
94 if (!platform_support_->IsConnected())
95 return;
96 pending_checks_.push_back(check);
97 std::vector<OverlayCheck_Params> list;
98 for (const auto& candidate : candidates)
99 list.push_back(OverlayCheck_Params(candidate));
100 platform_support_->CheckOverlayCapabilities(widget_, list);
101 }
102
103 void DrmOverlayCandidatesHost::OnOverlayResult(bool* handled,
104 gfx::AcceleratedWidget widget,
105 bool result) {
106 if (widget != widget_)
107 return;
108 *handled = true;
109 DCHECK(!pending_checks_.empty());
110 ProcessResult(pending_checks_.front(), result);
111 pending_checks_.pop_front();
112 }
113
114 void DrmOverlayCandidatesHost::ProcessResult(const OverlayCheck_Params& check,
115 bool result) {
116 if (result)
117 cache_.Put(check, true);
118 }
119
120 } // 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