diff options
author | posciak <posciak@chromium.org> | 2016-03-24 23:02:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 06:03:50 +0000 |
commit | 6977e5243786901a766a38c2c291464875dffbd6 (patch) | |
tree | cdda3912792594e80978880986bce932dfca9b4d /media | |
parent | e582c0b02df6a3f4406bb075b22f71f3d931f581 (diff) | |
download | chromium_src-6977e5243786901a766a38c2c291464875dffbd6.zip chromium_src-6977e5243786901a766a38c2c291464875dffbd6.tar.gz chromium_src-6977e5243786901a766a38c2c291464875dffbd6.tar.bz2 |
Introduce GpuVideoDecodeAcceleratorFactory.
- Move platform-specific code from GpuVideoDecodeAccelerator to
GpuVideoDecodeAcceleratorFactory.
- Make GVDAFactory a content/public interface, to provide the ability to
instantiate VDAs from outside content/.
- Unify how we obtain access to various GL functionality/classes from VDAs
by introducing a set of callbacks provided by the client.
- Replace VDA::CanDecodeOnIOThread() with
VDA::TryInitializeDecodeOnSeparateThread(). This allows us to remove
additional client/taskrunner arguments from VDA constructors, and give client
the option to use a separate thread to decode, instead of having to make this
decision in the factory, and enforcing these arguments in the constructors.
- Deduplicate VDA creation code across users (currently GVDA and vdaunittest).
BUG=b/27687678
TEST=compile/run various VDA impls
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel
Review URL: https://codereview.chromium.org/1745903002
Cr-Commit-Position: refs/heads/master@{#383256}
Diffstat (limited to 'media')
-rw-r--r-- | media/video/mock_video_decode_accelerator.h | 4 | ||||
-rw-r--r-- | media/video/video_decode_accelerator.cc | 8 | ||||
-rw-r--r-- | media/video/video_decode_accelerator.h | 54 |
3 files changed, 47 insertions, 19 deletions
diff --git a/media/video/mock_video_decode_accelerator.h b/media/video/mock_video_decode_accelerator.h index 63aeaad..89978987 100644 --- a/media/video/mock_video_decode_accelerator.h +++ b/media/video/mock_video_decode_accelerator.h @@ -34,7 +34,9 @@ class MockVideoDecodeAccelerator : public VideoDecodeAccelerator { MOCK_METHOD0(Flush, void()); MOCK_METHOD0(Reset, void()); MOCK_METHOD0(Destroy, void()); - MOCK_METHOD0(CanDecodeOnIOThread, bool()); + MOCK_METHOD2(TryToSetupDecodeOnSeparateThread, + bool(const base::WeakPtr<Client>&, + const scoped_refptr<base::SingleThreadTaskRunner>&)); private: void DeleteThis(); diff --git a/media/video/video_decode_accelerator.cc b/media/video/video_decode_accelerator.cc index f99787a..00ae88c 100644 --- a/media/video/video_decode_accelerator.cc +++ b/media/video/video_decode_accelerator.cc @@ -34,9 +34,11 @@ void VideoDecodeAccelerator::SetCdm(int cdm_id) { NOTREACHED() << "By default CDM is not supported."; } -bool VideoDecodeAccelerator::CanDecodeOnIOThread() { - // GPU process subclasses must override this. - LOG(FATAL) << "This should only get called in the GPU process"; +bool VideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( + const base::WeakPtr<Client>& decode_client, + const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { + // Implementations in the process that VDA runs in must override this. + LOG(FATAL) << "This may only be called in the same process as VDA impl."; return false; // not reached } diff --git a/media/video/video_decode_accelerator.h b/media/video/video_decode_accelerator.h index a840750..4552973 100644 --- a/media/video/video_decode_accelerator.h +++ b/media/video/video_decode_accelerator.h @@ -10,15 +10,20 @@ #include <memory> #include <vector> +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" #include "media/base/bitstream_buffer.h" #include "media/base/surface_manager.h" #include "media/base/video_decoder_config.h" #include "media/video/picture.h" #include "ui/gfx/geometry/size.h" -#include "ui/gl/gl_image.h" typedef unsigned int GLenum; +namespace base { +class SingleThreadTaskRunner; +} + namespace media { // Video decoder interface. @@ -38,10 +43,6 @@ class MEDIA_EXPORT VideoDecodeAccelerator { }; using SupportedProfiles = std::vector<SupportedProfile>; - using MakeContextCurrentCallback = base::Callback<bool(void)>; - using BindImageCallback = base::Callback< - void(uint32_t, uint32_t, scoped_refptr<gl::GLImage>, bool)>; - struct MEDIA_EXPORT Capabilities { Capabilities(); Capabilities(const Capabilities& other); @@ -229,16 +230,39 @@ class MEDIA_EXPORT VideoDecodeAccelerator { // unconditionally, so make sure to drop all pointers to it! virtual void Destroy() = 0; - // GPU PROCESS ONLY. Implementations of this interface in the - // content/common/gpu/media should implement this, and implementations in - // other processes should not override the default implementation. - // Returns true if VDA::Decode and VDA::Client callbacks can run on the IO - // thread. Otherwise they will run on the GPU child thread. The purpose of - // running Decode on the IO thread is to reduce decode latency. Note Decode - // should return as soon as possible and not block on the IO thread. Also, - // PictureReady should be run on the child thread if a picture is delivered - // the first time so it can be cleared. - virtual bool CanDecodeOnIOThread(); + // TO BE CALLED IN THE SAME PROCESS AS THE VDA IMPLEMENTATION ONLY. + // + // A decode "task" is a sequence that includes a Decode() call from Client, + // as well as corresponding callbacks to return the input BitstreamBuffer + // after use, and the resulting output Picture(s). + // + // If the Client can support running these three calls on a separate thread, + // it may call this method to try to set up the VDA implementation to do so. + // If the VDA can support this as well, return true, otherwise return false. + // If true is returned, the client may submit each Decode() call (but no other + // calls) on |decode_task_runner|, and should then expect that + // NotifyEndOfBitstreamBuffer() and PictureReady() callbacks may come on + // |decode_task_runner| as well, called on |decode_client|, instead of client + // provided to Initialize(). + // + // This method may be called at any time. + // + // NOTE 1: some callbacks may still have to come on the main thread and the + // Client should handle both callbacks coming on main and |decode_task_runner| + // thread. + // + // NOTE 2: VDA implementations of Decode() must return as soon as possible and + // never block, as |decode_task_runner| may be a latency critical thread + // (such as the GPU IO thread). + // + // One application of this is offloading the GPU Child thread. In general, + // calls to VDA in GPU process have to be done on the GPU Child thread, as + // they may require GL context to be current. However, some VDAs may be able + // to run decode operations without GL context, which helps reduce latency and + // offloads the GPU Child thread. + virtual bool TryToSetupDecodeOnSeparateThread( + const base::WeakPtr<Client>& decode_client, + const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner); // Windows creates a BGRA texture. // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 |