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 |
33 namespace content { | 37 namespace content { |
34 | 38 |
35 namespace { | 39 namespace { |
36 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
37 // Amount of time we expect the GPU to stay powered up without being used. | 41 // Amount of time we expect the GPU to stay powered up without being used. |
38 const int kMaxGpuIdleTimeMs = 40; | 42 const int kMaxGpuIdleTimeMs = 40; |
39 // Maximum amount of time we keep pinging the GPU waiting for the client to | 43 // Maximum amount of time we keep pinging the GPU waiting for the client to |
40 // draw. | 44 // draw. |
41 const int kMaxKeepAliveTimeMs = 200; | 45 const int kMaxKeepAliveTimeMs = 200; |
42 #endif | 46 #endif |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 134 } |
131 | 135 |
132 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { | 136 bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) { |
133 bool handled = true; | 137 bool handled = true; |
134 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) | 138 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) |
135 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 139 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
136 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 140 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
137 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 141 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
138 OnCreateViewCommandBuffer) | 142 OnCreateViewCommandBuffer) |
139 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) | 143 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) |
| 144 #if defined(OS_CHROMEOS) |
| 145 IPC_MESSAGE_HANDLER(GpuMsg_CreateArcVideoAcceleratorChannel, |
| 146 OnCreateArcVideoAcceleratorChannel) |
| 147 #endif |
140 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) | 148 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) |
141 IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) | 149 IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) |
142 #if defined(OS_ANDROID) | 150 #if defined(OS_ANDROID) |
143 IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); | 151 IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); |
144 #endif | 152 #endif |
145 IPC_MESSAGE_UNHANDLED(handled = false) | 153 IPC_MESSAGE_UNHANDLED(handled = false) |
146 IPC_END_MESSAGE_MAP() | 154 IPC_END_MESSAGE_MAP() |
147 return handled; | 155 return handled; |
148 } | 156 } |
149 | 157 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, | 247 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
240 base::Unretained(this), id, client_id)); | 248 base::Unretained(this), id, client_id)); |
241 return; | 249 return; |
242 } | 250 } |
243 } | 251 } |
244 | 252 |
245 // No sync token or invalid sync token, destroy immediately. | 253 // No sync token or invalid sync token, destroy immediately. |
246 DestroyGpuMemoryBuffer(id, client_id); | 254 DestroyGpuMemoryBuffer(id, client_id); |
247 } | 255 } |
248 | 256 |
| 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 |
249 void GpuChannelManager::OnUpdateValueState( | 279 void GpuChannelManager::OnUpdateValueState( |
250 int client_id, unsigned int target, const gpu::ValueState& state) { | 280 int client_id, unsigned int target, const gpu::ValueState& state) { |
251 // Only pass updated state to the channel corresponding to the | 281 // Only pass updated state to the channel corresponding to the |
252 // render_widget_host where the event originated. | 282 // render_widget_host where the event originated. |
253 auto it = gpu_channels_.find(client_id); | 283 auto it = gpu_channels_.find(client_id); |
254 if (it != gpu_channels_.end()) | 284 if (it != gpu_channels_.end()) |
255 it->second->HandleUpdateValueState(target, state); | 285 it->second->HandleUpdateValueState(target, state); |
256 } | 286 } |
257 | 287 |
258 void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { | 288 void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 370 } |
341 } | 371 } |
342 if (!stub || !stub->decoder()->MakeCurrent()) | 372 if (!stub || !stub->decoder()->MakeCurrent()) |
343 return; | 373 return; |
344 glFinish(); | 374 glFinish(); |
345 DidAccessGpu(); | 375 DidAccessGpu(); |
346 } | 376 } |
347 #endif | 377 #endif |
348 | 378 |
349 } // namespace content | 379 } // namespace content |
OLD | NEW |