| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_IMPL_H_ | |
| 6 #define MEDIA_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_IMPL_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "gpu/command_buffer/service/gpu_preferences.h" | |
| 13 #include "gpu/config/gpu_driver_bug_workarounds.h" | |
| 14 #include "gpu/config/gpu_info.h" | |
| 15 #include "media/gpu/media_gpu_export.h" | |
| 16 #include "media/video/video_decode_accelerator.h" | |
| 17 | |
| 18 namespace gl { | |
| 19 class GLContext; | |
| 20 class GLImage; | |
| 21 } | |
| 22 | |
| 23 namespace gpu { | |
| 24 struct GpuPreferences; | |
| 25 | |
| 26 namespace gles2 { | |
| 27 class GLES2Decoder; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 namespace media { | |
| 32 | |
| 33 class MEDIA_GPU_EXPORT GpuVideoDecodeAcceleratorFactoryImpl { | |
| 34 public: | |
| 35 ~GpuVideoDecodeAcceleratorFactoryImpl(); | |
| 36 | |
| 37 // Return current GLContext. | |
| 38 using GetGLContextCallback = base::Callback<gl::GLContext*(void)>; | |
| 39 | |
| 40 // Make the applicable GL context current. To be called by VDAs before | |
| 41 // executing any GL calls. Return true on success, false otherwise. | |
| 42 using MakeGLContextCurrentCallback = base::Callback<bool(void)>; | |
| 43 | |
| 44 // Bind |image| to |client_texture_id| given |texture_target|. If | |
| 45 // |can_bind_to_sampler| is true, then the image may be used as a sampler | |
| 46 // directly, otherwise a copy to a staging buffer is required. | |
| 47 // Return true on success, false otherwise. | |
| 48 using BindGLImageCallback = | |
| 49 base::Callback<bool(uint32_t client_texture_id, | |
| 50 uint32_t texture_target, | |
| 51 const scoped_refptr<gl::GLImage>& image, | |
| 52 bool can_bind_to_sampler)>; | |
| 53 | |
| 54 // Return a WeakPtr to a GLES2Decoder, if one is available. | |
| 55 using GetGLES2DecoderCallback = | |
| 56 base::Callback<base::WeakPtr<gpu::gles2::GLES2Decoder>(void)>; | |
| 57 | |
| 58 static std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> Create( | |
| 59 const GetGLContextCallback& get_gl_context_cb, | |
| 60 const MakeGLContextCurrentCallback& make_context_current_cb, | |
| 61 const BindGLImageCallback& bind_image_cb); | |
| 62 | |
| 63 static std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> | |
| 64 CreateWithGLES2Decoder( | |
| 65 const GetGLContextCallback& get_gl_context_cb, | |
| 66 const MakeGLContextCurrentCallback& make_context_current_cb, | |
| 67 const BindGLImageCallback& bind_image_cb, | |
| 68 const GetGLES2DecoderCallback& get_gles2_decoder_cb); | |
| 69 | |
| 70 static std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> CreateWithNoGL(); | |
| 71 | |
| 72 static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities( | |
| 73 const gpu::GpuPreferences& gpu_preferences); | |
| 74 | |
| 75 std::unique_ptr<VideoDecodeAccelerator> CreateVDA( | |
| 76 VideoDecodeAccelerator::Client* client, | |
| 77 const VideoDecodeAccelerator::Config& config, | |
| 78 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 79 const gpu::GpuPreferences& gpu_preferences); | |
| 80 | |
| 81 private: | |
| 82 GpuVideoDecodeAcceleratorFactoryImpl( | |
| 83 const GetGLContextCallback& get_gl_context_cb, | |
| 84 const MakeGLContextCurrentCallback& make_context_current_cb, | |
| 85 const BindGLImageCallback& bind_image_cb, | |
| 86 const GetGLES2DecoderCallback& get_gles2_decoder_cb); | |
| 87 | |
| 88 #if defined(OS_WIN) | |
| 89 std::unique_ptr<VideoDecodeAccelerator> CreateDXVAVDA( | |
| 90 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 91 const gpu::GpuPreferences& gpu_preferences) const; | |
| 92 #endif | |
| 93 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
| 94 std::unique_ptr<VideoDecodeAccelerator> CreateV4L2VDA( | |
| 95 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 96 const gpu::GpuPreferences& gpu_preferences) const; | |
| 97 std::unique_ptr<VideoDecodeAccelerator> CreateV4L2SVDA( | |
| 98 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 99 const gpu::GpuPreferences& gpu_preferences) const; | |
| 100 #endif | |
| 101 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 102 std::unique_ptr<VideoDecodeAccelerator> CreateVaapiVDA( | |
| 103 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 104 const gpu::GpuPreferences& gpu_preferences) const; | |
| 105 #endif | |
| 106 #if defined(OS_MACOSX) | |
| 107 std::unique_ptr<VideoDecodeAccelerator> CreateVTVDA( | |
| 108 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 109 const gpu::GpuPreferences& gpu_preferences) const; | |
| 110 #endif | |
| 111 #if defined(OS_ANDROID) | |
| 112 std::unique_ptr<VideoDecodeAccelerator> CreateAndroidVDA( | |
| 113 const gpu::GpuDriverBugWorkarounds& workarounds, | |
| 114 const gpu::GpuPreferences& gpu_preferences) const; | |
| 115 #endif | |
| 116 | |
| 117 const GetGLContextCallback get_gl_context_cb_; | |
| 118 const MakeGLContextCurrentCallback make_context_current_cb_; | |
| 119 const BindGLImageCallback bind_image_cb_; | |
| 120 const GetGLES2DecoderCallback get_gles2_decoder_cb_; | |
| 121 | |
| 122 base::ThreadChecker thread_checker_; | |
| 123 | |
| 124 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAcceleratorFactoryImpl); | |
| 125 }; | |
| 126 | |
| 127 } // namespace media | |
| 128 | |
| 129 #endif // MEDIA_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_IMPL_H_ | |
| OLD | NEW |