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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 namespace content { | 25 namespace content { |
26 | 26 |
27 // static | 27 // static |
28 scoped_ptr<RendererGpuVideoAcceleratorFactories> | 28 scoped_ptr<RendererGpuVideoAcceleratorFactories> |
29 RendererGpuVideoAcceleratorFactories::Create( | 29 RendererGpuVideoAcceleratorFactories::Create( |
30 GpuChannelHost* gpu_channel_host, | 30 GpuChannelHost* gpu_channel_host, |
31 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, | 31 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, |
32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
33 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 33 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
34 bool enable_gpu_memory_buffer_video_frames, | 34 bool enable_gpu_memory_buffer_video_frames, |
35 unsigned image_texture_target, | 35 std::vector<unsigned> image_texture_targets, |
36 bool enable_video_accelerator) { | 36 bool enable_video_accelerator) { |
37 return make_scoped_ptr(new RendererGpuVideoAcceleratorFactories( | 37 return make_scoped_ptr(new RendererGpuVideoAcceleratorFactories( |
38 gpu_channel_host, main_thread_task_runner, task_runner, context_provider, | 38 gpu_channel_host, main_thread_task_runner, task_runner, context_provider, |
39 enable_gpu_memory_buffer_video_frames, image_texture_target, | 39 enable_gpu_memory_buffer_video_frames, image_texture_targets, |
40 enable_video_accelerator)); | 40 enable_video_accelerator)); |
41 } | 41 } |
42 | 42 |
43 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( | 43 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( |
44 GpuChannelHost* gpu_channel_host, | 44 GpuChannelHost* gpu_channel_host, |
45 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, | 45 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, |
46 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 46 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
47 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 47 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
48 bool enable_gpu_memory_buffer_video_frames, | 48 bool enable_gpu_memory_buffer_video_frames, |
49 unsigned image_texture_target, | 49 std::vector<unsigned> image_texture_targets, |
50 bool enable_video_accelerator) | 50 bool enable_video_accelerator) |
51 : main_thread_task_runner_(main_thread_task_runner), | 51 : main_thread_task_runner_(main_thread_task_runner), |
52 task_runner_(task_runner), | 52 task_runner_(task_runner), |
53 gpu_channel_host_(gpu_channel_host), | 53 gpu_channel_host_(gpu_channel_host), |
54 context_provider_refptr_(context_provider), | 54 context_provider_refptr_(context_provider), |
55 context_provider_(context_provider.get()), | 55 context_provider_(context_provider.get()), |
56 enable_gpu_memory_buffer_video_frames_( | 56 enable_gpu_memory_buffer_video_frames_( |
57 enable_gpu_memory_buffer_video_frames), | 57 enable_gpu_memory_buffer_video_frames), |
58 image_texture_target_(image_texture_target), | 58 image_texture_targets_(image_texture_targets), |
59 video_accelerator_enabled_(enable_video_accelerator), | 59 video_accelerator_enabled_(enable_video_accelerator), |
60 gpu_memory_buffer_manager_(ChildThreadImpl::current() | 60 gpu_memory_buffer_manager_(ChildThreadImpl::current() |
61 ->gpu_memory_buffer_manager()), | 61 ->gpu_memory_buffer_manager()), |
62 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) { | 62 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) { |
63 DCHECK(main_thread_task_runner_); | 63 DCHECK(main_thread_task_runner_); |
64 DCHECK(gpu_channel_host_); | 64 DCHECK(gpu_channel_host_); |
65 } | 65 } |
66 | 66 |
67 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} | 67 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} |
68 | 68 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 gfx::BufferUsage usage) { | 187 gfx::BufferUsage usage) { |
188 scoped_ptr<gfx::GpuMemoryBuffer> buffer = | 188 scoped_ptr<gfx::GpuMemoryBuffer> buffer = |
189 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(size, format, usage); | 189 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(size, format, usage); |
190 return buffer; | 190 return buffer; |
191 } | 191 } |
192 bool RendererGpuVideoAcceleratorFactories:: | 192 bool RendererGpuVideoAcceleratorFactories:: |
193 ShouldUseGpuMemoryBuffersForVideoFrames() const { | 193 ShouldUseGpuMemoryBuffersForVideoFrames() const { |
194 return enable_gpu_memory_buffer_video_frames_; | 194 return enable_gpu_memory_buffer_video_frames_; |
195 } | 195 } |
196 | 196 |
197 unsigned RendererGpuVideoAcceleratorFactories::ImageTextureTarget() { | 197 std::vector<unsigned> |
198 return image_texture_target_; | 198 RendererGpuVideoAcceleratorFactories::ImageTextureTargets() { |
| 199 return image_texture_targets_; |
199 } | 200 } |
200 | 201 |
201 media::VideoPixelFormat | 202 media::VideoPixelFormat |
202 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { | 203 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { |
203 DCHECK(task_runner_->BelongsToCurrentThread()); | 204 DCHECK(task_runner_->BelongsToCurrentThread()); |
204 if (CheckContextLost()) | 205 if (CheckContextLost()) |
205 return media::PIXEL_FORMAT_UNKNOWN; | 206 return media::PIXEL_FORMAT_UNKNOWN; |
206 cc::ContextProvider::ScopedContextLock lock(context_provider_); | 207 cc::ContextProvider::ScopedContextLock lock(context_provider_); |
207 auto capabilities = context_provider_->ContextCapabilities(); | 208 auto capabilities = context_provider_->ContextCapabilities(); |
208 if (capabilities.gpu.image_ycbcr_422) | 209 if (capabilities.gpu.image_ycbcr_422) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 gpu_channel_host_->gpu_info() | 260 gpu_channel_host_->gpu_info() |
260 .video_encode_accelerator_supported_profiles); | 261 .video_encode_accelerator_supported_profiles); |
261 } | 262 } |
262 | 263 |
263 void RendererGpuVideoAcceleratorFactories::ReleaseContextProvider() { | 264 void RendererGpuVideoAcceleratorFactories::ReleaseContextProvider() { |
264 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 265 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
265 context_provider_refptr_ = nullptr; | 266 context_provider_refptr_ = nullptr; |
266 } | 267 } |
267 | 268 |
268 } // namespace content | 269 } // namespace content |
OLD | NEW |