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 #include <utility> |
8 | 9 |
9 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
15 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 channel_filter_.get())); | 231 channel_filter_.get())); |
231 } | 232 } |
232 | 233 |
233 return NULL; | 234 return NULL; |
234 } | 235 } |
235 | 236 |
236 scoped_ptr<CommandBufferProxyImpl> command_buffer = | 237 scoped_ptr<CommandBufferProxyImpl> command_buffer = |
237 make_scoped_ptr(new CommandBufferProxyImpl(this, route_id, stream_id)); | 238 make_scoped_ptr(new CommandBufferProxyImpl(this, route_id, stream_id)); |
238 AddRoute(route_id, command_buffer->AsWeakPtr()); | 239 AddRoute(route_id, command_buffer->AsWeakPtr()); |
239 | 240 |
240 return command_buffer.Pass(); | 241 return command_buffer; |
241 } | 242 } |
242 | 243 |
243 scoped_ptr<CommandBufferProxyImpl> GpuChannelHost::CreateOffscreenCommandBuffer( | 244 scoped_ptr<CommandBufferProxyImpl> GpuChannelHost::CreateOffscreenCommandBuffer( |
244 const gfx::Size& size, | 245 const gfx::Size& size, |
245 CommandBufferProxyImpl* share_group, | 246 CommandBufferProxyImpl* share_group, |
246 int32_t stream_id, | 247 int32_t stream_id, |
247 GpuStreamPriority stream_priority, | 248 GpuStreamPriority stream_priority, |
248 const std::vector<int32_t>& attribs, | 249 const std::vector<int32_t>& attribs, |
249 const GURL& active_url, | 250 const GURL& active_url, |
250 gfx::GpuPreference gpu_preference) { | 251 gfx::GpuPreference gpu_preference) { |
(...skipping 21 matching lines...) Expand all Loading... |
272 if (!succeeded) { | 273 if (!succeeded) { |
273 LOG(ERROR) | 274 LOG(ERROR) |
274 << "GpuChannelMsg_CreateOffscreenCommandBuffer returned failure."; | 275 << "GpuChannelMsg_CreateOffscreenCommandBuffer returned failure."; |
275 return NULL; | 276 return NULL; |
276 } | 277 } |
277 | 278 |
278 scoped_ptr<CommandBufferProxyImpl> command_buffer = | 279 scoped_ptr<CommandBufferProxyImpl> command_buffer = |
279 make_scoped_ptr(new CommandBufferProxyImpl(this, route_id, stream_id)); | 280 make_scoped_ptr(new CommandBufferProxyImpl(this, route_id, stream_id)); |
280 AddRoute(route_id, command_buffer->AsWeakPtr()); | 281 AddRoute(route_id, command_buffer->AsWeakPtr()); |
281 | 282 |
282 return command_buffer.Pass(); | 283 return command_buffer; |
283 } | 284 } |
284 | 285 |
285 scoped_ptr<media::JpegDecodeAccelerator> GpuChannelHost::CreateJpegDecoder( | 286 scoped_ptr<media::JpegDecodeAccelerator> GpuChannelHost::CreateJpegDecoder( |
286 media::JpegDecodeAccelerator::Client* client) { | 287 media::JpegDecodeAccelerator::Client* client) { |
287 TRACE_EVENT0("gpu", "GpuChannelHost::CreateJpegDecoder"); | 288 TRACE_EVENT0("gpu", "GpuChannelHost::CreateJpegDecoder"); |
288 | 289 |
289 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 290 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
290 factory_->GetIOThreadTaskRunner(); | 291 factory_->GetIOThreadTaskRunner(); |
291 int32_t route_id = GenerateRouteID(); | 292 int32_t route_id = GenerateRouteID(); |
292 scoped_ptr<GpuJpegDecodeAcceleratorHost> decoder( | 293 scoped_ptr<GpuJpegDecodeAcceleratorHost> decoder( |
293 new GpuJpegDecodeAcceleratorHost(this, route_id, io_task_runner)); | 294 new GpuJpegDecodeAcceleratorHost(this, route_id, io_task_runner)); |
294 if (!decoder->Initialize(client)) { | 295 if (!decoder->Initialize(client)) { |
295 return nullptr; | 296 return nullptr; |
296 } | 297 } |
297 | 298 |
298 // The reply message of jpeg decoder should run on IO thread. | 299 // The reply message of jpeg decoder should run on IO thread. |
299 io_task_runner->PostTask(FROM_HERE, | 300 io_task_runner->PostTask(FROM_HERE, |
300 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, | 301 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, |
301 channel_filter_.get(), route_id, | 302 channel_filter_.get(), route_id, |
302 decoder->GetReceiver(), io_task_runner)); | 303 decoder->GetReceiver(), io_task_runner)); |
303 | 304 |
304 return decoder.Pass(); | 305 return std::move(decoder); |
305 } | 306 } |
306 | 307 |
307 void GpuChannelHost::DestroyCommandBuffer( | 308 void GpuChannelHost::DestroyCommandBuffer( |
308 CommandBufferProxyImpl* command_buffer) { | 309 CommandBufferProxyImpl* command_buffer) { |
309 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 310 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
310 | 311 |
311 int32_t route_id = command_buffer->route_id(); | 312 int32_t route_id = command_buffer->route_id(); |
312 int32_t stream_id = command_buffer->stream_id(); | 313 int32_t stream_id = command_buffer->stream_id(); |
313 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 314 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
314 RemoveRoute(route_id); | 315 RemoveRoute(route_id); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 543 |
543 listeners_.clear(); | 544 listeners_.clear(); |
544 } | 545 } |
545 | 546 |
546 bool GpuChannelHost::MessageFilter::IsLost() const { | 547 bool GpuChannelHost::MessageFilter::IsLost() const { |
547 AutoLock lock(lock_); | 548 AutoLock lock(lock_); |
548 return lost_; | 549 return lost_; |
549 } | 550 } |
550 | 551 |
551 } // namespace content | 552 } // namespace content |
OLD | NEW |