Chromium Code Reviews| 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 "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/unguessable_token.h" | 13 #include "base/unguessable_token.h" |
| 14 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
| 15 #include "content/child/child_thread_impl.h" | 15 #include "content/child/child_thread_impl.h" |
| 16 #include "content/renderer/render_thread_impl.h" | 16 #include "content/renderer/render_thread_impl.h" |
| 17 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 19 #include "gpu/ipc/client/gpu_channel_host.h" | 19 #include "gpu/ipc/client/gpu_channel_host.h" |
| 20 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | |
| 20 #include "media/gpu/gpu_video_accelerator_util.h" | 21 #include "media/gpu/gpu_video_accelerator_util.h" |
| 21 #include "media/gpu/ipc/client/gpu_video_decode_accelerator_host.h" | 22 #include "media/gpu/ipc/client/gpu_video_decode_accelerator_host.h" |
| 22 #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h" | 23 #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h" |
| 23 #include "media/gpu/ipc/common/media_messages.h" | 24 #include "media/gpu/ipc/common/media_messages.h" |
| 24 #include "media/video/video_decode_accelerator.h" | 25 #include "media/video/video_decode_accelerator.h" |
| 25 #include "media/video/video_encode_accelerator.h" | 26 #include "media/video/video_encode_accelerator.h" |
| 26 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 27 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 | 30 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 | 262 |
| 262 media::GpuVideoAcceleratorFactories::OutputFormat | 263 media::GpuVideoAcceleratorFactories::OutputFormat |
| 263 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { | 264 RendererGpuVideoAcceleratorFactories::VideoFrameOutputFormat() { |
| 264 DCHECK(task_runner_->BelongsToCurrentThread()); | 265 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 265 if (CheckContextLost()) | 266 if (CheckContextLost()) |
| 266 return media::GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED; | 267 return media::GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED; |
| 267 cc::ContextProvider::ScopedContextLock lock(context_provider_); | 268 cc::ContextProvider::ScopedContextLock lock(context_provider_); |
| 268 auto capabilities = context_provider_->ContextCapabilities(); | 269 auto capabilities = context_provider_->ContextCapabilities(); |
| 269 if (capabilities.image_ycbcr_420v) | 270 if (capabilities.image_ycbcr_420v) |
| 270 return media::GpuVideoAcceleratorFactories::OutputFormat::NV12_SINGLE_GMB; | 271 return media::GpuVideoAcceleratorFactories::OutputFormat::NV12_SINGLE_GMB; |
| 271 if (capabilities.image_ycbcr_422) | 272 if (capabilities.image_ycbcr_422) { |
| 273 #if defined(OS_MACOSX) | |
| 274 // Mac supports UYVY IOSurface. | |
| 272 return media::GpuVideoAcceleratorFactories::OutputFormat::UYVY; | 275 return media::GpuVideoAcceleratorFactories::OutputFormat::UYVY; |
| 276 #elif defined(OS_CHROMEOS) | |
| 277 // Native GPU memory buffers are required. | |
| 278 if (gpu::IsNativeGpuMemoryBufferConfigurationSupported( | |
| 279 gfx::BufferFormat::YUYV_422, | |
| 280 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE)) { | |
| 281 // Mesa EGL supports not UYVY but YUYV image. | |
|
marcheu1
2017/01/21 00:25:18
pleaes don't add platform-specific code, even comm
dshwang
2017/01/23 23:13:42
Done.
| |
| 282 return media::GpuVideoAcceleratorFactories::OutputFormat::YUYV; | |
| 283 } | |
| 284 #endif | |
| 285 } | |
| 286 | |
| 273 if (capabilities.texture_rg) | 287 if (capabilities.texture_rg) |
| 274 return media::GpuVideoAcceleratorFactories::OutputFormat::NV12_DUAL_GMB; | 288 return media::GpuVideoAcceleratorFactories::OutputFormat::NV12_DUAL_GMB; |
| 275 return media::GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED; | 289 return media::GpuVideoAcceleratorFactories::OutputFormat::UNDEFINED; |
| 276 } | 290 } |
| 277 | 291 |
| 278 namespace { | 292 namespace { |
| 279 class ScopedGLContextLockImpl | 293 class ScopedGLContextLockImpl |
| 280 : public media::GpuVideoAcceleratorFactories::ScopedGLContextLock { | 294 : public media::GpuVideoAcceleratorFactories::ScopedGLContextLock { |
| 281 public: | 295 public: |
| 282 ScopedGLContextLockImpl(cc::ContextProvider* context_provider) | 296 ScopedGLContextLockImpl(cc::ContextProvider* context_provider) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 context_provider_refptr_ = nullptr; | 344 context_provider_refptr_ = nullptr; |
| 331 } | 345 } |
| 332 | 346 |
| 333 scoped_refptr<ui::ContextProviderCommandBuffer> | 347 scoped_refptr<ui::ContextProviderCommandBuffer> |
| 334 RendererGpuVideoAcceleratorFactories::ContextProviderMainThread() { | 348 RendererGpuVideoAcceleratorFactories::ContextProviderMainThread() { |
| 335 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 349 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 336 return context_provider_refptr_; | 350 return context_provider_refptr_; |
| 337 } | 351 } |
| 338 | 352 |
| 339 } // namespace content | 353 } // namespace content |
| OLD | NEW |