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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.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_video_encode_accelerator_host.h" | |
17 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
18 #include "ipc/ipc_sync_message_filter.h" | 17 #include "ipc/ipc_sync_message_filter.h" |
19 #include "url/gurl.h" | 18 #include "url/gurl.h" |
20 | 19 |
21 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
22 #include "content/public/common/sandbox_init.h" | 21 #include "content/public/common/sandbox_init.h" |
23 #endif | 22 #endif |
24 | 23 |
25 using base::AutoLock; | 24 using base::AutoLock; |
26 using base::MessageLoopProxy; | 25 using base::MessageLoopProxy; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 CommandBufferProxyImpl* command_buffer = | 186 CommandBufferProxyImpl* command_buffer = |
188 new CommandBufferProxyImpl(this, route_id); | 187 new CommandBufferProxyImpl(this, route_id); |
189 AddRoute(route_id, command_buffer->AsWeakPtr()); | 188 AddRoute(route_id, command_buffer->AsWeakPtr()); |
190 | 189 |
191 AutoLock lock(context_lock_); | 190 AutoLock lock(context_lock_); |
192 proxies_[route_id] = command_buffer; | 191 proxies_[route_id] = command_buffer; |
193 return command_buffer; | 192 return command_buffer; |
194 } | 193 } |
195 | 194 |
196 scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder( | 195 scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder( |
197 int command_buffer_route_id, | 196 int command_buffer_route_id) { |
198 media::VideoCodecProfile profile) { | 197 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoDecoder"); |
199 AutoLock lock(context_lock_); | 198 AutoLock lock(context_lock_); |
200 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); | 199 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
201 DCHECK(it != proxies_.end()); | 200 DCHECK(it != proxies_.end()); |
202 CommandBufferProxyImpl* proxy = it->second; | 201 return it->second->CreateVideoDecoder(); |
203 return proxy->CreateVideoDecoder(profile).Pass(); | |
204 } | 202 } |
205 | 203 |
206 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder() { | 204 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder( |
| 205 int command_buffer_route_id) { |
207 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); | 206 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); |
208 | 207 AutoLock lock(context_lock_); |
209 scoped_ptr<media::VideoEncodeAccelerator> vea; | 208 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
210 int32 route_id = MSG_ROUTING_NONE; | 209 DCHECK(it != proxies_.end()); |
211 if (!Send(new GpuChannelMsg_CreateVideoEncoder(&route_id))) | 210 return it->second->CreateVideoEncoder(); |
212 return vea.Pass(); | |
213 if (route_id == MSG_ROUTING_NONE) | |
214 return vea.Pass(); | |
215 | |
216 vea.reset(new GpuVideoEncodeAcceleratorHost(this, route_id)); | |
217 return vea.Pass(); | |
218 } | 211 } |
219 | 212 |
220 void GpuChannelHost::DestroyCommandBuffer( | 213 void GpuChannelHost::DestroyCommandBuffer( |
221 CommandBufferProxyImpl* command_buffer) { | 214 CommandBufferProxyImpl* command_buffer) { |
222 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 215 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
223 | 216 |
224 int route_id = command_buffer->GetRouteID(); | 217 int route_id = command_buffer->GetRouteID(); |
225 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 218 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
226 RemoveRoute(route_id); | 219 RemoveRoute(route_id); |
227 | 220 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 370 |
378 listeners_.clear(); | 371 listeners_.clear(); |
379 } | 372 } |
380 | 373 |
381 bool GpuChannelHost::MessageFilter::IsLost() const { | 374 bool GpuChannelHost::MessageFilter::IsLost() const { |
382 AutoLock lock(lock_); | 375 AutoLock lock(lock_); |
383 return lost_; | 376 return lost_; |
384 } | 377 } |
385 | 378 |
386 } // namespace content | 379 } // namespace content |
OLD | NEW |