| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 std::unique_ptr<RendererGpuVideoAcceleratorFactories> | 46 std::unique_ptr<RendererGpuVideoAcceleratorFactories> |
| 47 RendererGpuVideoAcceleratorFactories::Create( | 47 RendererGpuVideoAcceleratorFactories::Create( |
| 48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 48 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 49 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, | 49 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, |
| 50 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 50 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 51 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 51 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 52 bool enable_gpu_memory_buffer_video_frames, | 52 bool enable_gpu_memory_buffer_video_frames, |
| 53 std::vector<unsigned> image_texture_targets, | 53 const cc::BufferToTextureTargetMap& image_texture_targets, |
| 54 bool enable_video_accelerator) { | 54 bool enable_video_accelerator) { |
| 55 RecordContextProviderPhaseUmaEnum( | 55 RecordContextProviderPhaseUmaEnum( |
| 56 ContextProviderPhase::CONTEXT_PROVIDER_ACQUIRED); | 56 ContextProviderPhase::CONTEXT_PROVIDER_ACQUIRED); |
| 57 return base::WrapUnique(new RendererGpuVideoAcceleratorFactories( | 57 return base::WrapUnique(new RendererGpuVideoAcceleratorFactories( |
| 58 std::move(gpu_channel_host), main_thread_task_runner, task_runner, | 58 std::move(gpu_channel_host), main_thread_task_runner, task_runner, |
| 59 context_provider, enable_gpu_memory_buffer_video_frames, | 59 context_provider, enable_gpu_memory_buffer_video_frames, |
| 60 image_texture_targets, enable_video_accelerator)); | 60 image_texture_targets, enable_video_accelerator)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( | 63 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( |
| 64 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 64 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 65 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, | 65 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, |
| 66 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 66 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 67 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 67 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 68 bool enable_gpu_memory_buffer_video_frames, | 68 bool enable_gpu_memory_buffer_video_frames, |
| 69 std::vector<unsigned> image_texture_targets, | 69 const cc::BufferToTextureTargetMap& image_texture_targets, |
| 70 bool enable_video_accelerator) | 70 bool enable_video_accelerator) |
| 71 : main_thread_task_runner_(main_thread_task_runner), | 71 : main_thread_task_runner_(main_thread_task_runner), |
| 72 task_runner_(task_runner), | 72 task_runner_(task_runner), |
| 73 gpu_channel_host_(std::move(gpu_channel_host)), | 73 gpu_channel_host_(std::move(gpu_channel_host)), |
| 74 context_provider_refptr_(context_provider), | 74 context_provider_refptr_(context_provider), |
| 75 context_provider_(context_provider.get()), | 75 context_provider_(context_provider.get()), |
| 76 enable_gpu_memory_buffer_video_frames_( | 76 enable_gpu_memory_buffer_video_frames_( |
| 77 enable_gpu_memory_buffer_video_frames), | 77 enable_gpu_memory_buffer_video_frames), |
| 78 image_texture_targets_(image_texture_targets), | 78 image_texture_targets_(image_texture_targets), |
| 79 video_accelerator_enabled_(enable_video_accelerator), | 79 video_accelerator_enabled_(enable_video_accelerator), |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 size, format, usage, gpu::kNullSurfaceHandle); | 222 size, format, usage, gpu::kNullSurfaceHandle); |
| 223 return buffer; | 223 return buffer; |
| 224 } | 224 } |
| 225 bool RendererGpuVideoAcceleratorFactories:: | 225 bool RendererGpuVideoAcceleratorFactories:: |
| 226 ShouldUseGpuMemoryBuffersForVideoFrames() const { | 226 ShouldUseGpuMemoryBuffersForVideoFrames() const { |
| 227 return enable_gpu_memory_buffer_video_frames_; | 227 return enable_gpu_memory_buffer_video_frames_; |
| 228 } | 228 } |
| 229 | 229 |
| 230 unsigned RendererGpuVideoAcceleratorFactories::ImageTextureTarget( | 230 unsigned RendererGpuVideoAcceleratorFactories::ImageTextureTarget( |
| 231 gfx::BufferFormat format) { | 231 gfx::BufferFormat format) { |
| 232 return image_texture_targets_[static_cast<int>(format)]; | 232 auto found = image_texture_targets_.find(cc::BufferToTextureTargetKey( |
| 233 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, format)); |
| 234 DCHECK(found != image_texture_targets_.end()); |
| 235 return found->second; |
| 233 } | 236 } |
| 234 | 237 |
| 235 media::VideoPixelFormat | 238 media::VideoPixelFormat |
| 236 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { | 239 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { |
| 237 DCHECK(task_runner_->BelongsToCurrentThread()); | 240 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 238 if (CheckContextLost()) | 241 if (CheckContextLost()) |
| 239 return media::PIXEL_FORMAT_UNKNOWN; | 242 return media::PIXEL_FORMAT_UNKNOWN; |
| 240 cc::ContextProvider::ScopedContextLock lock(context_provider_); | 243 cc::ContextProvider::ScopedContextLock lock(context_provider_); |
| 241 auto capabilities = context_provider_->ContextCapabilities(); | 244 auto capabilities = context_provider_->ContextCapabilities(); |
| 242 if (capabilities.image_ycbcr_420v) | 245 if (capabilities.image_ycbcr_420v) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 context_provider_refptr_ = nullptr; | 306 context_provider_refptr_ = nullptr; |
| 304 } | 307 } |
| 305 | 308 |
| 306 scoped_refptr<ContextProviderCommandBuffer> | 309 scoped_refptr<ContextProviderCommandBuffer> |
| 307 RendererGpuVideoAcceleratorFactories::ContextProviderMainThread() { | 310 RendererGpuVideoAcceleratorFactories::ContextProviderMainThread() { |
| 308 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 311 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 309 return context_provider_refptr_; | 312 return context_provider_refptr_; |
| 310 } | 313 } |
| 311 | 314 |
| 312 } // namespace content | 315 } // namespace content |
| OLD | NEW |