Chromium Code Reviews| Index: content/common/gpu/gpu_channel_manager.cc |
| diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc |
| index dd7646bcd42951a1d542291052cc07004ae0483c..25681ff79e623721c336a2daa48c64137d8aa322 100644 |
| --- a/content/common/gpu/gpu_channel_manager.cc |
| +++ b/content/common/gpu/gpu_channel_manager.cc |
| @@ -13,12 +13,14 @@ |
| #include "base/single_thread_task_runner.h" |
| #include "base/thread_task_runner_handle.h" |
| #include "build/build_config.h" |
| +#include "content/common/gpu/establish_channel_params.h" |
| #include "content/common/gpu/gpu_channel.h" |
| +#include "content/common/gpu/gpu_channel_manager_delegate.h" |
| #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| #include "content/common/gpu/gpu_memory_manager.h" |
| -#include "content/common/gpu/gpu_messages.h" |
| #include "content/common/message_router.h" |
| #include "content/public/common/content_switches.h" |
| +#include "gpu/command_buffer/common/sync_token.h" |
| #include "gpu/command_buffer/common/value_state.h" |
| #include "gpu/command_buffer/service/feature_info.h" |
| #include "gpu/command_buffer/service/gpu_switches.h" |
| @@ -44,6 +46,7 @@ const int kMaxKeepAliveTimeMs = 200; |
| } |
| GpuChannelManager::GpuChannelManager( |
| + GpuChannelManagerDelegate* delegate, |
| IPC::SyncChannel* channel, |
| GpuWatchdog* watchdog, |
| base::SingleThreadTaskRunner* task_runner, |
| @@ -53,6 +56,7 @@ GpuChannelManager::GpuChannelManager( |
| GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| : task_runner_(task_runner), |
| io_task_runner_(io_task_runner), |
| + delegate_(delegate), |
| channel_(channel), |
| watchdog_(watchdog), |
| shutdown_event_(shutdown_event), |
| @@ -108,7 +112,7 @@ GpuChannelManager::framebuffer_completeness_cache() { |
| } |
| void GpuChannelManager::RemoveChannel(int client_id) { |
| - Send(new GpuHostMsg_DestroyChannel(client_id)); |
| + delegate_->DestroyChannel(client_id); |
| gpu_channels_.erase(client_id); |
| } |
| @@ -130,33 +134,11 @@ GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { |
| return it != gpu_channels_.end() ? it->second : nullptr; |
| } |
| -bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { |
| - bool handled = true; |
| - IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) |
| - IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
| - IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
| - IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) |
| - IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) |
| - IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) |
| -#if defined(OS_ANDROID) |
| - IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); |
| -#endif |
| - IPC_MESSAGE_UNHANDLED(handled = false) |
| - IPC_END_MESSAGE_MAP() |
| - return handled; |
| -} |
| - |
| bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { |
| - if (msg.routing_id() == MSG_ROUTING_CONTROL) |
| - return OnControlMessageReceived(msg); |
| - |
| + DCHECK_NE(MSG_ROUTING_CONTROL, msg.routing_id()); |
| return router_.RouteMessage(msg); |
| } |
| -bool GpuChannelManager::Send(IPC::Message* msg) { |
| - return channel_->Send(msg); |
| -} |
| - |
| scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( |
| int client_id, |
| uint64_t client_tracing_id, |
| @@ -170,8 +152,7 @@ scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( |
| allow_view_command_buffers, allow_real_time_streams)); |
| } |
| -void GpuChannelManager::OnEstablishChannel( |
| - const GpuMsg_EstablishChannel_Params& params) { |
| +void GpuChannelManager::EstablishChannel(const EstablishChannelParams& params) { |
| scoped_ptr<GpuChannel> channel(CreateGpuChannel( |
| params.client_id, params.client_tracing_id, params.preempts, |
| params.allow_view_command_buffers, params.allow_real_time_streams)); |
| @@ -181,11 +162,10 @@ void GpuChannelManager::OnEstablishChannel( |
| gpu_channels_.set(params.client_id, std::move(channel)); |
| - Send(new GpuHostMsg_ChannelEstablished(channel_handle)); |
| + delegate_->ChannelEstablished(channel_handle); |
| } |
| -void GpuChannelManager::OnCloseChannel( |
| - const IPC::ChannelHandle& channel_handle) { |
| +void GpuChannelManager::CloseChannel(const IPC::ChannelHandle& channel_handle) { |
| for (auto it = gpu_channels_.begin(); it != gpu_channels_.end(); ++it) { |
| if (it->second->channel_id() == channel_handle.name) { |
| gpu_channels_.erase(it); |
| @@ -194,21 +174,22 @@ void GpuChannelManager::OnCloseChannel( |
| } |
| } |
| -void GpuChannelManager::DestroyGpuMemoryBuffer( |
| +void GpuChannelManager::InternalDestroyGpuMemoryBuffer( |
| gfx::GpuMemoryBufferId id, |
| int client_id) { |
| io_task_runner_->PostTask( |
| - FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO, |
| - base::Unretained(this), id, client_id)); |
| + FROM_HERE, |
| + base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO, |
| + base::Unretained(this), id, client_id)); |
| } |
| -void GpuChannelManager::DestroyGpuMemoryBufferOnIO( |
| +void GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO( |
| gfx::GpuMemoryBufferId id, |
| int client_id) { |
| gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id); |
| } |
| -void GpuChannelManager::OnDestroyGpuMemoryBuffer( |
| +void GpuChannelManager::DestroyGpuMemoryBuffer( |
| gfx::GpuMemoryBufferId id, |
| int client_id, |
| const gpu::SyncToken& sync_token) { |
| @@ -219,18 +200,19 @@ void GpuChannelManager::OnDestroyGpuMemoryBuffer( |
| if (release_state) { |
| sync_point_client_waiter_->WaitOutOfOrder( |
| release_state.get(), sync_token.release_count(), |
| - base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
| + base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBuffer, |
| base::Unretained(this), id, client_id)); |
| return; |
| } |
| } |
| // No sync token or invalid sync token, destroy immediately. |
| - DestroyGpuMemoryBuffer(id, client_id); |
| + InternalDestroyGpuMemoryBuffer(id, client_id); |
| } |
| -void GpuChannelManager::OnUpdateValueState( |
| - int client_id, unsigned int target, const gpu::ValueState& state) { |
| +void GpuChannelManager::UpdateValueState(int client_id, |
| + unsigned int target, |
| + const gpu::ValueState& state) { |
| // Only pass updated state to the channel corresponding to the |
| // render_widget_host where the event originated. |
| auto it = gpu_channels_.find(client_id); |
| @@ -238,7 +220,7 @@ void GpuChannelManager::OnUpdateValueState( |
| it->second->HandleUpdateValueState(target, state); |
| } |
| -void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { |
| +void GpuChannelManager::LoadedShader(const std::string& program_proto) { |
|
no sievers
2016/02/19 00:19:24
nit: PopulateShaderCache(), CacheShaderProgram() m
Fady Samuel
2016/02/19 01:13:10
Done.
|
| if (program_cache()) |
| program_cache()->LoadProgram(program_proto); |
| } |
| @@ -266,11 +248,11 @@ void GpuChannelManager::LoseAllContexts() { |
| kv.second->MarkAllContextsLost(); |
| } |
| task_runner_->PostTask(FROM_HERE, |
| - base::Bind(&GpuChannelManager::OnLoseAllContexts, |
| + base::Bind(&GpuChannelManager::ClearAllChannels, |
| weak_factory_.GetWeakPtr())); |
| } |
| -void GpuChannelManager::OnLoseAllContexts() { |
| +void GpuChannelManager::ClearAllChannels() { |
|
no sievers
2016/02/19 00:19:24
nit: DestroyAllChannels?
Fady Samuel
2016/02/19 01:13:10
Done.
|
| gpu_channels_.clear(); |
| } |
| @@ -287,7 +269,7 @@ void GpuChannelManager::DidAccessGpu() { |
| last_gpu_access_time_ = base::TimeTicks::Now(); |
| } |
| -void GpuChannelManager::OnWakeUpGpu() { |
| +void GpuChannelManager::WakeUpGpu() { |
| begin_wake_up_time_ = base::TimeTicks::Now(); |
| ScheduleWakeUpGpu(); |
| } |