2 #include "D2ChannelRender.h"
3 #include "helpers/hresult_exception.h"
7 D2ChannelRender::D2ChannelRender()
8 : render_target(
nullptr)
11 , text_format(
nullptr)
13 , scaletext(L
"__ µm x __ µm") {
27 std::lock_guard<std::mutex> lock(
mutex);
37 std::lock_guard<std::mutex> lock(
mutex);
43 std::lock_guard<std::mutex> lock(
mutex);
51 std::lock_guard<std::mutex> lock(
mutex);
53 if ( 0 == (D2D1_WINDOW_STATE_OCCLUDED &
render_target->CheckWindowState()) ) {
66 if ((HRESULT)hr == D2DERR_RECREATE_TARGET) {
67 hr(__FUNCTION__) = S_OK;
74 std::lock_guard<std::mutex> lock(
mutex);
ID2D1SolidColorBrush * text_brush
Direct2D brush for text (do not use a unique_ptr for COM interfaces)
virtual bool Resize(const uint32_t &_xres, const uint32_t &_yres)
Resizes the render target.
~D2ChannelRender()
Discard resources and delete the render_target.
virtual void UpdateScaleText(const std::wstring &_text)
Update the scale text.
Wrappers around the Direct2D interface.
void SafeRelease(Interface **ppInterfaceToRelease)
A safe release for COM objects.
void DiscardDeviceResources()
Safely release all Direct2D resources.
virtual void Render()
Renders the bitmap and the scale text.
This is the include file for standard system include files, or project specific include files that ar...
IDWriteTextFormat * text_format
Direct2D text format (do not use a unique_ptr for COM interfaces)
std::unique_ptr< RenderTarget > render_target
Direct2D render target.
std::mutex mutex
mutex for protection
ID2D1Bitmap * bitmap
Direct2D bitmap (do not use a unique_ptr for COM interfaces)
Wrapper around a Direct2D render target and the underlying Direct2D factory and IDWriteFactory.
bool ResizeBitmap(const uint32_t &_xres, const uint32_t &_yres)
Resizes the bitmap.
virtual void Create(const HWND &_hwnd, const uint32_t &_xres, const uint32_t &_yres)
Creates the render target for a hwnd, a bitmap with the desired resolution, a brushes for painting ...
std::wstring scaletext
String with the scale information, ala L"9.5 µm".