#pragma once

#include "AbstractPainter.h"

#include <dwrite.h>
#include <d2d1_3.h>
#include <d2d1_1.h>
#include <d3d12.h>

#include <memory>

class DrawingContext;
class DirectXMeshPainter;
class DirectXTextPainter;
class DirectX2dPainter;
class DirectXInterface;

class DirectXPainter : public AbstractPainter
{
public:
    DirectXPainter(DrawingContext* context);
    
    DirectXMeshPainter* getMeshPainter() const;
    void initializeMesh();

    void paint() override;
    void paintBackground(const D3D12_CPU_DESCRIPTOR_HANDLE& rtvHandle, ID3D12GraphicsCommandList* commandList);
    void paintMesh(ID3D12GraphicsCommandList* commandList);

    void setDxInterface(DirectXInterface* dxInterface);

    bool supportsGeometryPrimitives() const override;

    void updateMesh();

private:
    DirectXInterface* getDxInterface() const;

    void initializeDxInterface();
    void resetPainters();

    std::unique_ptr<DirectXMeshPainter> mMeshPainter;
    std::unique_ptr<DirectXTextPainter> mTextPainter;
    std::unique_ptr<DirectX2dPainter> m2dPainter;

    DirectXInterface* mRawDxInterface{ nullptr };
    std::unique_ptr<DirectXInterface> mDxInterface;
};