Commit becaa513 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media/gpu/linux: Move GetDmabufId() method to DmabufVideoFramePool.

The GetDmabufId() method is getting an identifier of a Dma-buf
VideoFrame. The method is used for all DmabufVideoFramePool
implementations, not only PlatformVideoFramePool. This CL moves the
method to DmabufVideoFramePool.

BUG=b:136716638
TEST=media_unittests --gtest_filter=PlatformVideoFramePoolTest.*

Change-Id: I6950c1cf5a5127778a3dba2bbf2475fd4779a679
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824501
Auto-Submit: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700120}
parent 6150156d
......@@ -6,6 +6,12 @@
namespace media {
// static
DmabufVideoFramePool::DmabufId DmabufVideoFramePool::GetDmabufId(
const VideoFrame& frame) {
return &(frame.DmabufFds());
}
DmabufVideoFramePool::DmabufVideoFramePool() = default;
DmabufVideoFramePool::~DmabufVideoFramePool() = default;
......
......@@ -23,6 +23,12 @@ namespace media {
// implementation must be thread-safe.
class MEDIA_GPU_EXPORT DmabufVideoFramePool {
public:
using DmabufId = const std::vector<base::ScopedFD>*;
// Get the identifier of Dmabuf-backed |frame|. Calling this method with the
// frames backed by the same Dmabuf should return the same result.
static DmabufId GetDmabufId(const VideoFrame& frame);
DmabufVideoFramePool();
virtual ~DmabufVideoFramePool();
......
......@@ -27,12 +27,6 @@ scoped_refptr<VideoFrame> DefaultCreateFrame(VideoPixelFormat format,
gfx::BufferUsage::SCANOUT_VDA_WRITE);
}
// Get the identifier of |frame|. Calling this method with the frames backed
// by the same Dmabuf should return the same result.
PlatformVideoFramePool::DmabufId GetDmabufId(const VideoFrame& frame) {
return &(frame.DmabufFds());
}
} // namespace
PlatformVideoFramePool::PlatformVideoFramePool()
......
......@@ -34,8 +34,6 @@ namespace media {
// old parameter values will be purged from the pool.
class MEDIA_GPU_EXPORT PlatformVideoFramePool : public DmabufVideoFramePool {
public:
using DmabufId = const std::vector<base::ScopedFD>*;
PlatformVideoFramePool();
~PlatformVideoFramePool() override;
......
......@@ -50,7 +50,7 @@ scoped_refptr<VideoFrame> CreateDmabufVideoFrame(VideoPixelFormat format,
class PlatformVideoFramePoolTest
: public ::testing::TestWithParam<VideoPixelFormat> {
public:
using DmabufId = PlatformVideoFramePool::DmabufId;
using DmabufId = DmabufVideoFramePool::DmabufId;
PlatformVideoFramePoolTest()
: task_environment_(base::test::TaskEnvironment::TimeSource::MOCK_TIME) {
......@@ -86,8 +86,6 @@ class PlatformVideoFramePoolTest
EXPECT_EQ(size, pool_->GetPoolSizeForTesting());
}
DmabufId GetDmabufId(const VideoFrame& frame) { return &(frame.DmabufFds()); }
protected:
base::test::TaskEnvironment task_environment_;
std::unique_ptr<PlatformVideoFramePool,
......@@ -108,7 +106,7 @@ INSTANTIATE_TEST_SUITE_P(,
TEST_F(PlatformVideoFramePoolTest, SingleFrameReuse) {
SetFrameFormat(PIXEL_FORMAT_I420);
scoped_refptr<VideoFrame> frame = GetFrame(10);
DmabufId id = GetDmabufId(*frame);
DmabufId id = DmabufVideoFramePool::GetDmabufId(*frame);
// Clear frame reference to return the frame to the pool.
frame = nullptr;
......@@ -116,25 +114,25 @@ TEST_F(PlatformVideoFramePoolTest, SingleFrameReuse) {
// Verify that the next frame from the pool uses the same memory.
scoped_refptr<VideoFrame> new_frame = GetFrame(20);
EXPECT_EQ(id, GetDmabufId(*new_frame));
EXPECT_EQ(id, DmabufVideoFramePool::GetDmabufId(*new_frame));
}
TEST_F(PlatformVideoFramePoolTest, MultipleFrameReuse) {
SetFrameFormat(PIXEL_FORMAT_I420);
scoped_refptr<VideoFrame> frame1 = GetFrame(10);
scoped_refptr<VideoFrame> frame2 = GetFrame(20);
DmabufId id1 = GetDmabufId(*frame1);
DmabufId id2 = GetDmabufId(*frame2);
DmabufId id1 = DmabufVideoFramePool::GetDmabufId(*frame1);
DmabufId id2 = DmabufVideoFramePool::GetDmabufId(*frame2);
frame1 = nullptr;
task_environment_.RunUntilIdle();
frame1 = GetFrame(30);
EXPECT_EQ(id1, GetDmabufId(*frame1));
EXPECT_EQ(id1, DmabufVideoFramePool::GetDmabufId(*frame1));
frame2 = nullptr;
task_environment_.RunUntilIdle();
frame2 = GetFrame(40);
EXPECT_EQ(id2, GetDmabufId(*frame2));
EXPECT_EQ(id2, DmabufVideoFramePool::GetDmabufId(*frame2));
frame1 = nullptr;
frame2 = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment