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/client/gpu_channel_host.h" | 5 #include "content/common/gpu/client/gpu_channel_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/posix/eintr_wrapper.h" | 12 #include "base/posix/eintr_wrapper.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 15 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 16 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" |
16 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
17 #include "ipc/ipc_sync_message_filter.h" | 18 #include "ipc/ipc_sync_message_filter.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
21 #include "content/public/common/sandbox_init.h" | 22 #include "content/public/common/sandbox_init.h" |
22 #endif | 23 #endif |
23 | 24 |
24 using base::AutoLock; | 25 using base::AutoLock; |
25 using base::MessageLoopProxy; | 26 using base::MessageLoopProxy; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 250 |
250 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder( | 251 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder( |
251 int command_buffer_route_id) { | 252 int command_buffer_route_id) { |
252 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); | 253 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); |
253 AutoLock lock(context_lock_); | 254 AutoLock lock(context_lock_); |
254 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); | 255 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
255 DCHECK(it != proxies_.end()); | 256 DCHECK(it != proxies_.end()); |
256 return it->second->CreateVideoEncoder(); | 257 return it->second->CreateVideoEncoder(); |
257 } | 258 } |
258 | 259 |
| 260 scoped_ptr<media::JpegDecodeAccelerator> GpuChannelHost::CreateJpegDecoder( |
| 261 scoped_refptr<base::MessageLoopProxy> reply_loop) { |
| 262 TRACE_EVENT0("gpu", "GpuChannelHost::CreateJpegDecoder"); |
| 263 // This function is called from GpuJpegDecodeAcceleratorAdapter's device |
| 264 // thread, which is not main thread. |
| 265 |
| 266 int32 route_id = GenerateRouteID(); |
| 267 GpuJpegDecodeAcceleratorHost* decoder( |
| 268 new GpuJpegDecodeAcceleratorHost(this, route_id)); |
| 269 |
| 270 // GpuJpegDecodeAcceleratorAdapter's device thread is usually blocking wait |
| 271 // for next frame, so it expects decoder responses are send to |reply_loop| |
| 272 // directly. |
| 273 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
| 274 io_loop->PostTask(FROM_HERE, |
| 275 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, |
| 276 channel_filter_.get(), route_id, |
| 277 decoder->AsWeakPtr(), reply_loop)); |
| 278 return scoped_ptr<media::JpegDecodeAccelerator>(decoder); |
| 279 } |
| 280 |
259 void GpuChannelHost::DestroyCommandBuffer( | 281 void GpuChannelHost::DestroyCommandBuffer( |
260 CommandBufferProxyImpl* command_buffer) { | 282 CommandBufferProxyImpl* command_buffer) { |
261 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 283 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
262 | 284 |
263 int route_id = command_buffer->GetRouteID(); | 285 int route_id = command_buffer->GetRouteID(); |
264 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 286 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
265 RemoveRoute(route_id); | 287 RemoveRoute(route_id); |
266 | 288 |
267 AutoLock lock(context_lock_); | 289 AutoLock lock(context_lock_); |
268 proxies_.erase(route_id); | 290 proxies_.erase(route_id); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 448 |
427 listeners_.clear(); | 449 listeners_.clear(); |
428 } | 450 } |
429 | 451 |
430 bool GpuChannelHost::MessageFilter::IsLost() const { | 452 bool GpuChannelHost::MessageFilter::IsLost() const { |
431 AutoLock lock(lock_); | 453 AutoLock lock(lock_); |
432 return lost_; | 454 return lost_; |
433 } | 455 } |
434 | 456 |
435 } // namespace content | 457 } // namespace content |
OLD | NEW |