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 "media/base/video_frame.h"
13 class SingleThreadTaskRunner
;
17 class GpuVideoAcceleratorFactories
;
19 // Interface to a pool of GpuMemoryBuffers/textues/images that can be used to
20 // transform software VideoFrames to VideoFrames backed by native textures.
21 // The resources used by the VideoFrame created by the pool will be
22 // automatically put back into the pool once the frame is destroyed.
23 // The pool recycles resources to a void unnecessarily allocating and
24 // destroying textures, images and GpuMemoryBuffer that could result
25 // in a round trip to the browser/GPU process.
26 class MEDIA_EXPORT GpuMemoryBufferVideoFramePool
{
28 GpuMemoryBufferVideoFramePool(
29 const scoped_refptr
<base::SingleThreadTaskRunner
>& task_runner
,
30 const scoped_refptr
<GpuVideoAcceleratorFactories
>& gpu_factories
);
31 ~GpuMemoryBufferVideoFramePool();
33 // Returns a new VideoFrame containing only mailboxes to native resources.
34 // The content of the returned object is copied from the software-allocated
36 // If it's not possible to create a new hardware VideoFrame, |video_frame|
37 // itself will be returned.
38 scoped_refptr
<VideoFrame
> MaybeCreateHardwareFrame(
39 const scoped_refptr
<VideoFrame
>& video_frame
);
43 scoped_refptr
<PoolImpl
> pool_impl_
;
45 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferVideoFramePool
);
50 #endif // MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_