forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "[ozone/drm]: support content and service manager launching"
This is a reland of 7faa3b0. With modified ozone setup to not regress --mash mode. Original change's description: > [ozone/drm]: support content and service manager launching > > The existing in-progress implementation of ozone/drm over mojo IPC > assumed that the ozone host would use a mojo ServiceManager provided > at initialization that it could use to launch and connect to the DRM > and cursor services. However, when used in a src/content context (such > as would be the case in Chrome), there is no service manager available > at ozone initialization time. Instead, content::GpuProcessHost > notifies the ozone host later from the browser I/O thread when the GPU > process containing the DRM and cursor services is running. > > This CL refactors the ozone/drm/mojo implementation to isolate the > acquisition of mojo pipes into a separate class that supports both > styles of pipe acquistion: either by the use of a ServiceManager or > via an asynchronously injected dependency on content. > > This CL also restructures the launch of the DRM thread itself so that > it can be deferred until after the GPU sandbox is initialized in a way > that does not depend on the use of legacy IPC message filters. > > BUG=620927 > > Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel > Change-Id: Icfb2261326cd1d5d6e2769d9801c02a744e1102a > Reviewed-on: https://chromium-review.googlesource.com/861749 > Commit-Queue: Robert Kroeger <rjkroege@chromium.org> > Reviewed-by: Daniel Nicoara <dnicoara@chromium.org> > Reviewed-by: Yuzhu Shen <yzshen@chromium.org> > Reviewed-by: Antoine Labour <piman@chromium.org> > Cr-Commit-Position: refs/heads/master@{#530562} TBR=dnicoara@chromium.org,yzshen@chromium.org Bug: 620927 Change-Id: I1453fc61b096600495276731c3bc749a040d14d3 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Reviewed-on: https://chromium-review.googlesource.com/882482 Reviewed-by: Antoine Labour <piman@chromium.org> Reviewed-by: Robert Kroeger <rjkroege@chromium.org> Commit-Queue: Robert Kroeger <rjkroege@chromium.org> Cr-Commit-Position: refs/heads/master@{#531572}
- Loading branch information
Showing
27 changed files
with
525 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ui/ozone/platform/drm/host/drm_device_connector.h" | ||
|
||
#include "mojo/public/cpp/bindings/interface_request.h" | ||
#include "mojo/public/cpp/system/message_pipe.h" | ||
#include "services/service_manager/public/cpp/connector.h" | ||
#include "services/ui/public/interfaces/constants.mojom.h" | ||
#include "ui/ozone/platform/drm/host/host_drm_device.h" | ||
#include "ui/ozone/public/gpu_platform_support_host.h" | ||
|
||
namespace { | ||
// TODO(rjkroege): In the future when ozone/drm is always mojo-based, remove | ||
// this utility code. | ||
using BinderCallback = ui::GpuPlatformSupportHost::GpuHostBindInterfaceCallback; | ||
|
||
void BindInterfaceInGpuProcess(const std::string& interface_name, | ||
mojo::ScopedMessagePipeHandle interface_pipe, | ||
const BinderCallback& binder_callback) { | ||
return binder_callback.Run(interface_name, std::move(interface_pipe)); | ||
} | ||
|
||
template <typename Interface> | ||
void BindInterfaceInGpuProcess(mojo::InterfaceRequest<Interface> request, | ||
const BinderCallback& binder_callback) { | ||
BindInterfaceInGpuProcess( | ||
Interface::Name_, std::move(request.PassMessagePipe()), binder_callback); | ||
} | ||
|
||
} // namespace | ||
|
||
namespace ui { | ||
|
||
DrmDeviceConnector::DrmDeviceConnector( | ||
service_manager::Connector* connector, | ||
scoped_refptr<HostDrmDevice> host_drm_device_) | ||
: connector_(connector), host_drm_device_(host_drm_device_) {} | ||
|
||
DrmDeviceConnector::~DrmDeviceConnector() {} | ||
|
||
void DrmDeviceConnector::OnGpuProcessLaunched( | ||
int host_id, | ||
scoped_refptr<base::SingleThreadTaskRunner> ui_runner, | ||
scoped_refptr<base::SingleThreadTaskRunner> send_runner, | ||
const base::RepeatingCallback<void(IPC::Message*)>& send_callback) { | ||
NOTREACHED(); | ||
} | ||
|
||
void DrmDeviceConnector::OnChannelDestroyed(int host_id) { | ||
// TODO(rjkroege): Handle Viz restarting. | ||
NOTIMPLEMENTED(); | ||
} | ||
|
||
void DrmDeviceConnector::OnGpuServiceLaunched( | ||
scoped_refptr<base::SingleThreadTaskRunner> ui_runner, | ||
scoped_refptr<base::SingleThreadTaskRunner> io_runner, | ||
GpuHostBindInterfaceCallback binder) { | ||
// We need to preserve |binder| to let us bind interfaces later. | ||
binder_callback_ = std::move(binder); | ||
|
||
ui::ozone::mojom::DrmDevicePtr drm_device_ptr; | ||
BindInterfaceDrmDevice(&drm_device_ptr); | ||
ui::ozone::mojom::DeviceCursorPtr cursor_ptr_ui, cursor_ptr_io; | ||
BindInterfaceDeviceCursor(&cursor_ptr_ui); | ||
BindInterfaceDeviceCursor(&cursor_ptr_io); | ||
|
||
ui_runner->PostTask( | ||
FROM_HERE, | ||
base::BindOnce(&HostDrmDevice::OnGpuServiceLaunched, host_drm_device_, | ||
std::move(drm_device_ptr), std::move(cursor_ptr_ui), | ||
std::move(cursor_ptr_io))); | ||
} | ||
|
||
void DrmDeviceConnector::OnMessageReceived(const IPC::Message& message) { | ||
NOTREACHED() << "This class should only be used with mojo transport but here " | ||
"we're wrongly getting invoked to handle IPC communication."; | ||
} | ||
|
||
void DrmDeviceConnector::BindInterfaceDrmDevice( | ||
ui::ozone::mojom::DrmDevicePtr* drm_device_ptr) const { | ||
if (connector_) { | ||
connector_->BindInterface(ui::mojom::kServiceName, drm_device_ptr); | ||
} else { | ||
auto request = mojo::MakeRequest(drm_device_ptr); | ||
BindInterfaceInGpuProcess(std::move(request), binder_callback_); | ||
} | ||
} | ||
|
||
void DrmDeviceConnector::BindInterfaceDeviceCursor( | ||
ui::ozone::mojom::DeviceCursorPtr* cursor_ptr) const { | ||
if (connector_) { | ||
connector_->BindInterface(ui::mojom::kServiceName, cursor_ptr); | ||
} else { | ||
auto request = mojo::MakeRequest(cursor_ptr); | ||
BindInterfaceInGpuProcess(std::move(request), binder_callback_); | ||
} | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef UI_OZONE_PLATFORM_DRM_HOST_DRM_DEVICE_CONNECTOR_H_ | ||
#define UI_OZONE_PLATFORM_DRM_HOST_DRM_DEVICE_CONNECTOR_H_ | ||
|
||
#include "ui/ozone/public/gpu_platform_support_host.h" | ||
#include "ui/ozone/public/interfaces/device_cursor.mojom.h" | ||
#include "ui/ozone/public/interfaces/drm_device.mojom.h" | ||
|
||
namespace service_manager { | ||
class Connector; | ||
} | ||
|
||
namespace ui { | ||
class HostDrmDevice; | ||
|
||
// DrmDeviceConnector sets up mojo pipes connecting the Viz host to the DRM | ||
// service. It operates in two modes: running on the I/O thread when invoked | ||
// from content and running on the VizHost main thread when operating with a | ||
// service_manager. | ||
class DrmDeviceConnector : public GpuPlatformSupportHost { | ||
public: | ||
DrmDeviceConnector(service_manager::Connector* connector, | ||
scoped_refptr<HostDrmDevice> host_drm_device_); | ||
~DrmDeviceConnector() override; | ||
|
||
// GpuPlatformSupportHost: | ||
void OnGpuProcessLaunched( | ||
int host_id, | ||
scoped_refptr<base::SingleThreadTaskRunner> ui_runner, | ||
scoped_refptr<base::SingleThreadTaskRunner> send_runner, | ||
const base::RepeatingCallback<void(IPC::Message*)>& send_callback) | ||
override; | ||
void OnChannelDestroyed(int host_id) override; | ||
void OnMessageReceived(const IPC::Message& message) override; | ||
void OnGpuServiceLaunched( | ||
scoped_refptr<base::SingleThreadTaskRunner> ui_runner, | ||
scoped_refptr<base::SingleThreadTaskRunner> io_runner, | ||
GpuHostBindInterfaceCallback binder) override; | ||
|
||
// BindInterface arranges for the drm_device_ptr to be connected. | ||
void BindInterfaceDrmDevice( | ||
ui::ozone::mojom::DrmDevicePtr* drm_device_ptr) const; | ||
|
||
// BindInterface arranges for the cursor_ptr to be wired up. | ||
void BindInterfaceDeviceCursor( | ||
ui::ozone::mojom::DeviceCursorPtr* cursor_ptr) const; | ||
|
||
// BindableNow returns true if this DrmDeviceConnector is capable of binding a | ||
// mojo endpoint for the DrmDevice service. | ||
bool BindableNow() const { return !!connector_; } | ||
|
||
private: | ||
// This will be present if the Viz host has a service manager. | ||
service_manager::Connector* connector_; | ||
|
||
// This will be used if we are operating under content/gpu without a service | ||
// manager. | ||
GpuHostBindInterfaceCallback binder_callback_; | ||
|
||
scoped_refptr<HostDrmDevice> host_drm_device_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(DrmDeviceConnector); | ||
}; | ||
|
||
} // namespace ui | ||
|
||
#endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_DEVICE_CONNECTOR_H_ |
Oops, something went wrong.