#pragma once

#include <wrl.h>
#include <dwrite.h>
#include <d2d1_3.h>

class DirectXInterface;

struct IDWriteFactory;
struct ID2D1Factory3;
struct ID2D1Device2;
struct ID2D1DeviceContext2;
struct ID2D1RenderTarget;
struct IWICBitmap;
struct IDXGIDevice;

class DirectX2dInterface
{
public:
	DirectX2dInterface(DirectXInterface* dxInterface);

	ID2D1Factory3* getFactory() const;
	ID2D1DeviceContext2* getContext() const;
	IDWriteFactory* getDirectWriteFactory() const;
	ID2D1RenderTarget* getRenderTarget() const;

	bool initialize(IDXGIDevice* device);
	void initialize(IWICBitmap* bitmap, bool useSoftware = true);

	bool isValid() const;

private:
	bool initializeDirectWrite();

	bool mIsValid{ false };

	DirectXInterface* mDxInterface{ nullptr };

	Microsoft::WRL::ComPtr<ID2D1Factory3> mFactory;
	Microsoft::WRL::ComPtr<ID2D1Device2> mDevice;
	Microsoft::WRL::ComPtr<ID2D1DeviceContext2> mDeviceContext;
	Microsoft::WRL::ComPtr<IDWriteFactory> mDWriteFactory;
	Microsoft::WRL::ComPtr<ID2D1RenderTarget> mRenderTarget;
};