| Index: ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
|
| diff --git a/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc b/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
|
| index 75096a0cb8dc615b89ceed60ffcd6e0642afc774..8b3bafba0ce8fce0ccd8afe4681b18295f2c3f23 100644
|
| --- a/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
|
| +++ b/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
|
| @@ -100,20 +100,28 @@ void DrmGpuPlatformSupportHost::RemoveGpuThreadObserver(
|
| }
|
|
|
| bool DrmGpuPlatformSupportHost::IsConnected() {
|
| - return host_id_ >= 0;
|
| + return host_id_ >= 0 && channel_established_;
|
| }
|
|
|
| -void DrmGpuPlatformSupportHost::OnChannelEstablished(
|
| +void DrmGpuPlatformSupportHost::OnGpuProcessLaunched(
|
| int host_id,
|
| scoped_refptr<base::SingleThreadTaskRunner> send_runner,
|
| const base::Callback<void(IPC::Message*)>& send_callback) {
|
| - TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished",
|
| + TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnGpuProcessLaunched",
|
| "host_id", host_id);
|
| host_id_ = host_id;
|
| send_runner_ = send_runner;
|
| send_callback_ = send_callback;
|
|
|
| for (GpuThreadObserver& observer : gpu_thread_observers_)
|
| + observer.OnGpuProcessLaunched();
|
| +}
|
| +
|
| +void DrmGpuPlatformSupportHost::OnChannelEstablished() {
|
| + TRACE_EVENT0("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished");
|
| + channel_established_ = true;
|
| +
|
| + for (GpuThreadObserver& observer : gpu_thread_observers_)
|
| observer.OnGpuThreadReady();
|
|
|
| // The cursor is special since it will process input events on the IO thread
|
| @@ -131,6 +139,7 @@ void DrmGpuPlatformSupportHost::OnChannelDestroyed(int host_id) {
|
| if (host_id_ == host_id) {
|
| cursor_->ResetDrmCursorProxy();
|
| host_id_ = -1;
|
| + channel_established_ = false;
|
| send_runner_ = nullptr;
|
| send_callback_.Reset();
|
| for (GpuThreadObserver& observer : gpu_thread_observers_)
|
| @@ -230,7 +239,21 @@ bool DrmGpuPlatformSupportHost::GpuRelinquishDisplayControl() {
|
| bool DrmGpuPlatformSupportHost::GpuAddGraphicsDevice(
|
| const base::FilePath& path,
|
| const base::FileDescriptor& fd) {
|
| - return Send(new OzoneGpuMsg_AddGraphicsDevice(path, fd));
|
| + IPC::Message* message = new OzoneGpuMsg_AddGraphicsDevice(path, fd);
|
| +
|
| + // This function may be called from two places:
|
| + // - DrmDisplayHostManager::OnGpuProcessLaunched() invoked synchronously
|
| + // by GpuProcessHost::Init() on IO thread, which is the same thread as
|
| + // |send_runner_|. In this case we can synchronously send the IPC;
|
| + // - DrmDisplayHostManager::OnAddGraphicsDevice() on UI thread. In this
|
| + // case we need to post the send task to IO thread.
|
| + if (send_runner_ && send_runner_->BelongsToCurrentThread()) {
|
| + DCHECK(!send_callback_.is_null());
|
| + send_callback_.Run(message);
|
| + return true;
|
| + }
|
| +
|
| + return Send(message);
|
| }
|
|
|
| bool DrmGpuPlatformSupportHost::GpuRemoveGraphicsDevice(
|
|
|