#ifndef CONTENT_RENDERER_MEDIA_WIN_DCOMP_TEXTURE_WRAPPER_IMPL_H_
#define CONTENT_RENDERER_MEDIA_WIN_DCOMP_TEXTURE_WRAPPER_IMPL_H_
#include "base/task/sequenced_task_runner.h"
#include "base/unguessable_token.h"
#include "content/common/content_export.h"
#include "content/renderer/media/win/dcomp_texture_factory.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "media/base/video_frame.h"
#include "media/base/win/dcomp_texture_wrapper.h"
#include "ui/gfx/geometry/rect.h"
namespace content {
class DCOMPTextureMailboxResources;
class CONTENT_EXPORT DCOMPTextureWrapperImpl
: public media::DCOMPTextureWrapper,
public DCOMPTextureHost::Listener {
public:
static std::unique_ptr<media::DCOMPTextureWrapper> Create(
scoped_refptr<DCOMPTextureFactory> factory,
scoped_refptr<base::SequencedTaskRunner> media_task_runner);
~DCOMPTextureWrapperImpl() override;
bool Initialize(const gfx::Size& output_size,
OutputRectChangeCB output_rect_change_cb) override;
void UpdateTextureSize(const gfx::Size& natural_size) override;
void SetDCOMPSurfaceHandle(
const base::UnguessableToken& token,
SetDCOMPSurfaceHandleCB set_dcomp_surface_handle_cb) override;
void CreateVideoFrame(const gfx::Size& natural_size,
CreateVideoFrameCB create_video_frame_cb) override;
void CreateVideoFrame(const gfx::Size& natural_size,
gfx::GpuMemoryBufferHandle dx_handle,
CreateDXVideoFrameCB create_video_frame_cb) override;
private:
DCOMPTextureWrapperImpl(
scoped_refptr<DCOMPTextureFactory> factory,
scoped_refptr<base::SequencedTaskRunner> media_task_runner);
DCOMPTextureWrapperImpl(const DCOMPTextureWrapperImpl&) = delete;
DCOMPTextureWrapperImpl& operator=(const DCOMPTextureWrapperImpl&) = delete;
void OnSharedImageMailboxBound(gpu::Mailbox mailbox) override;
void OnOutputRectChange(gfx::Rect output_rect) override;
void OnDXVideoFrameDestruction(const gpu::SyncToken& sync_token,
const gpu::Mailbox& image_mailbox);
scoped_refptr<DCOMPTextureFactory> factory_;
scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
gfx::Size natural_size_;
gfx::Size output_size_;
OutputRectChangeCB output_rect_change_cb_;
std::unique_ptr<DCOMPTextureHost> dcomp_texture_host_;
bool mailbox_added_ = false;
gpu::Mailbox mailbox_;
CreateVideoFrameCB create_video_frame_cb_;
scoped_refptr<DCOMPTextureMailboxResources> dcomp_texture_resources_;
base::WeakPtrFactory<DCOMPTextureWrapperImpl> weak_factory_{this};
};
}
#endif