Chromium Code Reviews| OLD | NEW |
|---|---|
| 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( |
|
dnicoara
2015/05/28 21:09:54
This is never used.
achaulk
2015/05/29 18:49:21
Oh, yeah this should gate object creation
| |
| 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 OverlayCandidatesOzone* DrmOverlayManager::GetOverlayCandidates( |
| 71 gfx::AcceleratedWidget w) { | 28 gfx::AcceleratedWidget w) { |
| 72 return candidates_.get(); | 29 return new DrmHostOverlayCandidates(w, platform_support_host_); |
|
dnicoara
2015/05/28 21:09:54
This is leaking the DrmHostOverlayCandidates.
achaulk
2015/05/29 18:49:21
Yeah I was still deciding where it should be destr
| |
| 73 } | 30 } |
| 74 | 31 |
| 75 bool DrmOverlayManager::CanShowPrimaryPlaneAsOverlay() { | 32 bool DrmOverlayManager::CanShowPrimaryPlaneAsOverlay() { |
| 76 return allow_surfaceless_; | 33 return allow_surfaceless_; |
| 77 } | 34 } |
| 78 | 35 |
| 79 } // namespace ui | 36 } // namespace ui |
| OLD | NEW |