Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / media / video / gpu_memory_buffer_video_frame_pool.h
blob9e72e9b4d73b13461155915e147555965edf796b
1 // Copyright 2015 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.
5 #ifndef MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_
6 #define MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/task_runner.h"
11 #include "media/base/video_frame.h"
13 namespace base {
14 class SingleThreadTaskRunner;
17 namespace media {
18 class GpuVideoAcceleratorFactories;
20 // Interface to a pool of GpuMemoryBuffers/textues/images that can be used to
21 // transform software VideoFrames to VideoFrames backed by native textures.
22 // The resources used by the VideoFrame created by the pool will be
23 // automatically put back into the pool once the frame is destroyed.
24 // The pool recycles resources to a void unnecessarily allocating and
25 // destroying textures, images and GpuMemoryBuffer that could result
26 // in a round trip to the browser/GPU process.
27 class MEDIA_EXPORT GpuMemoryBufferVideoFramePool {
28 public:
29 GpuMemoryBufferVideoFramePool();
30 GpuMemoryBufferVideoFramePool(
31 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
32 const scoped_refptr<base::TaskRunner>& worker_task_runner,
33 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories);
34 virtual ~GpuMemoryBufferVideoFramePool();
36 // Callback used by MaybeCreateHardwareFrame to deliver a new VideoFrame
37 // after it has been copied to GpuMemoryBuffers.
38 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> FrameReadyCB;
40 // Calls |cb| on |media_worker_pool| with a new VideoFrame containing only
41 // mailboxes to native resources. |cb| will be destroyed on
42 // |media_worker_pool|.
43 // The content of the new object is copied from the software-allocated
44 // |video_frame|.
45 // If it's not possible to create a new hardware VideoFrame, |video_frame|
46 // itself will passed to |cb|.
47 virtual void MaybeCreateHardwareFrame(
48 const scoped_refptr<VideoFrame>& video_frame,
49 const FrameReadyCB& frame_ready_cb);
51 private:
52 class PoolImpl;
53 scoped_refptr<PoolImpl> pool_impl_;
55 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferVideoFramePool);
58 } // namespace media
60 #endif // MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_