gpu_memory_buffer_utils.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 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_CAPTURE_VIDEO_GPU_MEMORY_BUFFER_UTILS_H_
  5. #define MEDIA_CAPTURE_VIDEO_GPU_MEMORY_BUFFER_UTILS_H_
  6. #include <memory>
  7. #include "media/capture/video/video_capture_device.h"
  8. namespace gfx {
  9. class GpuMemoryBuffer;
  10. } // namespace gfx
  11. namespace gpu {
  12. class GpuMemoryBufferSupport;
  13. } // namespace gpu
  14. // Utility class and function for creating and accessing video capture client
  15. // buffers backed with GpuMemoryBuffer buffers.
  16. namespace media {
  17. class ScopedNV12GpuMemoryBufferMapping {
  18. public:
  19. explicit ScopedNV12GpuMemoryBufferMapping(
  20. std::unique_ptr<gfx::GpuMemoryBuffer> gmb);
  21. ~ScopedNV12GpuMemoryBufferMapping();
  22. uint8_t* y_plane();
  23. uint8_t* uv_plane();
  24. size_t y_stride();
  25. size_t uv_stride();
  26. private:
  27. std::unique_ptr<gfx::GpuMemoryBuffer> gmb_;
  28. };
  29. VideoCaptureDevice::Client::ReserveResult AllocateNV12GpuMemoryBuffer(
  30. VideoCaptureDevice::Client* capture_client,
  31. const gfx::Size& buffer_size,
  32. gpu::GpuMemoryBufferSupport* gmb_support,
  33. std::unique_ptr<gfx::GpuMemoryBuffer>* out_gpu_memory_buffer,
  34. VideoCaptureDevice::Client::Buffer* out_capture_buffer);
  35. } // namespace media
  36. #endif // MEDIA_CAPTURE_VIDEO_GPU_MEMORY_BUFFER_UTILS_H_