1 // Copyright 2021 The Chromium Authors
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_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_
6 #define MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_
11 #include "base/functional/bind.h"
12 #include "components/viz/common/gpu/context_provider.h"
13 #include "media/base/video_frame.h"
17 // Creates a video frame from a set of shared images with a common texture
18 // target and sync token.
19 scoped_refptr<VideoFrame> CreateSharedImageFrame(
20 scoped_refptr<viz::ContextProvider> context_provider,
21 VideoPixelFormat format,
22 std::vector<gpu::Mailbox> mailboxes,
23 const gpu::SyncToken& sync_token,
24 GLenum texture_target,
25 const gfx::Size& coded_size,
26 const gfx::Rect& visible_rect,
27 const gfx::Size& natural_size,
28 base::TimeDelta timestamp,
29 base::OnceClosure destroyed_callback);
31 // Creates a shared image backed frame in RGBA format, with colors on the shared
32 // image mapped as follow.
36 scoped_refptr<VideoFrame> CreateSharedImageRGBAFrame(
37 scoped_refptr<viz::ContextProvider> context_provider,
38 const gfx::Size& coded_size,
39 const gfx::Rect& visible_rect,
40 base::OnceClosure destroyed_callback);
42 // Creates a shared image backed frame in I420 format, with colors mapped
43 // exactly like CreateSharedImageRGBAFrame above, noting that subsamples may get
44 // interpolated leading to inconsistent colors around the "seams".
45 scoped_refptr<VideoFrame> CreateSharedImageI420Frame(
46 scoped_refptr<viz::ContextProvider> context_provider,
47 const gfx::Size& coded_size,
48 const gfx::Rect& visible_rect,
49 base::OnceClosure destroyed_callback);
51 // Creates a shared image backed frame in NV12 format, with colors mapped
52 // exactly like CreateSharedImageRGBAFrame above.
53 // This will return nullptr if the necessary extension is not available for NV12
55 scoped_refptr<VideoFrame> CreateSharedImageNV12Frame(
56 scoped_refptr<viz::ContextProvider> context_provider,
57 const gfx::Size& coded_size,
58 const gfx::Rect& visible_rect,
59 base::OnceClosure destroyed_callback);
63 #endif // MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_