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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 CommandBufferProxyImpl* command_buffer = | 183 CommandBufferProxyImpl* command_buffer = |
185 new CommandBufferProxyImpl(this, route_id); | 184 new CommandBufferProxyImpl(this, route_id); |
186 AddRoute(route_id, command_buffer->AsWeakPtr()); | 185 AddRoute(route_id, command_buffer->AsWeakPtr()); |
187 | 186 |
188 AutoLock lock(context_lock_); | 187 AutoLock lock(context_lock_); |
189 proxies_[route_id] = command_buffer; | 188 proxies_[route_id] = command_buffer; |
190 return command_buffer; | 189 return command_buffer; |
191 } | 190 } |
192 | 191 |
193 scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder( | 192 scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder( |
194 int command_buffer_route_id, | 193 int command_buffer_route_id) { |
195 media::VideoCodecProfile profile) { | 194 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoDecoder"); |
196 AutoLock lock(context_lock_); | 195 AutoLock lock(context_lock_); |
197 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); | 196 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
198 DCHECK(it != proxies_.end()); | 197 DCHECK(it != proxies_.end()); |
199 CommandBufferProxyImpl* proxy = it->second; | 198 return it->second->CreateVideoDecoder(); |
200 return proxy->CreateVideoDecoder(profile).Pass(); | |
201 } | 199 } |
202 | 200 |
203 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder() { | 201 scoped_ptr<media::VideoEncodeAccelerator> GpuChannelHost::CreateVideoEncoder( |
| 202 int command_buffer_route_id) { |
204 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); | 203 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoEncoder"); |
205 | 204 AutoLock lock(context_lock_); |
206 scoped_ptr<media::VideoEncodeAccelerator> vea; | 205 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
207 int32 route_id = MSG_ROUTING_NONE; | 206 DCHECK(it != proxies_.end()); |
208 if (!Send(new GpuChannelMsg_CreateVideoEncoder(&route_id))) | 207 return it->second->CreateVideoEncoder(); |
209 return vea.Pass(); | |
210 if (route_id == MSG_ROUTING_NONE) | |
211 return vea.Pass(); | |
212 | |
213 vea.reset(new GpuVideoEncodeAcceleratorHost(this, route_id)); | |
214 return vea.Pass(); | |
215 } | 208 } |
216 | 209 |
217 void GpuChannelHost::DestroyCommandBuffer( | 210 void GpuChannelHost::DestroyCommandBuffer( |
218 CommandBufferProxyImpl* command_buffer) { | 211 CommandBufferProxyImpl* command_buffer) { |
219 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 212 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
220 | 213 |
221 int route_id = command_buffer->GetRouteID(); | 214 int route_id = command_buffer->GetRouteID(); |
222 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 215 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
223 RemoveRoute(route_id); | 216 RemoveRoute(route_id); |
224 | 217 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 363 |
371 listeners_.clear(); | 364 listeners_.clear(); |
372 } | 365 } |
373 | 366 |
374 bool GpuChannelHost::MessageFilter::IsLost() const { | 367 bool GpuChannelHost::MessageFilter::IsLost() const { |
375 AutoLock lock(lock_); | 368 AutoLock lock(lock_); |
376 return lost_; | 369 return lost_; |
377 } | 370 } |
378 | 371 |
379 } // namespace content | 372 } // namespace content |
OLD | NEW |