| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "media/gpu/gpu_video_decode_accelerator_factory.h" | 5 #include "media/gpu/gpu_video_decode_accelerator_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "gpu/command_buffer/service/gpu_preferences.h" | 8 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 9 #include "media/base/media_switches.h" |
| 9 #include "media/gpu/gpu_video_accelerator_util.h" | 10 #include "media/gpu/gpu_video_accelerator_util.h" |
| 10 #include "media/gpu/media_gpu_export.h" | 11 #include "media/gpu/media_gpu_export.h" |
| 11 | 12 |
| 12 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 13 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
| 15 #include "media/gpu/d3d11_video_decode_accelerator_win.h" |
| 14 #include "media/gpu/dxva_video_decode_accelerator_win.h" | 16 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
| 15 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) |
| 16 #include "media/gpu/vt_video_decode_accelerator_mac.h" | 18 #include "media/gpu/vt_video_decode_accelerator_mac.h" |
| 17 #elif defined(OS_CHROMEOS) | 19 #elif defined(OS_CHROMEOS) |
| 18 #if defined(USE_V4L2_CODEC) | 20 #if defined(USE_V4L2_CODEC) |
| 19 #include "media/gpu/v4l2_device.h" | 21 #include "media/gpu/v4l2_device.h" |
| 20 #include "media/gpu/v4l2_slice_video_decode_accelerator.h" | 22 #include "media/gpu/v4l2_slice_video_decode_accelerator.h" |
| 21 #include "media/gpu/v4l2_video_decode_accelerator.h" | 23 #include "media/gpu/v4l2_video_decode_accelerator.h" |
| 22 #include "ui/gl/gl_surface_egl.h" | 24 #include "ui/gl/gl_surface_egl.h" |
| 23 #endif | 25 #endif |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 120 |
| 119 // Array of Create..VDA() function pointers, potentially usable on current | 121 // Array of Create..VDA() function pointers, potentially usable on current |
| 120 // platform. This list is ordered by priority, from most to least preferred, | 122 // platform. This list is ordered by priority, from most to least preferred, |
| 121 // if applicable. This list must be in the same order as the querying order | 123 // if applicable. This list must be in the same order as the querying order |
| 122 // in GetDecoderCapabilities() above. | 124 // in GetDecoderCapabilities() above. |
| 123 using CreateVDAFp = std::unique_ptr<VideoDecodeAccelerator> ( | 125 using CreateVDAFp = std::unique_ptr<VideoDecodeAccelerator> ( |
| 124 GpuVideoDecodeAcceleratorFactory::*)(const gpu::GpuDriverBugWorkarounds&, | 126 GpuVideoDecodeAcceleratorFactory::*)(const gpu::GpuDriverBugWorkarounds&, |
| 125 const gpu::GpuPreferences&) const; | 127 const gpu::GpuPreferences&) const; |
| 126 const CreateVDAFp create_vda_fps[] = { | 128 const CreateVDAFp create_vda_fps[] = { |
| 127 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 130 &GpuVideoDecodeAcceleratorFactory::CreateD3D11VDA, |
| 128 &GpuVideoDecodeAcceleratorFactory::CreateDXVAVDA, | 131 &GpuVideoDecodeAcceleratorFactory::CreateDXVAVDA, |
| 129 #endif | 132 #endif |
| 130 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 133 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 131 &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA, | 134 &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA, |
| 132 &GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA, | 135 &GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA, |
| 133 #endif | 136 #endif |
| 134 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 137 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 135 &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA, | 138 &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA, |
| 136 #endif | 139 #endif |
| 137 #if defined(OS_MACOSX) | 140 #if defined(OS_MACOSX) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 148 vda = (this->*create_vda_function)(workarounds, gpu_preferences); | 151 vda = (this->*create_vda_function)(workarounds, gpu_preferences); |
| 149 if (vda && vda->Initialize(config, client)) | 152 if (vda && vda->Initialize(config, client)) |
| 150 return vda; | 153 return vda; |
| 151 } | 154 } |
| 152 | 155 |
| 153 return nullptr; | 156 return nullptr; |
| 154 } | 157 } |
| 155 | 158 |
| 156 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
| 157 std::unique_ptr<VideoDecodeAccelerator> | 160 std::unique_ptr<VideoDecodeAccelerator> |
| 161 GpuVideoDecodeAcceleratorFactory::CreateD3D11VDA( |
| 162 const gpu::GpuDriverBugWorkarounds& workarounds, |
| 163 const gpu::GpuPreferences& gpu_preferences) const { |
| 164 std::unique_ptr<VideoDecodeAccelerator> decoder; |
| 165 if (!base::FeatureList::IsEnabled(kD3D11VideoDecoding)) |
| 166 return decoder; |
| 167 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 168 DVLOG(0) << "Initializing D3D11 HW decoder for windows."; |
| 169 decoder.reset(new D3D11VideoDecodeAccelerator(get_gl_context_cb_, |
| 170 make_context_current_cb_)); |
| 171 } |
| 172 return decoder; |
| 173 } |
| 174 |
| 175 std::unique_ptr<VideoDecodeAccelerator> |
| 158 GpuVideoDecodeAcceleratorFactory::CreateDXVAVDA( | 176 GpuVideoDecodeAcceleratorFactory::CreateDXVAVDA( |
| 159 const gpu::GpuDriverBugWorkarounds& workarounds, | 177 const gpu::GpuDriverBugWorkarounds& workarounds, |
| 160 const gpu::GpuPreferences& gpu_preferences) const { | 178 const gpu::GpuPreferences& gpu_preferences) const { |
| 161 std::unique_ptr<VideoDecodeAccelerator> decoder; | 179 std::unique_ptr<VideoDecodeAccelerator> decoder; |
| 162 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { | 180 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { |
| 163 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 181 DVLOG(0) << "Initializing DXVA HW decoder for windows."; |
| 164 decoder.reset(new DXVAVideoDecodeAccelerator( | 182 decoder.reset(new DXVAVideoDecodeAccelerator( |
| 165 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, | 183 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, |
| 166 workarounds, gpu_preferences)); | 184 workarounds, gpu_preferences)); |
| 167 } | 185 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 const BindGLImageCallback& bind_image_cb, | 259 const BindGLImageCallback& bind_image_cb, |
| 242 const GetGLES2DecoderCallback& get_gles2_decoder_cb) | 260 const GetGLES2DecoderCallback& get_gles2_decoder_cb) |
| 243 : get_gl_context_cb_(get_gl_context_cb), | 261 : get_gl_context_cb_(get_gl_context_cb), |
| 244 make_context_current_cb_(make_context_current_cb), | 262 make_context_current_cb_(make_context_current_cb), |
| 245 bind_image_cb_(bind_image_cb), | 263 bind_image_cb_(bind_image_cb), |
| 246 get_gles2_decoder_cb_(get_gles2_decoder_cb) {} | 264 get_gles2_decoder_cb_(get_gles2_decoder_cb) {} |
| 247 | 265 |
| 248 GpuVideoDecodeAcceleratorFactory::~GpuVideoDecodeAcceleratorFactory() {} | 266 GpuVideoDecodeAcceleratorFactory::~GpuVideoDecodeAcceleratorFactory() {} |
| 249 | 267 |
| 250 } // namespace media | 268 } // namespace media |
| OLD | NEW |