OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/media/renderer_gpu_video_accelerator_factories.h" | 5 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "content/child/child_thread.h" | 11 #include "content/child/child_thread.h" |
12 #include "content/common/gpu/client/context_provider_command_buffer.h" | 12 #include "content/common/gpu/client/context_provider_command_buffer.h" |
13 #include "content/common/gpu/client/gpu_channel_host.h" | 13 #include "content/common/gpu/client/gpu_channel_host.h" |
14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
15 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
16 #include "gpu/command_buffer/client/gles2_implementation.h" | 16 #include "gpu/command_buffer/client/gles2_implementation.h" |
17 #include "media/video/video_decode_accelerator.h" | 17 #include "media/video/video_decode_accelerator.h" |
18 #include "media/video/video_encode_accelerator.h" | 18 #include "media/video/video_encode_accelerator.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
20 #include "third_party/skia/include/core/SkPixelRef.h" | 20 #include "third_party/skia/include/core/SkPixelRef.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 // static | 24 // static |
25 scoped_refptr<RendererGpuVideoAcceleratorFactories> | 25 scoped_refptr<RendererGpuVideoAcceleratorFactories> |
26 RendererGpuVideoAcceleratorFactories::Create( | 26 RendererGpuVideoAcceleratorFactories::Create( |
27 GpuChannelHost* gpu_channel_host, | 27 GpuChannelHost* gpu_channel_host, |
28 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, | 28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
29 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) { | 29 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) { |
30 scoped_refptr<RendererGpuVideoAcceleratorFactories> factories = | 30 scoped_refptr<RendererGpuVideoAcceleratorFactories> factories = |
31 new RendererGpuVideoAcceleratorFactories( | 31 new RendererGpuVideoAcceleratorFactories( |
32 gpu_channel_host, message_loop_proxy, context_provider); | 32 gpu_channel_host, task_runner, context_provider); |
33 // Post task from outside constructor, since AddRef()/Release() is unsafe from | 33 // Post task from outside constructor, since AddRef()/Release() is unsafe from |
34 // within. | 34 // within. |
35 message_loop_proxy->PostTask( | 35 task_runner->PostTask( |
36 FROM_HERE, | 36 FROM_HERE, |
37 base::Bind(&RendererGpuVideoAcceleratorFactories::BindContext, | 37 base::Bind(&RendererGpuVideoAcceleratorFactories::BindContext, |
38 factories)); | 38 factories)); |
39 return factories; | 39 return factories; |
40 } | 40 } |
41 | 41 |
42 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( | 42 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( |
43 GpuChannelHost* gpu_channel_host, | 43 GpuChannelHost* gpu_channel_host, |
44 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, | 44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
45 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) | 45 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) |
46 : task_runner_(message_loop_proxy), | 46 : task_runner_(task_runner), |
47 gpu_channel_host_(gpu_channel_host), | 47 gpu_channel_host_(gpu_channel_host), |
48 context_provider_(context_provider), | 48 context_provider_(context_provider), |
49 thread_safe_sender_(ChildThread::current()->thread_safe_sender()) {} | 49 thread_safe_sender_(ChildThread::current()->thread_safe_sender()) {} |
50 | 50 |
51 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} | 51 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} |
52 | 52 |
53 void RendererGpuVideoAcceleratorFactories::BindContext() { | 53 void RendererGpuVideoAcceleratorFactories::BindContext() { |
54 DCHECK(task_runner_->BelongsToCurrentThread()); | 54 DCHECK(task_runner_->BelongsToCurrentThread()); |
55 if (!context_provider_->BindToCurrentThread()) | 55 if (!context_provider_->BindToCurrentThread()) |
56 context_provider_ = NULL; | 56 context_provider_ = NULL; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 DCHECK(task_runner_->BelongsToCurrentThread()); | 253 DCHECK(task_runner_->BelongsToCurrentThread()); |
254 return ChildThread::AllocateSharedMemory(size, thread_safe_sender_.get()); | 254 return ChildThread::AllocateSharedMemory(size, thread_safe_sender_.get()); |
255 } | 255 } |
256 | 256 |
257 scoped_refptr<base::SingleThreadTaskRunner> | 257 scoped_refptr<base::SingleThreadTaskRunner> |
258 RendererGpuVideoAcceleratorFactories::GetTaskRunner() { | 258 RendererGpuVideoAcceleratorFactories::GetTaskRunner() { |
259 return task_runner_; | 259 return task_runner_; |
260 } | 260 } |
261 | 261 |
262 } // namespace content | 262 } // namespace content |
OLD | NEW |