| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "gpu/command_buffer/service/feature_info.h" | 23 #include "gpu/command_buffer/service/feature_info.h" |
| 24 #include "gpu/command_buffer/service/gpu_switches.h" | 24 #include "gpu/command_buffer/service/gpu_switches.h" |
| 25 #include "gpu/command_buffer/service/mailbox_manager.h" | 25 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 26 #include "gpu/command_buffer/service/memory_program_cache.h" | 26 #include "gpu/command_buffer/service/memory_program_cache.h" |
| 27 #include "gpu/command_buffer/service/shader_translator_cache.h" | 27 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 28 #include "gpu/command_buffer/service/sync_point_manager.h" | 28 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 29 #include "ipc/message_filter.h" | 29 #include "ipc/message_filter.h" |
| 30 #include "ui/gl/gl_bindings.h" | 30 #include "ui/gl/gl_bindings.h" |
| 31 #include "ui/gl/gl_share_group.h" | 31 #include "ui/gl/gl_share_group.h" |
| 32 | 32 |
| 33 #if defined(OS_CHROMEOS) | |
| 34 #include "content/common/gpu/media/gpu_arc_video_service.h" | |
| 35 #endif | |
| 36 | |
| 37 namespace content { | 33 namespace content { |
| 38 | 34 |
| 39 namespace { | 35 namespace { |
| 40 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
| 41 // Amount of time we expect the GPU to stay powered up without being used. | 37 // Amount of time we expect the GPU to stay powered up without being used. |
| 42 const int kMaxGpuIdleTimeMs = 40; | 38 const int kMaxGpuIdleTimeMs = 40; |
| 43 // Maximum amount of time we keep pinging the GPU waiting for the client to | 39 // Maximum amount of time we keep pinging the GPU waiting for the client to |
| 44 // draw. | 40 // draw. |
| 45 const int kMaxKeepAliveTimeMs = 200; | 41 const int kMaxKeepAliveTimeMs = 200; |
| 46 #endif | 42 #endif |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 131 } |
| 136 | 132 |
| 137 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { | 133 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { |
| 138 bool handled = true; | 134 bool handled = true; |
| 139 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) | 135 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) |
| 140 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 136 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
| 141 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 137 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
| 142 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 138 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
| 143 OnCreateViewCommandBuffer) | 139 OnCreateViewCommandBuffer) |
| 144 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) | 140 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) |
| 145 #if defined(OS_CHROMEOS) | |
| 146 IPC_MESSAGE_HANDLER(GpuMsg_CreateArcVideoAcceleratorChannel, | |
| 147 OnCreateArcVideoAcceleratorChannel) | |
| 148 #endif | |
| 149 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) | 141 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) |
| 150 IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) | 142 IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) |
| 151 #if defined(OS_ANDROID) | 143 #if defined(OS_ANDROID) |
| 152 IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); | 144 IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); |
| 153 #endif | 145 #endif |
| 154 IPC_MESSAGE_UNHANDLED(handled = false) | 146 IPC_MESSAGE_UNHANDLED(handled = false) |
| 155 IPC_END_MESSAGE_MAP() | 147 IPC_END_MESSAGE_MAP() |
| 156 return handled; | 148 return handled; |
| 157 } | 149 } |
| 158 | 150 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, | 239 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
| 248 base::Unretained(this), id, client_id)); | 240 base::Unretained(this), id, client_id)); |
| 249 return; | 241 return; |
| 250 } | 242 } |
| 251 } | 243 } |
| 252 | 244 |
| 253 // No sync token or invalid sync token, destroy immediately. | 245 // No sync token or invalid sync token, destroy immediately. |
| 254 DestroyGpuMemoryBuffer(id, client_id); | 246 DestroyGpuMemoryBuffer(id, client_id); |
| 255 } | 247 } |
| 256 | 248 |
| 257 #if defined(OS_CHROMEOS) | |
| 258 void GpuChannelManager::OnCreateArcVideoAcceleratorChannel() { | |
| 259 if (!gpu_arc_video_service_) { | |
| 260 gpu_arc_video_service_.reset( | |
| 261 new GpuArcVideoService(shutdown_event_, io_task_runner_)); | |
| 262 } | |
| 263 | |
| 264 gpu_arc_video_service_->CreateChannel( | |
| 265 base::Bind(&GpuChannelManager::ArcVideoAcceleratorChannelCreated, | |
| 266 weak_factory_.GetWeakPtr())); | |
| 267 } | |
| 268 | |
| 269 void GpuChannelManager::ArcVideoAcceleratorChannelCreated( | |
| 270 const IPC::ChannelHandle& handle) { | |
| 271 Send(new GpuHostMsg_ArcVideoAcceleratorChannelCreated(handle)); | |
| 272 } | |
| 273 | |
| 274 void GpuChannelManager::OnShutdownArcVideoService() { | |
| 275 gpu_arc_video_service_.reset(); | |
| 276 } | |
| 277 #endif | |
| 278 | |
| 279 void GpuChannelManager::OnUpdateValueState( | 249 void GpuChannelManager::OnUpdateValueState( |
| 280 int client_id, unsigned int target, const gpu::ValueState& state) { | 250 int client_id, unsigned int target, const gpu::ValueState& state) { |
| 281 // Only pass updated state to the channel corresponding to the | 251 // Only pass updated state to the channel corresponding to the |
| 282 // render_widget_host where the event originated. | 252 // render_widget_host where the event originated. |
| 283 auto it = gpu_channels_.find(client_id); | 253 auto it = gpu_channels_.find(client_id); |
| 284 if (it != gpu_channels_.end()) | 254 if (it != gpu_channels_.end()) |
| 285 it->second->HandleUpdateValueState(target, state); | 255 it->second->HandleUpdateValueState(target, state); |
| 286 } | 256 } |
| 287 | 257 |
| 288 void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { | 258 void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 340 } |
| 371 } | 341 } |
| 372 if (!stub || !stub->decoder()->MakeCurrent()) | 342 if (!stub || !stub->decoder()->MakeCurrent()) |
| 373 return; | 343 return; |
| 374 glFinish(); | 344 glFinish(); |
| 375 DidAccessGpu(); | 345 DidAccessGpu(); |
| 376 } | 346 } |
| 377 #endif | 347 #endif |
| 378 | 348 |
| 379 } // namespace content | 349 } // namespace content |
| OLD | NEW |