#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/video/fake_gpu_memory_buffer.h"
#include "base/atomic_sequence_num.h"
#include "build/build_config.h"
#include "media/base/format_utils.h"
#include "media/base/video_frame.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
#if BUILDFLAG(IS_FUCHSIA)
#include <lib/zx/eventpair.h>
#include <lib/zx/object.h>
#endif
namespace media {
namespace {
class FakeGpuMemoryBufferImpl : public gpu::GpuMemoryBufferImpl { … };
}
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::ScopedFD GetDummyFD() { … }
#endif
FakeGpuMemoryBuffer::FakeGpuMemoryBuffer(const gfx::Size& size,
gfx::BufferFormat format)
: … { … }
FakeGpuMemoryBuffer::FakeGpuMemoryBuffer(const gfx::Size& size,
gfx::BufferFormat format,
uint64_t modifier)
: … { … }
FakeGpuMemoryBuffer::~FakeGpuMemoryBuffer() = default;
bool FakeGpuMemoryBuffer::Map() { … }
void* FakeGpuMemoryBuffer::memory(size_t plane) { … }
void FakeGpuMemoryBuffer::Unmap() { … }
gfx::Size FakeGpuMemoryBuffer::GetSize() const { … }
gfx::BufferFormat FakeGpuMemoryBuffer::GetFormat() const { … }
int FakeGpuMemoryBuffer::stride(size_t plane) const { … }
gfx::GpuMemoryBufferId FakeGpuMemoryBuffer::GetId() const { … }
gfx::GpuMemoryBufferType FakeGpuMemoryBuffer::GetType() const { … }
gfx::GpuMemoryBufferHandle FakeGpuMemoryBuffer::CloneHandle() const { … }
void FakeGpuMemoryBuffer::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd,
const base::trace_event::MemoryAllocatorDumpGuid& buffer_dump_guid,
uint64_t tracing_process_id,
int importance) const { … }
std::unique_ptr<gpu::GpuMemoryBufferImpl>
FakeGpuMemoryBufferSupport::CreateGpuMemoryBufferImplFromHandle(
gfx::GpuMemoryBufferHandle handle,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::GpuMemoryBufferImpl::DestructionCallback callback,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
scoped_refptr<base::UnsafeSharedMemoryPool> pool,
base::span<uint8_t> premapped_memory) { … }
}