| 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 13 matching lines...) Expand all Loading... |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 // static | 26 // static |
| 27 scoped_refptr<RendererGpuVideoAcceleratorFactories> | 27 scoped_refptr<RendererGpuVideoAcceleratorFactories> |
| 28 RendererGpuVideoAcceleratorFactories::Create( | 28 RendererGpuVideoAcceleratorFactories::Create( |
| 29 GpuChannelHost* gpu_channel_host, | 29 GpuChannelHost* gpu_channel_host, |
| 30 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 30 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 31 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 31 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 32 bool enable_gpu_memory_buffer_video_frames, | 32 bool enable_gpu_memory_buffer_video_frames, |
| 33 unsigned image_texture_target, | 33 unsigned image_texture_target, |
| 34 media::VideoPixelFormat video_frame_output_format, |
| 34 bool enable_video_accelerator) { | 35 bool enable_video_accelerator) { |
| 35 scoped_refptr<RendererGpuVideoAcceleratorFactories> factories = | 36 scoped_refptr<RendererGpuVideoAcceleratorFactories> factories = |
| 36 new RendererGpuVideoAcceleratorFactories( | 37 new RendererGpuVideoAcceleratorFactories( |
| 37 gpu_channel_host, task_runner, context_provider, | 38 gpu_channel_host, task_runner, context_provider, |
| 38 enable_gpu_memory_buffer_video_frames, image_texture_target, | 39 enable_gpu_memory_buffer_video_frames, image_texture_target, |
| 39 enable_video_accelerator); | 40 video_frame_output_format, enable_video_accelerator); |
| 40 // Post task from outside constructor, since AddRef()/Release() is unsafe from | 41 // Post task from outside constructor, since AddRef()/Release() is unsafe from |
| 41 // within. | 42 // within. |
| 42 task_runner->PostTask( | 43 task_runner->PostTask( |
| 43 FROM_HERE, | 44 FROM_HERE, |
| 44 base::Bind(&RendererGpuVideoAcceleratorFactories::BindContext, | 45 base::Bind(&RendererGpuVideoAcceleratorFactories::BindContext, |
| 45 factories)); | 46 factories)); |
| 46 return factories; | 47 return factories; |
| 47 } | 48 } |
| 48 | 49 |
| 49 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( | 50 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( |
| 50 GpuChannelHost* gpu_channel_host, | 51 GpuChannelHost* gpu_channel_host, |
| 51 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 52 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 52 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 53 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 53 bool enable_gpu_memory_buffer_video_frames, | 54 bool enable_gpu_memory_buffer_video_frames, |
| 54 unsigned image_texture_target, | 55 unsigned image_texture_target, |
| 56 media::VideoPixelFormat video_frame_output_format, |
| 55 bool enable_video_accelerator) | 57 bool enable_video_accelerator) |
| 56 : task_runner_(task_runner), | 58 : task_runner_(task_runner), |
| 57 gpu_channel_host_(gpu_channel_host), | 59 gpu_channel_host_(gpu_channel_host), |
| 58 context_provider_(context_provider), | 60 context_provider_(context_provider), |
| 59 enable_gpu_memory_buffer_video_frames_( | 61 enable_gpu_memory_buffer_video_frames_( |
| 60 enable_gpu_memory_buffer_video_frames), | 62 enable_gpu_memory_buffer_video_frames), |
| 61 image_texture_target_(image_texture_target), | 63 image_texture_target_(image_texture_target), |
| 64 video_frame_output_format_(video_frame_output_format), |
| 62 video_accelerator_enabled_(enable_video_accelerator), | 65 video_accelerator_enabled_(enable_video_accelerator), |
| 63 gpu_memory_buffer_manager_(ChildThreadImpl::current() | 66 gpu_memory_buffer_manager_(ChildThreadImpl::current() |
| 64 ->gpu_memory_buffer_manager()), | 67 ->gpu_memory_buffer_manager()), |
| 65 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) { | 68 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) { |
| 66 DCHECK(gpu_channel_host_.get()); | 69 DCHECK(gpu_channel_host_.get()); |
| 67 } | 70 } |
| 68 | 71 |
| 69 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} | 72 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} |
| 70 | 73 |
| 71 void RendererGpuVideoAcceleratorFactories::BindContext() { | 74 void RendererGpuVideoAcceleratorFactories::BindContext() { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 231 |
| 229 bool RendererGpuVideoAcceleratorFactories:: | 232 bool RendererGpuVideoAcceleratorFactories:: |
| 230 ShouldUseGpuMemoryBuffersForVideoFrames() const { | 233 ShouldUseGpuMemoryBuffersForVideoFrames() const { |
| 231 return enable_gpu_memory_buffer_video_frames_; | 234 return enable_gpu_memory_buffer_video_frames_; |
| 232 } | 235 } |
| 233 | 236 |
| 234 unsigned RendererGpuVideoAcceleratorFactories::ImageTextureTarget() { | 237 unsigned RendererGpuVideoAcceleratorFactories::ImageTextureTarget() { |
| 235 return image_texture_target_; | 238 return image_texture_target_; |
| 236 } | 239 } |
| 237 | 240 |
| 241 media::VideoPixelFormat |
| 242 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { |
| 243 return video_frame_output_format_; |
| 244 } |
| 245 |
| 238 gpu::gles2::GLES2Interface* | 246 gpu::gles2::GLES2Interface* |
| 239 RendererGpuVideoAcceleratorFactories::GetGLES2Interface() { | 247 RendererGpuVideoAcceleratorFactories::GetGLES2Interface() { |
| 240 DCHECK(task_runner_->BelongsToCurrentThread()); | 248 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 241 | 249 |
| 242 WebGraphicsContext3DCommandBufferImpl* context = GetContext3d(); | 250 WebGraphicsContext3DCommandBufferImpl* context = GetContext3d(); |
| 243 if (!context) | 251 if (!context) |
| 244 return nullptr; | 252 return nullptr; |
| 245 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation(); | 253 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation(); |
| 246 return gles2; | 254 return gles2; |
| 247 } | 255 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 271 | 279 |
| 272 media::VideoEncodeAccelerator::SupportedProfiles | 280 media::VideoEncodeAccelerator::SupportedProfiles |
| 273 RendererGpuVideoAcceleratorFactories:: | 281 RendererGpuVideoAcceleratorFactories:: |
| 274 GetVideoEncodeAcceleratorSupportedProfiles() { | 282 GetVideoEncodeAcceleratorSupportedProfiles() { |
| 275 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles( | 283 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles( |
| 276 gpu_channel_host_->gpu_info() | 284 gpu_channel_host_->gpu_info() |
| 277 .video_encode_accelerator_supported_profiles); | 285 .video_encode_accelerator_supported_profiles); |
| 278 } | 286 } |
| 279 | 287 |
| 280 } // namespace content | 288 } // namespace content |
| OLD | NEW |