shared_image_video_frame_test_utils.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2021 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.
  4. #ifndef MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_
  5. #define MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_
  6. #include <GLES3/gl3.h>
  7. #include <stdint.h>
  8. #include "base/bind.h"
  9. #include "components/viz/common/gpu/context_provider.h"
  10. #include "media/base/video_frame.h"
  11. namespace media {
  12. // Creates a video frame from a set of shared images with a common texture
  13. // target and sync token.
  14. scoped_refptr<VideoFrame> CreateSharedImageFrame(
  15. scoped_refptr<viz::ContextProvider> context_provider,
  16. VideoPixelFormat format,
  17. std::vector<gpu::Mailbox> mailboxes,
  18. const gpu::SyncToken& sync_token,
  19. GLenum texture_target,
  20. const gfx::Size& coded_size,
  21. const gfx::Rect& visible_rect,
  22. const gfx::Size& natural_size,
  23. base::TimeDelta timestamp,
  24. base::OnceClosure destroyed_callback);
  25. // Creates a shared image backed frame in RGBA format, with colors on the shared
  26. // image mapped as follow.
  27. // Bk | R | G | Y
  28. // ---+---+---+---
  29. // Bl | M | C | W
  30. scoped_refptr<VideoFrame> CreateSharedImageRGBAFrame(
  31. scoped_refptr<viz::ContextProvider> context_provider,
  32. const gfx::Size& coded_size,
  33. const gfx::Rect& visible_rect,
  34. base::OnceClosure destroyed_callback);
  35. // Creates a shared image backed frame in I420 format, with colors mapped
  36. // exactly like CreateSharedImageRGBAFrame above, noting that subsamples may get
  37. // interpolated leading to inconsistent colors around the "seams".
  38. scoped_refptr<VideoFrame> CreateSharedImageI420Frame(
  39. scoped_refptr<viz::ContextProvider> context_provider,
  40. const gfx::Size& coded_size,
  41. const gfx::Rect& visible_rect,
  42. base::OnceClosure destroyed_callback);
  43. // Creates a shared image backed frame in NV12 format, with colors mapped
  44. // exactly like CreateSharedImageRGBAFrame above.
  45. // This will return nullptr if the necessary extension is not available for NV12
  46. // support.
  47. scoped_refptr<VideoFrame> CreateSharedImageNV12Frame(
  48. scoped_refptr<viz::ContextProvider> context_provider,
  49. const gfx::Size& coded_size,
  50. const gfx::Rect& visible_rect,
  51. base::OnceClosure destroyed_callback);
  52. } // namespace media
  53. #endif // MEDIA_RENDERERS_SHARED_IMAGE_VIDEO_FRAME_TEST_UTILS_H_