Chromium Code Reviews| Index: ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| diff --git a/ui/ozone/platform/drm/host/drm_overlay_manager.cc b/ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| index ae0a755e3d5d83b8bf81c59ad57090fe859917a8..55c2e57eb6ab6aea8db1087541dc34352228b26d 100644 |
| --- a/ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| +++ b/ui/ozone/platform/drm/host/drm_overlay_manager.cc |
| @@ -4,34 +4,84 @@ |
| #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" |
| -#include "base/command_line.h" |
| #include "ui/gfx/geometry/rect_conversions.h" |
| +#include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| +#include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" |
| #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h" |
| +#include "ui/ozone/platform/drm/host/drm_window_host.h" |
| #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" |
| #include "ui/ozone/public/overlay_candidates_ozone.h" |
| -#include "ui/ozone/public/ozone_switches.h" |
| namespace ui { |
| DrmOverlayManager::DrmOverlayManager( |
| DrmGpuPlatformSupportHost* platform_support_host, |
| - DrmWindowHostManager* manager) |
| - : platform_support_host_(platform_support_host), window_manager_(manager) { |
| - is_supported_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kOzoneTestSingleOverlaySupport); |
| -} |
| + DrmWindowHostManager* window_manager) |
| + : sender_(new OverlayCandidatesIPC(platform_support_host, this)), |
| + core_(new DrmOverlayManagerCore(sender_.get(), window_manager)) {} |
| DrmOverlayManager::~DrmOverlayManager() { |
| } |
| scoped_ptr<OverlayCandidatesOzone> DrmOverlayManager::CreateOverlayCandidates( |
| gfx::AcceleratedWidget w) { |
| - if (!is_supported_) |
| - return nullptr; |
| - DrmWindowHost* window = window_manager_->GetWindow(w); |
| - DCHECK(window); |
| - return make_scoped_ptr( |
| - new DrmOverlayCandidatesHost(platform_support_host_, window)); |
| + return core_->CreateOverlayCandidates(w); |
| +} |
| + |
| +void DrmOverlayManager::OnChannelEstablished( |
| + int host_id, |
| + scoped_refptr<base::SingleThreadTaskRunner> send_runner, |
| + const base::Callback<void(IPC::Message*)>& sender) { |
| + core_->ResetCache(); |
| +} |
| + |
| +void DrmOverlayManager::OnChannelDestroyed(int host_id) {} |
| + |
| +bool DrmOverlayManager::OnMessageReceived(const IPC::Message& message) { |
| + bool handled = false; |
| + IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(DrmOverlayCandidatesHost, message, &handled) |
| + 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.
|
| + DrmOverlayManager::OnOverlayResult) |
| + IPC_END_MESSAGE_MAP() |
| + return handled; |
| +} |
| + |
| +void DrmOverlayManager::ResetCache() { |
| + core_->ResetCache(); |
| +} |
| + |
| +void DrmOverlayManager::OnOverlayResult( |
| + bool* handled, |
| + gfx::AcceleratedWidget widget, |
| + const std::vector<OverlayCheck_Params>& params) { |
| + core_->GpuSentOverlayResult(handled, widget, params); |
| +} |
| + |
| +// TODO(rjkroege): There is a refactoring opportunity in the sender pattern. |
| +DrmOverlayManager::OverlayCandidatesIPC::OverlayCandidatesIPC( |
| + DrmGpuPlatformSupportHost* platform_support, |
| + DrmOverlayManager* parent) |
| + : platform_support_(platform_support), parent_(parent) {} |
| + |
| +DrmOverlayManager::OverlayCandidatesIPC::~OverlayCandidatesIPC() {} |
| + |
| +void DrmOverlayManager::OverlayCandidatesIPC::UnregisterHandler() { |
| + platform_support_->UnregisterHandler(parent_); |
| +} |
| + |
| +void DrmOverlayManager::OverlayCandidatesIPC::RegisterHandler() { |
| + platform_support_->RegisterHandler(parent_); |
| +} |
| + |
| +bool DrmOverlayManager::OverlayCandidatesIPC::IsConnected() { |
| + return platform_support_->IsConnected(); |
| +} |
| + |
| +bool DrmOverlayManager::OverlayCandidatesIPC::CheckOverlayCapabilities( |
| + gfx::AcceleratedWidget widget, |
| + const std::vector<OverlayCheck_Params>& new_params) { |
| + return platform_support_->Send( |
| + new OzoneGpuMsg_CheckOverlayCapabilities(widget, new_params)); |
| } |
| } // namespace ui |