diff --git a/src/host/ut_host/ScreenBufferTests.cpp b/src/host/ut_host/ScreenBufferTests.cpp index a81d47ec931..31ec3a747f1 100644 --- a/src/host/ut_host/ScreenBufferTests.cpp +++ b/src/host/ut_host/ScreenBufferTests.cpp @@ -44,7 +44,6 @@ class ScreenBufferTests m_state->InitEvents(); m_state->PrepareGlobalFont({ 1, 1 }); - m_state->PrepareGlobalRenderer(); m_state->PrepareGlobalInputBuffer(); m_state->PrepareGlobalScreenBuffer(); @@ -54,7 +53,6 @@ class ScreenBufferTests TEST_CLASS_CLEANUP(ClassCleanup) { m_state->CleanupGlobalScreenBuffer(); - m_state->CleanupGlobalRenderer(); m_state->CleanupGlobalInputBuffer(); delete m_state; @@ -581,8 +579,6 @@ void ScreenBufferTests::TestResetClearTabStops() // Reset the screen buffer to test the defaults. m_state->CleanupNewTextBufferInfo(); m_state->CleanupGlobalScreenBuffer(); - m_state->CleanupGlobalRenderer(); - m_state->PrepareGlobalRenderer(); m_state->PrepareGlobalScreenBuffer(); m_state->PrepareNewTextBufferInfo(); diff --git a/src/host/ut_host/SearchTests.cpp b/src/host/ut_host/SearchTests.cpp index d37c3556d40..d7ba067e765 100644 --- a/src/host/ut_host/SearchTests.cpp +++ b/src/host/ut_host/SearchTests.cpp @@ -23,20 +23,14 @@ class SearchTests TEST_CLASS_SETUP(ClassSetup) { m_state = new CommonState(); - - m_state->PrepareGlobalRenderer(); m_state->PrepareGlobalScreenBuffer(); - return true; } TEST_CLASS_CLEANUP(ClassCleanup) { m_state->CleanupGlobalScreenBuffer(); - m_state->CleanupGlobalRenderer(); - delete m_state; - return true; } diff --git a/src/inc/test/CommonState.hpp b/src/inc/test/CommonState.hpp index c0f4c0bcf4c..66ddfb5b003 100644 --- a/src/inc/test/CommonState.hpp +++ b/src/inc/test/CommonState.hpp @@ -66,20 +66,6 @@ class CommonState m_pFontInfo = { L"Consolas", 0, 0, coordFontSize, 0 }; } - void PrepareGlobalRenderer() - { - Globals& g = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals(); - CONSOLE_INFORMATION& gci = g.getConsoleInformation(); - g.pRender = new Microsoft::Console::Render::Renderer(gci.GetRenderSettings(), &gci.renderData); - } - - void CleanupGlobalRenderer() - { - Globals& g = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals(); - delete g.pRender; - g.pRender = nullptr; - } - void PrepareGlobalScreenBuffer(const til::CoordType viewWidth = s_csWindowWidth, const til::CoordType viewHeight = s_csWindowHeight, const til::CoordType bufferWidth = s_csBufferWidth, diff --git a/src/renderer/base/renderer.cpp b/src/renderer/base/renderer.cpp index f0775115544..996c160fbda 100644 --- a/src/renderer/base/renderer.cpp +++ b/src/renderer/base/renderer.cpp @@ -178,12 +178,8 @@ CATCH_RETURN() void Renderer::NotifyPaintFrame() noexcept { - // If we're running in the unittests, we might not have a render thread. - if (_pThread) - { - // The thread will provide throttling for us. - _pThread->NotifyPaint(); - } + // The thread will provide throttling for us. + _thread.NotifyPaint(); } // Routine Description: @@ -595,12 +591,7 @@ void Renderer::EnablePainting() // When the renderer is constructed, the initial viewport won't be available yet, // but once EnablePainting is called it should be safe to retrieve. _viewport = _pData->GetViewport(); - - // When running the unit tests, we may be using a render without a render thread. - if (_pThread) - { - _pThread->EnablePainting(); - } + _thread.EnablePainting(); } // Routine Description: @@ -611,7 +602,7 @@ void Renderer::EnablePainting() // - void Renderer::WaitForPaintCompletionAndDisable() { - _pThread->WaitForPaintCompletionAndDisable(); + _thread.WaitForPaintCompletionAndDisable(); } // Routine Description: diff --git a/src/renderer/base/renderer.hpp b/src/renderer/base/renderer.hpp index 9882e77e63a..663e1ac9544 100644 --- a/src/renderer/base/renderer.hpp +++ b/src/renderer/base/renderer.hpp @@ -118,7 +118,7 @@ namespace Microsoft::Console::Render uint16_t _hyperlinkHoveredId = 0; std::optional::interval> _hoveredInterval; Microsoft::Console::Types::Viewport _viewport; - CursorOptions _currentCursorOptions; + CursorOptions _currentCursorOptions{}; std::optional _compositionCache; std::vector _clusterBuffer; std::function _pfnBackgroundColorChanged; @@ -132,6 +132,6 @@ namespace Microsoft::Console::Render // Ordered last, so that it gets destroyed first. // This ensures that the render thread stops accessing us. - std::unique_ptr _pThread = std::make_unique(this); + RenderThread _thread{ this }; }; }