| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/mus/gpu/gpu_service_impl.h" | 5 #include "components/mus/gpu/gpu_service_impl.h" |
| 6 | 6 |
| 7 #include "components/mus/common/gpu_type_converters.h" | 7 #include "components/mus/common/gpu_type_converters.h" |
| 8 #include "components/mus/gpu/gpu_service_mus.h" | 8 #include "components/mus/gpu/gpu_service_mus.h" |
| 9 #include "services/shell/public/cpp/connection.h" | 9 #include "services/shell/public/cpp/connection.h" |
| 10 | 10 |
| 11 namespace mus { | 11 namespace mus { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 void EstablishGpuChannelDone( | 15 void EstablishGpuChannelDone( |
| 16 const mojom::GpuService::EstablishGpuChannelCallback& callback, |
| 16 int32_t client_id, | 17 int32_t client_id, |
| 17 const mojom::GpuService::EstablishGpuChannelCallback& callback, | |
| 18 const IPC::ChannelHandle& channel_handle) { | 18 const IPC::ChannelHandle& channel_handle) { |
| 19 // TODO(penghuang): Send the real GPUInfo to the client. | 19 // TODO(penghuang): Send the real GPUInfo to the client. |
| 20 callback.Run(client_id, mojom::ChannelHandle::From(channel_handle), | 20 callback.Run(client_id, mojom::ChannelHandle::From(channel_handle), |
| 21 mojom::GpuInfo::From<gpu::GPUInfo>(gpu::GPUInfo())); | 21 mojom::GpuInfo::From<gpu::GPUInfo>(gpu::GPUInfo())); |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 GpuServiceImpl::GpuServiceImpl( | 25 GpuServiceImpl::GpuServiceImpl( |
| 26 mojo::InterfaceRequest<mojom::GpuService> request, | 26 mojo::InterfaceRequest<mojom::GpuService> request, |
| 27 shell::Connection* connection) | 27 shell::Connection* connection) |
| 28 : binding_(this, std::move(request)), | 28 : binding_(this, std::move(request)) {} |
| 29 client_id_(connection->GetRemoteInstanceID() + 1) { | |
| 30 // Use remote instead id + 1 as client id, so every GpuServiceImpl instances | |
| 31 // for a same client will have the same client id. | |
| 32 // Make sure client_id_ is greater than 1, because 1 is used for the local | |
| 33 // GpuChannel. | |
| 34 DCHECK_GT(client_id_, 1); | |
| 35 } | |
| 36 | 29 |
| 37 GpuServiceImpl::~GpuServiceImpl() {} | 30 GpuServiceImpl::~GpuServiceImpl() {} |
| 38 | 31 |
| 39 void GpuServiceImpl::EstablishGpuChannel( | 32 void GpuServiceImpl::EstablishGpuChannel( |
| 40 const mojom::GpuService::EstablishGpuChannelCallback& callback) { | 33 const mojom::GpuService::EstablishGpuChannelCallback& callback) { |
| 41 GpuServiceMus* service = GpuServiceMus::GetInstance(); | 34 GpuServiceMus* service = GpuServiceMus::GetInstance(); |
| 35 // TODO(penghuang): crbug.com/617415 figure out how to generate a meaningful |
| 36 // tracing id. |
| 37 const uint64_t client_tracing_id = 0; |
| 42 // TODO(penghuang): windows server may want to control those flags. | 38 // TODO(penghuang): windows server may want to control those flags. |
| 43 // Add a private interface for windows server. | 39 // Add a private interface for windows server. |
| 44 const bool preempts = false; | 40 const bool preempts = false; |
| 45 const bool allow_view_command_buffers = false; | 41 const bool allow_view_command_buffers = false; |
| 46 const bool allow_real_time_streams = false; | 42 const bool allow_real_time_streams = false; |
| 47 service->EstablishGpuChannel( | 43 service->EstablishGpuChannel( |
| 48 client_id_, client_id_, preempts, allow_view_command_buffers, | 44 client_tracing_id, preempts, allow_view_command_buffers, |
| 49 allow_real_time_streams, | 45 allow_real_time_streams, base::Bind(&EstablishGpuChannelDone, callback)); |
| 50 base::Bind(&EstablishGpuChannelDone, client_id_, callback)); | |
| 51 } | 46 } |
| 52 | 47 |
| 53 void GpuServiceImpl::CreateGpuMemoryBuffer( | 48 void GpuServiceImpl::CreateGpuMemoryBuffer( |
| 54 mojom::GpuMemoryBufferIdPtr id, | 49 mojom::GpuMemoryBufferIdPtr id, |
| 55 const gfx::Size& size, | 50 const gfx::Size& size, |
| 56 mojom::BufferFormat format, | 51 mojom::BufferFormat format, |
| 57 mojom::BufferUsage usage, | 52 mojom::BufferUsage usage, |
| 58 uint64_t surface_id, | 53 uint64_t surface_id, |
| 59 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) { | 54 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) { |
| 60 NOTIMPLEMENTED(); | 55 NOTIMPLEMENTED(); |
| 61 } | 56 } |
| 62 | 57 |
| 63 void GpuServiceImpl::CreateGpuMemoryBufferFromHandle( | 58 void GpuServiceImpl::CreateGpuMemoryBufferFromHandle( |
| 64 mojom::GpuMemoryBufferHandlePtr buffer_handle, | 59 mojom::GpuMemoryBufferHandlePtr buffer_handle, |
| 65 mojom::GpuMemoryBufferIdPtr id, | 60 mojom::GpuMemoryBufferIdPtr id, |
| 66 const gfx::Size& size, | 61 const gfx::Size& size, |
| 67 mojom::BufferFormat format, | 62 mojom::BufferFormat format, |
| 68 const mojom::GpuService::CreateGpuMemoryBufferFromHandleCallback& | 63 const mojom::GpuService::CreateGpuMemoryBufferFromHandleCallback& |
| 69 callback) { | 64 callback) { |
| 70 NOTIMPLEMENTED(); | 65 NOTIMPLEMENTED(); |
| 71 } | 66 } |
| 72 | 67 |
| 73 void GpuServiceImpl::DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, | 68 void GpuServiceImpl::DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, |
| 74 const gpu::SyncToken& sync_token) { | 69 const gpu::SyncToken& sync_token) { |
| 75 NOTIMPLEMENTED(); | 70 NOTIMPLEMENTED(); |
| 76 } | 71 } |
| 77 | 72 |
| 78 } // namespace mus | 73 } // namespace mus |
| OLD | NEW |