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

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: add missing license header 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_overlay_candidates_host.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 {
21 if (candidates->size() == 2) {
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 is_supported_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 20 is_supported_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
63 switches::kOzoneTestSingleOverlaySupport); 21 switches::kOzoneTestSingleOverlaySupport);
64 } 22 }
65 23
66 DrmOverlayManager::~DrmOverlayManager() { 24 DrmOverlayManager::~DrmOverlayManager() {
67 } 25 }
68 26
69 scoped_ptr<OverlayCandidatesOzone> DrmOverlayManager::CreateOverlayCandidates( 27 scoped_ptr<OverlayCandidatesOzone> DrmOverlayManager::CreateOverlayCandidates(
70 gfx::AcceleratedWidget w) { 28 gfx::AcceleratedWidget w) {
71 if (!is_supported_) 29 if (!is_supported_)
72 return nullptr; 30 return nullptr;
73 return make_scoped_ptr(new SingleOverlay()); 31 return make_scoped_ptr(
32 new DrmOverlayCandidatesHost(w, platform_support_host_));
74 } 33 }
75 34
76 bool DrmOverlayManager::CanShowPrimaryPlaneAsOverlay() { 35 bool DrmOverlayManager::CanShowPrimaryPlaneAsOverlay() {
77 return allow_surfaceless_; 36 return allow_surfaceless_;
78 } 37 }
79 38
80 } // namespace ui 39 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_overlay_manager.h ('k') | ui/ozone/platform/drm/ozone_platform_drm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698