Upload upstream chromium 120.0.6099.5
[platform/framework/web/chromium-efl.git] / media / renderers / shared_image_video_frame_test_utils.h
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.
4
5 #ifndef MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_
6 #define MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_
7
8 #include <GLES3/gl3.h>
9 #include <stdint.h>
10
11 #include "base/functional/bind.h"
12 #include "components/viz/common/gpu/context_provider.h"
13 #include "media/base/video_frame.h"
14
15 namespace media {
16
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);
30
31 // Creates a shared image backed frame in RGBA format, with colors on the shared
32 // image mapped as follow.
33 // Bk | R | G | Y
34 // ---+---+---+---
35 // Bl | M | C | W
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);
41
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);
50
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
54 // support.
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);
60
61 }  // namespace media
62
63 #endif  // MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_