Merge pull request #8006 from ivan100sic/zwnddraw-debug

[FancyZones] Refactor a function in ZoneWindowDrawing
This commit is contained in:
Ivan Stošić 2020-11-16 14:22:40 +01:00 committed by GitHub
commit 48e5cc152f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,6 +66,7 @@ D2D1_RECT_F ZoneWindowDrawing::ConvertRect(RECT rect)
ZoneWindowDrawing::ZoneWindowDrawing(HWND window)
{
HRESULT hr;
m_window = window;
m_renderTarget = nullptr;
m_shouldRender = false;
@ -73,23 +74,27 @@ ZoneWindowDrawing::ZoneWindowDrawing(HWND window)
// Obtain the size of the drawing area.
if (!GetClientRect(window, &m_clientRect))
{
// TODO: Log failures and errors using spdlog
return;
}
// Create a Direct2D render target
// We should always use the DPI value of 96 since we're running in DPI aware mode
GetD2DFactory()->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
96.f,
96.f),
D2D1::HwndRenderTargetProperties(
window,
D2D1::SizeU(
m_clientRect.right - m_clientRect.left,
m_clientRect.bottom - m_clientRect.top)),
&m_renderTarget);
auto renderTargetProperties = D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
96.f,
96.f);
auto renderTargetSize = D2D1::SizeU(m_clientRect.right - m_clientRect.left, m_clientRect.bottom - m_clientRect.top);
auto hwndRenderTargetProperties = D2D1::HwndRenderTargetProperties(window, renderTargetSize);
hr = GetD2DFactory()->CreateHwndRenderTarget(renderTargetProperties, hwndRenderTargetProperties, &m_renderTarget);
if (!SUCCEEDED(hr))
{
return;
}
m_renderThread = std::thread([this]() {
while (!m_abortThread)