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