#include "media/video/renderable_gpu_memory_buffer_video_frame_pool.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <list>
#include <utility>
#include "base/bits.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "cc/base/math_util.h"
#include "components/viz/common/resources/shared_image_format_utils.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/client_shared_image.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "media/base/format_utils.h"
#include "media/base/media_switches.h"
#include "media/base/video_frame.h"
namespace media {
namespace {
BASE_FEATURE(…);
class InternalRefCountedPool;
class FrameResources { … };
class InternalRefCountedPool
: public base::RefCountedThreadSafe<InternalRefCountedPool> { … };
class RenderableGpuMemoryBufferVideoFramePoolImpl
: public RenderableGpuMemoryBufferVideoFramePool { … };
FrameResources::FrameResources(scoped_refptr<InternalRefCountedPool> pool,
const VideoPixelFormat format,
const gfx::Size& coded_size,
const gfx::ColorSpace& color_space)
: … { … }
FrameResources::~FrameResources() { … }
gfx::Size GetBufferSizeInPixelsForVideoPixelFormat(
VideoPixelFormat format,
const gfx::Size& coded_size) { … }
bool FrameResources::Initialize() { … }
bool FrameResources::IsCompatibleWith(
const gfx::Size& coded_size,
const gfx::ColorSpace& color_space) const { … }
scoped_refptr<VideoFrame>
FrameResources::CreateVideoFrameAndTakeGpuMemoryBuffer() { … }
void FrameResources::ReturnGpuMemoryBufferFromFrame(
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer,
const gpu::SyncToken& sync_token) { … }
InternalRefCountedPool::InternalRefCountedPool(
std::unique_ptr<RenderableGpuMemoryBufferVideoFramePool::Context> context,
const VideoPixelFormat format)
: … { … }
scoped_refptr<VideoFrame> InternalRefCountedPool::MaybeCreateVideoFrame(
const gfx::Size& coded_size,
const gfx::ColorSpace& color_space) { … }
void InternalRefCountedPool::OnVideoFrameDestroyed(
std::unique_ptr<FrameResources> frame_resources,
const gpu::SyncToken& sync_token,
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer) { … }
void InternalRefCountedPool::Shutdown() { … }
RenderableGpuMemoryBufferVideoFramePool::Context*
InternalRefCountedPool::GetContext() const { … }
InternalRefCountedPool::~InternalRefCountedPool() { … }
RenderableGpuMemoryBufferVideoFramePoolImpl::
RenderableGpuMemoryBufferVideoFramePoolImpl(
std::unique_ptr<RenderableGpuMemoryBufferVideoFramePool::Context>
context,
const VideoPixelFormat format,
const bool is_mappable_si_enabled)
: … { … }
scoped_refptr<VideoFrame>
RenderableGpuMemoryBufferVideoFramePoolImpl::MaybeCreateVideoFrame(
const gfx::Size& coded_size,
const gfx::ColorSpace& color_space) { … }
bool RenderableGpuMemoryBufferVideoFramePoolImpl::
IsMappableSIEnabledForTesting() const { … }
RenderableGpuMemoryBufferVideoFramePoolImpl::
~RenderableGpuMemoryBufferVideoFramePoolImpl() { … }
}
std::unique_ptr<RenderableGpuMemoryBufferVideoFramePool>
RenderableGpuMemoryBufferVideoFramePool::Create(
std::unique_ptr<Context> context,
VideoPixelFormat format) { … }
}