#pragma once #include #include #include #include #include #include #include #include #include #include #include "d2d_svg.h" class D2DWindow { public: D2DWindow(); void show(UINT x, UINT y, UINT width, UINT height); void hide(); void initialize(); virtual ~D2DWindow(); protected: // Implement this: // Initialization - called when D2D device needs to be created. // When called all D2DWindow members will be initialized, including d2d_dc virtual void init() = 0; // resize - when called, window_width and window_height will have current window size virtual void resize() = 0; // render - called on WM_PAIT, BeginPaint/EndPaint is handled by D2DWindow virtual void render(ID2D1DeviceContext5* d2d_dc) = 0; // on_show, on_hide - called when the window is about to be shown or about to be hidden virtual void on_show() = 0; virtual void on_hide() = 0; static LRESULT __stdcall d2d_window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam); static D2DWindow* this_from_hwnd(HWND window); void base_init(); void base_resize(UINT width, UINT height); void base_render(); void render_empty(); std::recursive_mutex mutex; bool initialized = false; HWND hwnd; UINT window_width, window_height; winrt::com_ptr d3d_device; winrt::com_ptr dxgi_device; winrt::com_ptr dxgi_factory; winrt::com_ptr dxgi_swap_chain; winrt::com_ptr composition_device; winrt::com_ptr composition_target; winrt::com_ptr composition_visual; winrt::com_ptr dxgi_surface; winrt::com_ptr d2d_bitmap; winrt::com_ptr d2d_factory; winrt::com_ptr d2d_device; winrt::com_ptr d2d_dc; };