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 CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ |
| 6 #define CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/thread_checker.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "gpu/config/gpu_info.h" |
| 13 #include "media/video/video_decode_accelerator.h" |
| 14 |
| 15 namespace gfx { |
| 16 class GLContext; |
| 17 } |
| 18 |
| 19 namespace gl { |
| 20 class GLImage; |
| 21 } |
| 22 |
| 23 namespace gpu { |
| 24 struct GpuPreferences; |
| 25 |
| 26 namespace gles2 { |
| 27 class GLES2Decoder; |
| 28 } |
| 29 } |
| 30 |
| 31 namespace content { |
| 32 |
| 33 // This factory allows creation of VideoDecodeAccelerator implementations, |
| 34 // providing the most applicable VDA for current platform and given |
| 35 // configuration. To be used in GPU process only. |
| 36 class CONTENT_EXPORT GpuVideoDecodeAcceleratorFactory { |
| 37 public: |
| 38 virtual ~GpuVideoDecodeAcceleratorFactory() = default; |
| 39 |
| 40 // Return current GLContext. |
| 41 using GetGLContextCallback = base::Callback<gfx::GLContext*(void)>; |
| 42 |
| 43 // Make the applicable GL context current. To be called by VDAs before |
| 44 // executing any GL calls. Return true on success, false otherwise. |
| 45 using MakeGLContextCurrentCallback = base::Callback<bool(void)>; |
| 46 |
| 47 // Bind |image| to |client_texture_id| given |texture_target|. |
| 48 // Return true on success, false otherwise. |
| 49 using BindGLImageCallback = |
| 50 base::Callback<bool(uint32_t client_texture_id, |
| 51 uint32_t texture_target, |
| 52 const scoped_refptr<gl::GLImage>& image)>; |
| 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 // Create a factory capable of producing VDA instances for current platform. |
| 59 static scoped_ptr<GpuVideoDecodeAcceleratorFactory> Create( |
| 60 const GetGLContextCallback& get_gl_context_cb, |
| 61 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 62 const BindGLImageCallback& bind_image_cb); |
| 63 |
| 64 static scoped_ptr<GpuVideoDecodeAcceleratorFactory> 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 // Return decoder capabilities supported on the current platform. |
| 71 static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities( |
| 72 const gpu::GpuPreferences& gpu_preferences); |
| 73 |
| 74 // Create a VDA for the current platform for |client| with the given |config| |
| 75 // and for given |gpu_preferences|. Return nullptr on failure. |
| 76 virtual scoped_ptr<media::VideoDecodeAccelerator> CreateVDA( |
| 77 media::VideoDecodeAccelerator::Client* client, |
| 78 const media::VideoDecodeAccelerator::Config& config, |
| 79 const gpu::GpuPreferences& gpu_preferences) = 0; |
| 80 }; |
| 81 |
| 82 } // namespace content |
| 83 |
| 84 #endif // CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ |
OLD | NEW |