| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
| 15 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 15 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 16 #include "content/common/gpu/gpu_memory_manager.h" | 16 #include "content/common/gpu/gpu_memory_manager.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
| 18 #include "content/common/gpu/media/gpu_arc_video_service.h" |
| 18 #include "content/common/message_router.h" | 19 #include "content/common/message_router.h" |
| 19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 20 #include "gpu/command_buffer/common/value_state.h" | 21 #include "gpu/command_buffer/common/value_state.h" |
| 21 #include "gpu/command_buffer/service/feature_info.h" | 22 #include "gpu/command_buffer/service/feature_info.h" |
| 22 #include "gpu/command_buffer/service/gpu_switches.h" | 23 #include "gpu/command_buffer/service/gpu_switches.h" |
| 23 #include "gpu/command_buffer/service/mailbox_manager.h" | 24 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 24 #include "gpu/command_buffer/service/memory_program_cache.h" | 25 #include "gpu/command_buffer/service/memory_program_cache.h" |
| 25 #include "gpu/command_buffer/service/shader_translator_cache.h" | 26 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 26 #include "gpu/command_buffer/service/sync_point_manager.h" | 27 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 27 #include "ipc/message_filter.h" | 28 #include "ipc/message_filter.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 129 } |
| 129 | 130 |
| 130 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { | 131 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { |
| 131 bool handled = true; | 132 bool handled = true; |
| 132 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) | 133 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) |
| 133 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 134 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
| 134 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 135 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
| 135 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 136 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
| 136 OnCreateViewCommandBuffer) | 137 OnCreateViewCommandBuffer) |
| 137 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) | 138 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) |
| 139 IPC_MESSAGE_HANDLER(GpuMsg_CreateArcVideoAcceleratorChannel, |
| 140 OnCreateArcVideoAcceleratorChannel) |
| 138 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) | 141 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) |
| 139 IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) | 142 IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) |
| 140 #if defined(OS_ANDROID) | 143 #if defined(OS_ANDROID) |
| 141 IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); | 144 IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); |
| 142 #endif | 145 #endif |
| 143 IPC_MESSAGE_UNHANDLED(handled = false) | 146 IPC_MESSAGE_UNHANDLED(handled = false) |
| 144 IPC_END_MESSAGE_MAP() | 147 IPC_END_MESSAGE_MAP() |
| 145 return handled; | 148 return handled; |
| 146 } | 149 } |
| 147 | 150 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, | 240 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
| 238 base::Unretained(this), id, client_id)); | 241 base::Unretained(this), id, client_id)); |
| 239 return; | 242 return; |
| 240 } | 243 } |
| 241 } | 244 } |
| 242 | 245 |
| 243 // No sync token or invalid sync token, destroy immediately. | 246 // No sync token or invalid sync token, destroy immediately. |
| 244 DestroyGpuMemoryBuffer(id, client_id); | 247 DestroyGpuMemoryBuffer(id, client_id); |
| 245 } | 248 } |
| 246 | 249 |
| 250 void GpuChannelManager::OnCreateArcVideoAcceleratorChannel() { |
| 251 if (!arc_video_service_) { |
| 252 arc_video_service_.reset( |
| 253 new GpuArcVideoService(shutdown_event_, io_task_runner_)); |
| 254 arc_video_service_->Initialize(); |
| 255 } |
| 256 |
| 257 arc_video_service_->CreateChannel( |
| 258 base::Bind(&GpuChannelManager::ArcVideoAcceleratorChannelCreated, |
| 259 weak_factory_.GetWeakPtr())); |
| 260 } |
| 261 |
| 262 void GpuChannelManager::ArcVideoAcceleratorChannelCreated( |
| 263 const IPC::ChannelHandle& handle) { |
| 264 Send(new GpuHostMsg_ArcVideoAcceleratorChannelCreated(handle)); |
| 265 } |
| 266 |
| 267 void GpuChannelManager::OnShutdownArcVideoService() { |
| 268 arc_video_service_.reset(); |
| 269 } |
| 270 |
| 247 void GpuChannelManager::OnUpdateValueState( | 271 void GpuChannelManager::OnUpdateValueState( |
| 248 int client_id, unsigned int target, const gpu::ValueState& state) { | 272 int client_id, unsigned int target, const gpu::ValueState& state) { |
| 249 // Only pass updated state to the channel corresponding to the | 273 // Only pass updated state to the channel corresponding to the |
| 250 // render_widget_host where the event originated. | 274 // render_widget_host where the event originated. |
| 251 auto it = gpu_channels_.find(client_id); | 275 auto it = gpu_channels_.find(client_id); |
| 252 if (it != gpu_channels_.end()) | 276 if (it != gpu_channels_.end()) |
| 253 it->second->HandleUpdateValueState(target, state); | 277 it->second->HandleUpdateValueState(target, state); |
| 254 } | 278 } |
| 255 | 279 |
| 256 void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { | 280 void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 362 } |
| 339 } | 363 } |
| 340 if (!stub || !stub->decoder()->MakeCurrent()) | 364 if (!stub || !stub->decoder()->MakeCurrent()) |
| 341 return; | 365 return; |
| 342 glFinish(); | 366 glFinish(); |
| 343 DidAccessGpu(); | 367 DidAccessGpu(); |
| 344 } | 368 } |
| 345 #endif | 369 #endif |
| 346 | 370 |
| 347 } // namespace content | 371 } // namespace content |
| OLD | NEW |