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/location.h" | 10 #include "base/location.h" |
11 #include "base/posix/eintr_wrapper.h" | 11 #include "base/posix/eintr_wrapper.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
16 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 16 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 17 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" |
17 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
18 #include "ipc/ipc_sync_message_filter.h" | 19 #include "ipc/ipc_sync_message_filter.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 #if defined(OS_WIN) || defined(OS_MACOSX) | 22 #if defined(OS_WIN) || defined(OS_MACOSX) |
22 #include "content/public/common/sandbox_init.h" | 23 #include "content/public/common/sandbox_init.h" |
23 #endif | 24 #endif |
24 | 25 |
25 using base::AutoLock; | 26 using base::AutoLock; |
26 | 27 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 252 |
252 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder( | 253 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder( |
253 int command_buffer_route_id) { | 254 int command_buffer_route_id) { |
254 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); | 255 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); |
255 AutoLock lock(context_lock_); | 256 AutoLock lock(context_lock_); |
256 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); | 257 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
257 DCHECK(it != proxies_.end()); | 258 DCHECK(it != proxies_.end()); |
258 return it->second->CreateVideoEncoder(); | 259 return it->second->CreateVideoEncoder(); |
259 } | 260 } |
260 | 261 |
| 262 scoped_ptr<media::JpegDecodeAccelerator> GpuChannelHost::CreateJpegDecoder( |
| 263 media::JpegDecodeAccelerator::Client* client) { |
| 264 TRACE_EVENT0("gpu", "GpuChannelHost::CreateJpegDecoder"); |
| 265 |
| 266 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
| 267 factory_->GetIOThreadTaskRunner(); |
| 268 int32 route_id = GenerateRouteID(); |
| 269 scoped_ptr<GpuJpegDecodeAcceleratorHost> decoder( |
| 270 new GpuJpegDecodeAcceleratorHost(this, route_id, io_task_runner)); |
| 271 if (!decoder->Initialize(client)) { |
| 272 return nullptr; |
| 273 } |
| 274 |
| 275 // The reply message of jpeg decoder should run on IO thread. |
| 276 io_task_runner->PostTask(FROM_HERE, |
| 277 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, |
| 278 channel_filter_.get(), route_id, |
| 279 decoder->GetReceiver(), io_task_runner)); |
| 280 |
| 281 return decoder.Pass(); |
| 282 } |
| 283 |
261 void GpuChannelHost::DestroyCommandBuffer( | 284 void GpuChannelHost::DestroyCommandBuffer( |
262 CommandBufferProxyImpl* command_buffer) { | 285 CommandBufferProxyImpl* command_buffer) { |
263 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 286 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
264 | 287 |
265 int route_id = command_buffer->GetRouteID(); | 288 int route_id = command_buffer->GetRouteID(); |
266 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 289 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
267 RemoveRoute(route_id); | 290 RemoveRoute(route_id); |
268 | 291 |
269 AutoLock lock(context_lock_); | 292 AutoLock lock(context_lock_); |
270 proxies_.erase(route_id); | 293 proxies_.erase(route_id); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 459 |
437 listeners_.clear(); | 460 listeners_.clear(); |
438 } | 461 } |
439 | 462 |
440 bool GpuChannelHost::MessageFilter::IsLost() const { | 463 bool GpuChannelHost::MessageFilter::IsLost() const { |
441 AutoLock lock(lock_); | 464 AutoLock lock(lock_); |
442 return lost_; | 465 return lost_; |
443 } | 466 } |
444 | 467 |
445 } // namespace content | 468 } // namespace content |
OLD | NEW |