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

Side by Side Diff: content/public/gpu/gpu_video_decode_accelerator_factory.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_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 "content/common/content_export.h"
11 #include "gpu/command_buffer/service/gpu_preferences.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 namespace gles2 {
25 class GLES2Decoder;
26 }
27 }
28
29 namespace content {
30
31 class GpuVideoDecodeAcceleratorFactoryImpl;
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<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|. 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 scoped_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 scoped_ptr<GpuVideoDecodeAcceleratorFactory> CreateWithGLES2Decoder(
68 const GetGLContextCallback& get_gl_context_cb,
69 const MakeGLContextCurrentCallback& make_context_current_cb,
70 const BindGLImageCallback& bind_image_cb,
71 const GetGLES2DecoderCallback& get_gles2_decoder_cb);
72
73 // Return decoder capabilities supported on the current platform.
74 static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities(
75 const gpu::GpuPreferences& gpu_preferences);
76
77 // Create a VDA for the current platform for |client| with the given |config|
78 // and for given |gpu_preferences|. Return nullptr on failure.
79 virtual scoped_ptr<media::VideoDecodeAccelerator> CreateVDA(
80 media::VideoDecodeAccelerator::Client* client,
81 const media::VideoDecodeAccelerator::Config& config,
82 const gpu::GpuPreferences& gpu_preferences);
83
84 private:
85 // TODO(posciak): This is temporary and will not be needed once
86 // GpuVideoDecodeAcceleratorFactoryImpl implements
87 // GpuVideoDecodeAcceleratorFactory, see crbug.com/597150 and related.
88 GpuVideoDecodeAcceleratorFactory(
89 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> gvdafactory_impl);
90
91 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> gvdafactory_impl_;
92 };
93
94 } // namespace content
95
96 #endif // CONTENT_PUBLIC_GPU_GPU_VIDEO_DECODE_ACCELERATOR_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698