| 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 <memory> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "gpu/config/gpu_info.h" | |
| 14 #include "media/video/video_decode_accelerator.h" | |
| 15 | |
| 16 namespace gl { | |
| 17 class GLContext; | |
| 18 class GLImage; | |
| 19 } | |
| 20 | |
| 21 namespace gpu { | |
| 22 namespace gles2 { | |
| 23 class GLES2Decoder; | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 namespace media { | |
| 28 class GpuVideoDecodeAcceleratorFactoryImpl; | |
| 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(); | |
| 39 | |
| 40 // Return current GLContext. | |
| 41 using GetGLContextCallback = base::Callback<gl::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|. If | |
| 48 // |can_bind_to_sampler| is true, then the image may be used as a sampler | |
| 49 // directly, otherwise a copy to a staging buffer is required. | |
| 50 // Return true on success, false otherwise. | |
| 51 using BindGLImageCallback = | |
| 52 base::Callback<bool(uint32_t client_texture_id, | |
| 53 uint32_t texture_target, | |
| 54 const scoped_refptr<gl::GLImage>& image, | |
| 55 bool can_bind_to_sampler)>; | |
| 56 | |
| 57 // Return a WeakPtr to a GLES2Decoder, if one is available. | |
| 58 using GetGLES2DecoderCallback = | |
| 59 base::Callback<base::WeakPtr<gpu::gles2::GLES2Decoder>(void)>; | |
| 60 | |
| 61 // Create a factory capable of producing VDA instances for current platform. | |
| 62 static std::unique_ptr<GpuVideoDecodeAcceleratorFactory> Create( | |
| 63 const GetGLContextCallback& get_gl_context_cb, | |
| 64 const MakeGLContextCurrentCallback& make_context_current_cb, | |
| 65 const BindGLImageCallback& bind_image_cb); | |
| 66 | |
| 67 static std::unique_ptr<GpuVideoDecodeAcceleratorFactory> | |
| 68 CreateWithGLES2Decoder( | |
| 69 const GetGLContextCallback& get_gl_context_cb, | |
| 70 const MakeGLContextCurrentCallback& make_context_current_cb, | |
| 71 const BindGLImageCallback& bind_image_cb, | |
| 72 const GetGLES2DecoderCallback& get_gles2_decoder_cb); | |
| 73 | |
| 74 // Create a factory capable of producing VDA instances for current platform | |
| 75 // with no GL support. | |
| 76 // A factory created with this method will only be able to produce VDAs with | |
| 77 // no ability to call GL functions/access GL state. This also implies no | |
| 78 // ability to decode into textures provided by the client. | |
| 79 static std::unique_ptr<GpuVideoDecodeAcceleratorFactory> CreateWithNoGL(); | |
| 80 | |
| 81 // Return decoder capabilities supported on the current platform. | |
| 82 static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities(); | |
| 83 | |
| 84 // Create a VDA for the current platform for |client| with the given |config| | |
| 85 // and for given |gpu_preferences|. Return nullptr on failure. | |
| 86 virtual std::unique_ptr<media::VideoDecodeAccelerator> CreateVDA( | |
| 87 media::VideoDecodeAccelerator::Client* client, | |
| 88 const media::VideoDecodeAccelerator::Config& config); | |
| 89 | |
| 90 private: | |
| 91 // TODO(posciak): This is temporary and will not be needed once | |
| 92 // media::GpuVideoDecodeAcceleratorFactoryImpl implements | |
| 93 // GpuVideoDecodeAcceleratorFactory, see crbug.com/597150 and related. | |
| 94 GpuVideoDecodeAcceleratorFactory( | |
| 95 std::unique_ptr<media::GpuVideoDecodeAcceleratorFactoryImpl> | |
| 96 gvdafactory_impl); | |
| 97 | |
| 98 std::unique_ptr<media::GpuVideoDecodeAcceleratorFactoryImpl> | |
| 99 gvdafactory_impl_; | |
| 100 }; | |
| 101 | |
| 102 } // namespace content | |
| 103 | |
| 104 #endif // CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_ | |
| OLD | NEW |