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 "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
18 #include "third_party/skia/include/core/SkPixelRef.h" | 18 #include "third_party/skia/include/core/SkPixelRef.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} | |
23 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( | 22 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( |
24 GpuChannelHost* gpu_channel_host, | 23 GpuChannelHost* gpu_channel_host, |
25 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, | 24 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, |
26 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) | 25 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) |
27 : task_runner_(message_loop_proxy), | 26 : task_runner_(message_loop_proxy), |
28 gpu_channel_host_(gpu_channel_host), | 27 gpu_channel_host_(gpu_channel_host), |
29 context_provider_(context_provider), | 28 context_provider_(context_provider), |
30 thread_safe_sender_(ChildThread::current()->thread_safe_sender()) {} | 29 thread_safe_sender_(ChildThread::current()->thread_safe_sender()) { |
| 30 task_runner_->PostTask( |
| 31 FROM_HERE, |
| 32 base::Bind(&RendererGpuVideoAcceleratorFactories::BindContext, this)); |
| 33 } |
| 34 |
| 35 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} |
| 36 |
| 37 void RendererGpuVideoAcceleratorFactories::BindContext() { |
| 38 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 39 if (!context_provider_->BindToCurrentThread()) |
| 40 context_provider_ = NULL; |
| 41 } |
31 | 42 |
32 WebGraphicsContext3DCommandBufferImpl* | 43 WebGraphicsContext3DCommandBufferImpl* |
33 RendererGpuVideoAcceleratorFactories::GetContext3d() { | 44 RendererGpuVideoAcceleratorFactories::GetContext3d() { |
34 DCHECK(task_runner_->BelongsToCurrentThread()); | 45 DCHECK(task_runner_->BelongsToCurrentThread()); |
35 if (!context_provider_) | 46 if (!context_provider_) |
36 return NULL; | 47 return NULL; |
37 if (context_provider_->IsContextLost()) { | 48 if (context_provider_->IsContextLost()) { |
38 context_provider_->VerifyContexts(); | 49 context_provider_->VerifyContexts(); |
39 context_provider_ = NULL; | 50 context_provider_ = NULL; |
40 return NULL; | 51 return NULL; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 DCHECK(task_runner_->BelongsToCurrentThread()); | 207 DCHECK(task_runner_->BelongsToCurrentThread()); |
197 return ChildThread::AllocateSharedMemory(size, thread_safe_sender_.get()); | 208 return ChildThread::AllocateSharedMemory(size, thread_safe_sender_.get()); |
198 } | 209 } |
199 | 210 |
200 scoped_refptr<base::SingleThreadTaskRunner> | 211 scoped_refptr<base::SingleThreadTaskRunner> |
201 RendererGpuVideoAcceleratorFactories::GetTaskRunner() { | 212 RendererGpuVideoAcceleratorFactories::GetTaskRunner() { |
202 return task_runner_; | 213 return task_runner_; |
203 } | 214 } |
204 | 215 |
205 } // namespace content | 216 } // namespace content |
OLD | NEW |