Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h

Issue 1839193003: Reland: Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_IMPL_H_
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_IMPL_H_
7
8 #include "base/callback.h"
9 #include "base/threading/thread_checker.h"
10 #include "gpu/command_buffer/service/gpu_preferences.h"
11 #include "gpu/config/gpu_info.h"
12 #include "media/video/video_decode_accelerator.h"
13
14 namespace gfx {
15 class GLContext;
16 }
17
18 namespace gl {
19 class GLImage;
20 }
21
22 namespace gpu {
23 struct GpuPreferences;
24
25 namespace gles2 {
26 class GLES2Decoder;
27 }
28 }
29
30 namespace content {
31
32 // TODO(posciak): this class should be an implementation of
33 // content::GpuVideoDecodeAcceleratorFactory, however that can only be achieved
34 // once this is moved out of content/common, see crbug.com/597150 and related.
35 class GpuVideoDecodeAcceleratorFactoryImpl {
36 public:
37 ~GpuVideoDecodeAcceleratorFactoryImpl();
38
39 // Return current GLContext.
40 using GetGLContextCallback = base::Callback<gfx::GLContext*(void)>;
41
42 // Make the applicable GL context current. To be called by VDAs before
43 // executing any GL calls. Return true on success, false otherwise.
44 using MakeGLContextCurrentCallback = base::Callback<bool(void)>;
45
46 // Bind |image| to |client_texture_id| given |texture_target|. If
47 // |can_bind_to_sampler| is true, then the image may be used as a sampler
48 // directly, otherwise a copy to a staging buffer is required.
49 // Return true on success, false otherwise.
50 using BindGLImageCallback =
51 base::Callback<bool(uint32_t client_texture_id,
52 uint32_t texture_target,
53 const scoped_refptr<gl::GLImage>& image,
54 bool can_bind_to_sampler)>;
55
56 // Return a WeakPtr to a GLES2Decoder, if one is available.
57 using GetGLES2DecoderCallback =
58 base::Callback<base::WeakPtr<gpu::gles2::GLES2Decoder>(void)>;
59
60 static scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> Create(
61 const GetGLContextCallback& get_gl_context_cb,
62 const MakeGLContextCurrentCallback& make_context_current_cb,
63 const BindGLImageCallback& bind_image_cb);
64
65 static scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl>
66 CreateWithGLES2Decoder(
67 const GetGLContextCallback& get_gl_context_cb,
68 const MakeGLContextCurrentCallback& make_context_current_cb,
69 const BindGLImageCallback& bind_image_cb,
70 const GetGLES2DecoderCallback& get_gles2_decoder_cb);
71
72 static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities(
73 const gpu::GpuPreferences& gpu_preferences);
74
75 scoped_ptr<media::VideoDecodeAccelerator> CreateVDA(
76 media::VideoDecodeAccelerator::Client* client,
77 const media::VideoDecodeAccelerator::Config& config,
78 const gpu::GpuPreferences& gpu_preferences);
79
80 private:
81 GpuVideoDecodeAcceleratorFactoryImpl(
82 const GetGLContextCallback& get_gl_context_cb,
83 const MakeGLContextCurrentCallback& make_context_current_cb,
84 const BindGLImageCallback& bind_image_cb,
85 const GetGLES2DecoderCallback& get_gles2_decoder_cb);
86
87 #if defined(OS_WIN)
88 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(
89 const gpu::GpuPreferences& gpu_preferences) const;
90 #endif
91 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
92 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(
93 const gpu::GpuPreferences& gpu_preferences) const;
94 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA(
95 const gpu::GpuPreferences& gpu_preferences) const;
96 #endif
97 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
98 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(
99 const gpu::GpuPreferences& gpu_preferences) const;
100 #endif
101 #if defined(OS_MACOSX)
102 scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA(
103 const gpu::GpuPreferences& gpu_preferences) const;
104 #endif
105 #if defined(OS_ANDROID)
106 scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA(
107 const gpu::GpuPreferences& gpu_preferences) const;
108 #endif
109
110 const GetGLContextCallback get_gl_context_cb_;
111 const MakeGLContextCurrentCallback make_context_current_cb_;
112 const BindGLImageCallback bind_image_cb_;
113 const GetGLES2DecoderCallback get_gles2_decoder_cb_;
114
115 base::ThreadChecker thread_checker_;
116
117 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAcceleratorFactoryImpl);
118 };
119
120 } // namespace content
121
122 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698