Skip to content

Commit

Permalink
Fix tests, Cleanup Renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Feb 28, 2025
1 parent 01b1777 commit dc45cbb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 39 deletions.
4 changes: 0 additions & 4 deletions src/host/ut_host/ScreenBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ScreenBufferTests

m_state->InitEvents();
m_state->PrepareGlobalFont({ 1, 1 });
m_state->PrepareGlobalRenderer();
m_state->PrepareGlobalInputBuffer();
m_state->PrepareGlobalScreenBuffer();

Expand All @@ -54,7 +53,6 @@ class ScreenBufferTests
TEST_CLASS_CLEANUP(ClassCleanup)
{
m_state->CleanupGlobalScreenBuffer();
m_state->CleanupGlobalRenderer();
m_state->CleanupGlobalInputBuffer();

delete m_state;
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 0 additions & 6 deletions src/host/ut_host/SearchTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 0 additions & 14 deletions src/inc/test/CommonState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 4 additions & 13 deletions src/renderer/base/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -611,7 +602,7 @@ void Renderer::EnablePainting()
// - <none>
void Renderer::WaitForPaintCompletionAndDisable()
{
_pThread->WaitForPaintCompletionAndDisable();
_thread.WaitForPaintCompletionAndDisable();
}

// Routine Description:
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/base/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace Microsoft::Console::Render
uint16_t _hyperlinkHoveredId = 0;
std::optional<interval_tree::IntervalTree<til::point, size_t>::interval> _hoveredInterval;
Microsoft::Console::Types::Viewport _viewport;
CursorOptions _currentCursorOptions;
CursorOptions _currentCursorOptions{};
std::optional<CompositionCache> _compositionCache;
std::vector<Cluster> _clusterBuffer;
std::function<void()> _pfnBackgroundColorChanged;
Expand All @@ -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<RenderThread> _pThread = std::make_unique<RenderThread>(this);
RenderThread _thread{ this };
};
}

0 comments on commit dc45cbb

Please sign in to comment.