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

Side by Side Diff: ui/ozone/platform/drm/host/drm_overlay_manager.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: fix leak, other comments 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "ui/gfx/geometry/rect_conversions.h" 8 #include "ui/gfx/geometry/rect_conversions.h"
9 #include "ui/ozone/platform/drm/host/drm_host_overlay_candidates.h"
9 #include "ui/ozone/public/overlay_candidates_ozone.h" 10 #include "ui/ozone/public/overlay_candidates_ozone.h"
10 #include "ui/ozone/public/ozone_switches.h" 11 #include "ui/ozone/public/ozone_switches.h"
11 12
12 namespace ui { 13 namespace ui {
13 namespace {
14 14
15 class SingleOverlay : public OverlayCandidatesOzone { 15 DrmOverlayManager::DrmOverlayManager(
16 public: 16 bool allow_surfaceless,
17 SingleOverlay() {} 17 DrmGpuPlatformSupportHost* platform_support_host)
18 ~SingleOverlay() override {} 18 : platform_support_host_(platform_support_host),
19 19 allow_surfaceless_(allow_surfaceless) {
20 void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override { 20 is_supported_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
21 if (candidates->size() == 2) { 21 switches::kOzoneTestSingleOverlaySupport);
22 OverlayCandidatesOzone::OverlaySurfaceCandidate* first =
23 &(*candidates)[0];
24 OverlayCandidatesOzone::OverlaySurfaceCandidate* second =
25 &(*candidates)[1];
26 OverlayCandidatesOzone::OverlaySurfaceCandidate* overlay;
27 if (first->plane_z_order == 0) {
28 overlay = second;
29 } else if (second->plane_z_order == 0) {
30 overlay = first;
31 } else {
32 NOTREACHED();
33 return;
34 }
35 // 0.01 constant chosen to match DCHECKs in gfx::ToNearestRect and avoid
36 // that code asserting on quads that we accept.
37 if (overlay->plane_z_order > 0 &&
38 IsTransformSupported(overlay->transform) &&
39 gfx::IsNearestRectWithinDistance(overlay->display_rect, 0.01f)) {
40 overlay->overlay_handled = true;
41 }
42 }
43 }
44
45 private:
46 bool IsTransformSupported(gfx::OverlayTransform transform) {
47 switch (transform) {
48 case gfx::OVERLAY_TRANSFORM_NONE:
49 return true;
50 default:
51 return false;
52 }
53 }
54
55 DISALLOW_COPY_AND_ASSIGN(SingleOverlay);
56 };
57
58 } // namespace
59
60 DrmOverlayManager::DrmOverlayManager(bool allow_surfaceless)
61 : allow_surfaceless_(allow_surfaceless) {
62 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
63 switches::kOzoneTestSingleOverlaySupport))
64 candidates_ = make_scoped_ptr(new SingleOverlay());
65 } 22 }
66 23
67 DrmOverlayManager::~DrmOverlayManager() { 24 DrmOverlayManager::~DrmOverlayManager() {
68 } 25 }
69 26
70 OverlayCandidatesOzone* DrmOverlayManager::GetOverlayCandidates( 27 scoped_ptr<OverlayCandidatesOzone> DrmOverlayManager::GetOverlayCandidates(
dnicoara 2015/05/29 19:28:23 This should be renamed to CreateOverlayCandidates(
achaulk 2015/06/01 20:43:08 Acknowledged.
71 gfx::AcceleratedWidget w) { 28 gfx::AcceleratedWidget w) {
72 return candidates_.get(); 29 if (!is_supported_)
30 return nullptr;
31 return scoped_ptr<OverlayCandidatesOzone>(
32 new DrmHostOverlayCandidates(w, platform_support_host_));
73 } 33 }
74 34
75 bool DrmOverlayManager::CanShowPrimaryPlaneAsOverlay() { 35 bool DrmOverlayManager::CanShowPrimaryPlaneAsOverlay() {
76 return allow_surfaceless_; 36 return allow_surfaceless_;
77 } 37 }
78 38
79 } // namespace ui 39 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698