2021-12-29 20:33:20 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <mutex>
|
2022-02-03 20:30:05 +03:00
|
|
|
|
2021-12-29 20:33:20 +03:00
|
|
|
#include <d2d1.h>
|
2022-02-03 20:30:05 +03:00
|
|
|
#include <winrt/base.h>
|
2021-12-29 20:33:20 +03:00
|
|
|
#include <dwrite.h>
|
|
|
|
|
|
|
|
|
|
class FrameDrawer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static std::unique_ptr<FrameDrawer> Create(HWND window);
|
|
|
|
|
|
|
|
|
|
FrameDrawer(HWND window);
|
2022-02-03 20:30:05 +03:00
|
|
|
FrameDrawer(FrameDrawer&& other) = default;
|
2021-12-29 20:33:20 +03:00
|
|
|
|
|
|
|
|
bool Init();
|
|
|
|
|
|
|
|
|
|
void Show();
|
|
|
|
|
void Hide();
|
2022-02-10 20:24:29 +03:00
|
|
|
void SetBorderRect(RECT windowRect, COLORREF color, int thickness);
|
2021-12-29 20:33:20 +03:00
|
|
|
|
|
|
|
|
private:
|
2022-02-03 20:30:05 +03:00
|
|
|
bool CreateRenderTargets(const RECT& clientRect);
|
|
|
|
|
|
2021-12-29 20:33:20 +03:00
|
|
|
struct DrawableRect
|
|
|
|
|
{
|
|
|
|
|
D2D1_RECT_F rect;
|
|
|
|
|
D2D1_COLOR_F borderColor;
|
2022-02-10 20:24:29 +03:00
|
|
|
int thickness;
|
2021-12-29 20:33:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static ID2D1Factory* GetD2DFactory();
|
|
|
|
|
static IDWriteFactory* GetWriteFactory();
|
|
|
|
|
static D2D1_COLOR_F ConvertColor(COLORREF color);
|
|
|
|
|
static D2D1_RECT_F ConvertRect(RECT rect);
|
2022-02-03 20:30:05 +03:00
|
|
|
void Render();
|
2021-12-29 20:33:20 +03:00
|
|
|
|
|
|
|
|
HWND m_window = nullptr;
|
2022-02-03 20:30:05 +03:00
|
|
|
size_t m_renderTargetSizeHash = {};
|
|
|
|
|
winrt::com_ptr<ID2D1HwndRenderTarget> m_renderTarget;
|
|
|
|
|
winrt::com_ptr<ID2D1SolidColorBrush> m_borderBrush;
|
|
|
|
|
DrawableRect m_sceneRect = {};
|
2021-12-29 20:33:20 +03:00
|
|
|
};
|