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" | |
8 #include "ui/gfx/geometry/rect_conversions.h" | 7 #include "ui/gfx/geometry/rect_conversions.h" |
8 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | |
9 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" | |
9 #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h" | 10 #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h" |
11 #include "ui/ozone/platform/drm/host/drm_window_host.h" | |
10 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" | 12 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" |
11 #include "ui/ozone/public/overlay_candidates_ozone.h" | 13 #include "ui/ozone/public/overlay_candidates_ozone.h" |
12 #include "ui/ozone/public/ozone_switches.h" | |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 | 16 |
16 DrmOverlayManager::DrmOverlayManager( | 17 DrmOverlayManager::DrmOverlayManager( |
17 DrmGpuPlatformSupportHost* platform_support_host, | 18 DrmGpuPlatformSupportHost* platform_support_host, |
18 DrmWindowHostManager* manager) | 19 DrmWindowHostManager* window_manager) |
19 : platform_support_host_(platform_support_host), window_manager_(manager) { | 20 : sender_(new OverlayCandidatesIPC(platform_support_host, this)), |
20 is_supported_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 21 core_(new DrmOverlayManagerCore(sender_.get(), window_manager)) {} |
21 switches::kOzoneTestSingleOverlaySupport); | |
22 } | |
23 | 22 |
24 DrmOverlayManager::~DrmOverlayManager() { | 23 DrmOverlayManager::~DrmOverlayManager() { |
25 } | 24 } |
26 | 25 |
27 scoped_ptr<OverlayCandidatesOzone> DrmOverlayManager::CreateOverlayCandidates( | 26 scoped_ptr<OverlayCandidatesOzone> DrmOverlayManager::CreateOverlayCandidates( |
28 gfx::AcceleratedWidget w) { | 27 gfx::AcceleratedWidget w) { |
29 if (!is_supported_) | 28 return core_->CreateOverlayCandidates(w); |
30 return nullptr; | 29 } |
31 DrmWindowHost* window = window_manager_->GetWindow(w); | 30 |
32 DCHECK(window); | 31 void DrmOverlayManager::OnChannelEstablished( |
33 return make_scoped_ptr( | 32 int host_id, |
34 new DrmOverlayCandidatesHost(platform_support_host_, window)); | 33 scoped_refptr<base::SingleThreadTaskRunner> send_runner, |
34 const base::Callback<void(IPC::Message*)>& sender) { | |
35 core_->ResetCache(); | |
36 } | |
37 | |
38 void DrmOverlayManager::OnChannelDestroyed(int host_id) {} | |
39 | |
40 bool DrmOverlayManager::OnMessageReceived(const IPC::Message& message) { | |
41 bool handled = false; | |
42 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(DrmOverlayCandidatesHost, message, &handled) | |
43 IPC_MESSAGE_FORWARD(OzoneHostMsg_OverlayCapabilitiesReceived, this, | |
dnicoara
2016/01/26 14:14:23
nit: Since DrmOverlayManagerCore always handles th
rjkroege
2016/01/26 23:58:55
Done.
| |
44 DrmOverlayManager::OnOverlayResult) | |
45 IPC_END_MESSAGE_MAP() | |
46 return handled; | |
47 } | |
48 | |
49 void DrmOverlayManager::ResetCache() { | |
50 core_->ResetCache(); | |
51 } | |
52 | |
53 void DrmOverlayManager::OnOverlayResult( | |
54 bool* handled, | |
55 gfx::AcceleratedWidget widget, | |
56 const std::vector<OverlayCheck_Params>& params) { | |
57 core_->GpuSentOverlayResult(handled, widget, params); | |
58 } | |
59 | |
60 // TODO(rjkroege): There is a refactoring opportunity in the sender pattern. | |
61 DrmOverlayManager::OverlayCandidatesIPC::OverlayCandidatesIPC( | |
62 DrmGpuPlatformSupportHost* platform_support, | |
63 DrmOverlayManager* parent) | |
64 : platform_support_(platform_support), parent_(parent) {} | |
65 | |
66 DrmOverlayManager::OverlayCandidatesIPC::~OverlayCandidatesIPC() {} | |
67 | |
68 void DrmOverlayManager::OverlayCandidatesIPC::UnregisterHandler() { | |
69 platform_support_->UnregisterHandler(parent_); | |
70 } | |
71 | |
72 void DrmOverlayManager::OverlayCandidatesIPC::RegisterHandler() { | |
73 platform_support_->RegisterHandler(parent_); | |
74 } | |
75 | |
76 bool DrmOverlayManager::OverlayCandidatesIPC::IsConnected() { | |
77 return platform_support_->IsConnected(); | |
78 } | |
79 | |
80 bool DrmOverlayManager::OverlayCandidatesIPC::CheckOverlayCapabilities( | |
81 gfx::AcceleratedWidget widget, | |
82 const std::vector<OverlayCheck_Params>& new_params) { | |
83 return platform_support_->Send( | |
84 new OzoneGpuMsg_CheckOverlayCapabilities(widget, new_params)); | |
35 } | 85 } |
36 | 86 |
37 } // namespace ui | 87 } // namespace ui |
OLD | NEW |