#pragma once

#include <wrl.h>
#include <stdint.h>
#include <vector>

class DirectXInterface;
class DirectX2dInterface;

namespace mt
{
	class Window;
}
struct ID3D12Resource;
struct ID3D11Resource;
struct ID2D1Bitmap1;

class DirectX2dIntegration
{
public:
	DirectX2dIntegration(mt::Window* window, DirectXInterface* dxInterface, UINT frameCount);

	void clearBuffers();

	void render();

	void updateBackbufferIndex(UINT idx);

	void wrapBuffer(ID3D12Resource* referenceBuffer);

private:
	ID3D11Resource* const* getD11on12WrappedBackBuffer() const;
	ID2D1Bitmap1* getD2dRenderTarget() const;

	DirectXInterface* mDxInterface{ nullptr };
	DirectX2dInterface* mDx2dInterface{ nullptr };
	mt::Window* mWindow{ nullptr };

	UINT mFrameCount{ 2 };
	UINT mFrameIndex{ 0 };
	std::vector<Microsoft::WRL::ComPtr<ID3D11Resource> > mWrappedBackBuffers;
	std::vector<Microsoft::WRL::ComPtr<ID2D1Bitmap1> > mD2dRenderTargets;
};