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