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 GpuJpegDecoder's main task thread, which is | |
wuchengli
2015/04/24 05:54:23
Just call it task thread. main task thread sounds
kcwu
2015/04/30 19:25:40
Done.
| |
264 // not main thread. | |
265 | |
266 int32 route_id = GenerateRouteID(); | |
267 GpuJpegDecodeAcceleratorHost* decoder( | |
268 new GpuJpegDecodeAcceleratorHost(this, route_id, | |
269 factory_->GetIOLoopProxy())); | |
270 | |
271 // GpuJpegDecoder's main task thread (i.e., device thread on Linux) is | |
272 // usually blocking wait for next frame, so it expects decoder responses are | |
wuchengli
2015/04/24 05:54:23
s/blocking wait/waiting/.
Here it refers to the m
kcwu
2015/04/30 19:25:40
Done.
| |
273 // send to |reply_loop| directly. | |
274 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | |
275 io_loop->PostTask(FROM_HERE, | |
276 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, | |
277 channel_filter_.get(), route_id, | |
278 decoder->AsWeakPtr(), reply_loop)); | |
wuchengli
2015/04/24 05:54:23
Why not just use |io_loop|? reply_loop is always I
kcwu
2015/04/30 19:25:40
I want to make these thread logic stay in GpuJpegD
| |
279 return scoped_ptr<media::JpegDecodeAccelerator>(decoder); | |
280 } | |
281 | |
259 void GpuChannelHost::DestroyCommandBuffer( | 282 void GpuChannelHost::DestroyCommandBuffer( |
260 CommandBufferProxyImpl* command_buffer) { | 283 CommandBufferProxyImpl* command_buffer) { |
261 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 284 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
262 | 285 |
263 int route_id = command_buffer->GetRouteID(); | 286 int route_id = command_buffer->GetRouteID(); |
264 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 287 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
265 RemoveRoute(route_id); | 288 RemoveRoute(route_id); |
266 | 289 |
267 AutoLock lock(context_lock_); | 290 AutoLock lock(context_lock_); |
268 proxies_.erase(route_id); | 291 proxies_.erase(route_id); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 | 449 |
427 listeners_.clear(); | 450 listeners_.clear(); |
428 } | 451 } |
429 | 452 |
430 bool GpuChannelHost::MessageFilter::IsLost() const { | 453 bool GpuChannelHost::MessageFilter::IsLost() const { |
431 AutoLock lock(lock_); | 454 AutoLock lock(lock_); |
432 return lost_; | 455 return lost_; |
433 } | 456 } |
434 | 457 |
435 } // namespace content | 458 } // namespace content |
OLD | NEW |