From f2469415d22a805e3c3a9520ca4d04c6d6a1587f Mon Sep 17 00:00:00 2001 From: ivan100sic Date: Wed, 11 Nov 2020 17:57:24 +0100 Subject: [PATCH 1/3] Separate a big function call to several functions --- .../fancyzones/lib/ZoneWindowDrawing.cpp | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp b/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp index b90186bd9b..9b8384ab3b 100644 --- a/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp +++ b/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp @@ -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; @@ -78,19 +79,25 @@ ZoneWindowDrawing::ZoneWindowDrawing(HWND window) // 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)), + 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) { From 0013282012f039667702bf9e8e77ae6aa02d91ab Mon Sep 17 00:00:00 2001 From: ivan100sic Date: Thu, 12 Nov 2020 12:41:11 +0100 Subject: [PATCH 2/3] Formatting --- src/modules/fancyzones/lib/ZoneWindowDrawing.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp b/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp index 9b8384ab3b..ada8de141a 100644 --- a/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp +++ b/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp @@ -88,10 +88,7 @@ ZoneWindowDrawing::ZoneWindowDrawing(HWND window) 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); + hr = GetD2DFactory()->CreateHwndRenderTarget(renderTargetProperties, hwndRenderTargetProperties, &m_renderTarget); if (!SUCCEEDED(hr)) { From 81e0836e11389bdfc83a9635dc665916d6bfc109 Mon Sep 17 00:00:00 2001 From: ivan100sic Date: Mon, 16 Nov 2020 12:28:45 +0100 Subject: [PATCH 3/3] Add a TODO comment --- src/modules/fancyzones/lib/ZoneWindowDrawing.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp b/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp index ada8de141a..30a8caa118 100644 --- a/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp +++ b/src/modules/fancyzones/lib/ZoneWindowDrawing.cpp @@ -74,6 +74,7 @@ ZoneWindowDrawing::ZoneWindowDrawing(HWND window) // Obtain the size of the drawing area. if (!GetClientRect(window, &m_clientRect)) { + // TODO: Log failures and errors using spdlog return; }