From 825efda32fae57516a11ec1626940f79cf5e698d Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Fri, 7 Jan 2022 18:55:58 +0100 Subject: [PATCH] Remove wasteful virtuals according to SizeBench (#11889) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removes some pure virtual base classes from conhost, found with the help of SizeBench. This reduces binary size by 5kB. The reduction in code size however is the main benefit of this. Additionally this fixes a mysterious, undebuggable crash in ~RenderThread(), caused by a Control Flow Guard failure when the class was destroyed over its IRenderThread interface. ## PR Checklist * [x] I work here * [x] Tests added/passed ## Validation Steps Performed * Printing text works ✅ * Printing VT works ✅ * Performance is alright ✅ --- .github/actions/spelling/expect/expect.txt | 2 +- src/host/PtySignalInputThread.hpp | 5 ++ src/host/VtIo.hpp | 13 ++-- src/host/inputBuffer.cpp | 2 +- src/host/inputBuffer.hpp | 13 ++-- src/host/readData.hpp | 1 + src/host/screenInfo.cpp | 4 +- src/host/screenInfo.hpp | 4 +- src/inc/ITerminalOutputConnection.hpp | 32 -------- src/inc/ITerminalOwner.hpp | 33 -------- src/interactivity/onecore/ConIoSrvComm.cpp | 2 +- src/renderer/base/FontInfoBase.cpp | 3 - src/renderer/base/lib/base.vcxproj | 1 - src/renderer/base/lib/base.vcxproj.filters | 3 - src/renderer/base/renderer.cpp | 5 +- src/renderer/base/renderer.hpp | 30 ++++---- src/renderer/base/thread.cpp | 7 +- src/renderer/base/thread.hpp | 21 +++--- src/renderer/inc/IRenderEngine.hpp | 2 +- src/renderer/inc/IRenderThread.hpp | 37 --------- src/renderer/inc/IRenderer.hpp | 75 ------------------- src/renderer/vt/VtSequences.cpp | 2 + src/renderer/vt/XtermEngine.cpp | 2 +- src/renderer/vt/state.cpp | 6 +- src/renderer/vt/vtrenderer.hpp | 13 ++-- .../parser/OutputStateMachineEngine.cpp | 11 +-- .../parser/OutputStateMachineEngine.hpp | 10 ++- 27 files changed, 84 insertions(+), 255 deletions(-) delete mode 100644 src/inc/ITerminalOutputConnection.hpp delete mode 100644 src/inc/ITerminalOwner.hpp delete mode 100644 src/renderer/inc/IRenderThread.hpp delete mode 100644 src/renderer/inc/IRenderer.hpp diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index ee8d15ee8fd..ded141d0021 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -1162,7 +1162,6 @@ IRaw IRead IReference IRender -IRenderer IScheme ISelection IShell @@ -1590,6 +1589,7 @@ NOTSUPPORTED nouicompat nounihan NOUPDATE +novtable NOWAIT NOYIELD NOZORDER diff --git a/src/host/PtySignalInputThread.hpp b/src/host/PtySignalInputThread.hpp index e6c4d8bb4b9..74ffa8e022b 100644 --- a/src/host/PtySignalInputThread.hpp +++ b/src/host/PtySignalInputThread.hpp @@ -15,6 +15,11 @@ Author(s): --*/ #pragma once +namespace Microsoft::Console::VirtualTerminal +{ + class ConGetSet; +} + namespace Microsoft::Console { class PtySignalInputThread final diff --git a/src/host/VtIo.hpp b/src/host/VtIo.hpp index 77cc0fff3a1..d3d3410ec1b 100644 --- a/src/host/VtIo.hpp +++ b/src/host/VtIo.hpp @@ -4,20 +4,23 @@ #pragma once #include "../inc/VtIoModes.hpp" -#include "../inc/ITerminalOwner.hpp" #include "../renderer/vt/vtrenderer.hpp" #include "VtInputThread.hpp" #include "PtySignalInputThread.hpp" class ConsoleArguments; +namespace Microsoft::Console::Render +{ + class VtEngine; +} + namespace Microsoft::Console::VirtualTerminal { - class VtIo : public Microsoft::Console::ITerminalOwner + class VtIo { public: VtIo(); - virtual ~VtIo() override = default; [[nodiscard]] HRESULT Initialize(const ConsoleArguments* const pArgs); @@ -33,8 +36,8 @@ namespace Microsoft::Console::VirtualTerminal [[nodiscard]] HRESULT SuppressResizeRepaint(); [[nodiscard]] HRESULT SetCursorPosition(const COORD coordCursor); - void CloseInput() override; - void CloseOutput() override; + void CloseInput(); + void CloseOutput(); void BeginResize(); void EndResize(); diff --git a/src/host/inputBuffer.cpp b/src/host/inputBuffer.cpp index 0c855a894af..8283ef213e1 100644 --- a/src/host/inputBuffer.cpp +++ b/src/host/inputBuffer.cpp @@ -220,7 +220,7 @@ void InputBuffer::FlushAllButKeys() _storage.erase(newEnd, _storage.end()); } -void InputBuffer::SetTerminalConnection(_In_ ITerminalOutputConnection* const pTtyConnection) +void InputBuffer::SetTerminalConnection(_In_ Render::VtEngine* const pTtyConnection) { this->_pTtyConnection = pTtyConnection; } diff --git a/src/host/inputBuffer.hpp b/src/host/inputBuffer.hpp index fabdadee173..5c003faf03c 100644 --- a/src/host/inputBuffer.hpp +++ b/src/host/inputBuffer.hpp @@ -18,7 +18,6 @@ Revision History: #pragma once -#include "inputReadHandleData.h" #include "readData.hpp" #include "../types/inc/IInputEvent.hpp" @@ -26,10 +25,14 @@ Revision History: #include "../server/ObjectHeader.h" #include "../terminal/input/terminalInput.hpp" -#include "../inc/ITerminalOutputConnection.hpp" - #include +namespace Microsoft::Console::Render +{ + class Renderer; + class VtEngine; +} + class InputBuffer final : public ConsoleObjectHeader { public: @@ -77,7 +80,7 @@ class InputBuffer final : public ConsoleObjectHeader bool IsInVirtualTerminalInputMode() const; Microsoft::Console::VirtualTerminal::TerminalInput& GetTerminalInput(); - void SetTerminalConnection(_In_ Microsoft::Console::ITerminalOutputConnection* const pTtyConnection); + void SetTerminalConnection(_In_ Microsoft::Console::Render::VtEngine* const pTtyConnection); void PassThroughWin32MouseRequest(bool enable); private: @@ -85,7 +88,7 @@ class InputBuffer final : public ConsoleObjectHeader std::unique_ptr _readPartialByteSequence; std::unique_ptr _writePartialByteSequence; Microsoft::Console::VirtualTerminal::TerminalInput _termInput; - Microsoft::Console::ITerminalOutputConnection* _pTtyConnection; + Microsoft::Console::Render::VtEngine* _pTtyConnection; // This flag is used in _HandleTerminalInputCallback // If the InputBuffer leads to a _HandleTerminalInputCallback call, diff --git a/src/host/readData.hpp b/src/host/readData.hpp index 162116c4457..0d46d59d932 100644 --- a/src/host/readData.hpp +++ b/src/host/readData.hpp @@ -20,6 +20,7 @@ Revision History: #pragma once +#include "inputReadHandleData.h" #include "../server/IWaitRoutine.h" #include "../server/WaitTerminationReason.h" diff --git a/src/host/screenInfo.cpp b/src/host/screenInfo.cpp index bd16f3f25b3..ee72405103c 100644 --- a/src/host/screenInfo.cpp +++ b/src/host/screenInfo.cpp @@ -105,7 +105,7 @@ SCREEN_INFORMATION::~SCREEN_INFORMATION() IWindowMetrics* pMetrics = ServiceLocator::LocateWindowMetrics(); THROW_HR_IF_NULL(E_FAIL, pMetrics); - IAccessibilityNotifier* pNotifier = ServiceLocator::LocateAccessibilityNotifier(); + const auto pNotifier = ServiceLocator::LocateAccessibilityNotifier(); // It is possible for pNotifier to be null and that's OK. // For instance, the PTY doesn't need to send events. Just pass it along // and be sure that `SCREEN_INFORMATION` bypasses all event work if it's not there. @@ -2312,7 +2312,7 @@ void SCREEN_INFORMATION::SetViewport(const Viewport& newViewport, // sequence we didn't understand to. // Return Value: // - -void SCREEN_INFORMATION::SetTerminalConnection(_In_ ITerminalOutputConnection* const pTtyConnection) +void SCREEN_INFORMATION::SetTerminalConnection(_In_ VtEngine* const pTtyConnection) { OutputStateMachineEngine& engine = reinterpret_cast(_stateMachine->Engine()); if (pTtyConnection) diff --git a/src/host/screenInfo.hpp b/src/host/screenInfo.hpp index 740dbb53fcd..97251bf58a7 100644 --- a/src/host/screenInfo.hpp +++ b/src/host/screenInfo.hpp @@ -42,8 +42,6 @@ Revision History: #include "../interactivity/inc/IConsoleWindow.hpp" #include "../interactivity/inc/IWindowMetrics.hpp" -#include "../inc/ITerminalOutputConnection.hpp" - #include "../renderer/inc/FontInfo.hpp" #include "../renderer/inc/FontInfoDesired.hpp" @@ -222,7 +220,7 @@ class SCREEN_INFORMATION : public ConsoleObjectHeader, public Microsoft::Console [[nodiscard]] HRESULT VtEraseAll(); [[nodiscard]] HRESULT ClearBuffer(); - void SetTerminalConnection(_In_ Microsoft::Console::ITerminalOutputConnection* const pTtyConnection); + void SetTerminalConnection(_In_ Microsoft::Console::Render::VtEngine* const pTtyConnection); void UpdateBottom(); void MoveToBottom(); diff --git a/src/inc/ITerminalOutputConnection.hpp b/src/inc/ITerminalOutputConnection.hpp deleted file mode 100644 index 729691be256..00000000000 --- a/src/inc/ITerminalOutputConnection.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -/* -Module Name: -- ITerminalOutputConnection.hpp - -Abstract: -- Provides an abstraction for writing to the output pipe connected to the TTY. - In conpty mode, this is implemented by the VtRenderer, such that other - parts of the codebase (the state machine) can write VT sequences directly - to the terminal controlling us. -*/ - -#pragma once - -namespace Microsoft::Console -{ - class ITerminalOutputConnection - { - public: -#pragma warning(push) -#pragma warning(disable : 26432) // suppress rule of 5 violation on interface because tampering with this is fraught with peril - virtual ~ITerminalOutputConnection() = 0; - - [[nodiscard]] virtual HRESULT WriteTerminalUtf8(const std::string_view str) = 0; - [[nodiscard]] virtual HRESULT WriteTerminalW(const std::wstring_view wstr) = 0; - }; - - inline Microsoft::Console::ITerminalOutputConnection::~ITerminalOutputConnection() {} -#pragma warning(pop) -} diff --git a/src/inc/ITerminalOwner.hpp b/src/inc/ITerminalOwner.hpp deleted file mode 100644 index b2ba1e5747a..00000000000 --- a/src/inc/ITerminalOwner.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation. -Licensed under the MIT license. - -Module Name: -- ITerminalOwner.hpp - -Abstract: -- Provides an abstraction for Closing the Input/Output objects of a terminal - connection. This is implemented by VtIo in the host, and is used by the - renderer to be able to tell the VtIo object that the renderer has had it's - pipe broken. - -Author(s): -- Mike Griese (migrie) 28 March 2018 ---*/ - -#pragma once - -namespace Microsoft::Console -{ - class ITerminalOwner - { - public: - virtual ~ITerminalOwner() = 0; - - virtual void CloseInput() = 0; - virtual void CloseOutput() = 0; - }; - - // See docs/virtual-dtors.md for an explanation of why this is weird. - inline Microsoft::Console::ITerminalOwner::~ITerminalOwner() {} -} diff --git a/src/interactivity/onecore/ConIoSrvComm.cpp b/src/interactivity/onecore/ConIoSrvComm.cpp index 8e3eb96b5d4..cdeebed38c3 100644 --- a/src/interactivity/onecore/ConIoSrvComm.cpp +++ b/src/interactivity/onecore/ConIoSrvComm.cpp @@ -322,7 +322,7 @@ VOID ConIoSrvComm::ServiceInputPipe() VOID ConIoSrvComm::HandleFocusEvent(PCIS_EVENT Event) { BOOL Ret; - IRenderer* Renderer; + Renderer* Renderer; CIS_EVENT ReplyEvent; Renderer = ServiceLocator::LocateGlobals().pRender; diff --git a/src/renderer/base/FontInfoBase.cpp b/src/renderer/base/FontInfoBase.cpp index c95abf08dea..f9d47b822f0 100644 --- a/src/renderer/base/FontInfoBase.cpp +++ b/src/renderer/base/FontInfoBase.cpp @@ -2,9 +2,6 @@ // Licensed under the MIT license. #include "precomp.h" - -#include - #include "../inc/FontInfoBase.hpp" FontInfoBase::FontInfoBase(const std::wstring_view& faceName, diff --git a/src/renderer/base/lib/base.vcxproj b/src/renderer/base/lib/base.vcxproj index 92e78661920..9014520b75b 100644 --- a/src/renderer/base/lib/base.vcxproj +++ b/src/renderer/base/lib/base.vcxproj @@ -32,7 +32,6 @@ - diff --git a/src/renderer/base/lib/base.vcxproj.filters b/src/renderer/base/lib/base.vcxproj.filters index 71770c97626..562b0452c39 100644 --- a/src/renderer/base/lib/base.vcxproj.filters +++ b/src/renderer/base/lib/base.vcxproj.filters @@ -77,9 +77,6 @@ Header Files\inc - - Header Files\inc - Header Files diff --git a/src/renderer/base/renderer.cpp b/src/renderer/base/renderer.cpp index c046d1fd942..26ba9c3aa10 100644 --- a/src/renderer/base/renderer.cpp +++ b/src/renderer/base/renderer.cpp @@ -2,7 +2,6 @@ // Licensed under the MIT license. #include "precomp.h" - #include "renderer.hpp" #pragma hdrstop @@ -32,7 +31,7 @@ static constexpr auto renderBackoffBaseTimeMilliseconds{ 150 }; Renderer::Renderer(IRenderData* pData, _In_reads_(cEngines) IRenderEngine** const rgpEngines, const size_t cEngines, - std::unique_ptr thread) : + std::unique_ptr thread) : _pData(THROW_HR_IF_NULL(E_INVALIDARG, pData)), _pThread{ std::move(thread) }, _viewport{ pData->GetViewport() } @@ -51,7 +50,7 @@ Renderer::Renderer(IRenderData* pData, // - Renderer::~Renderer() { - // IRenderThread blocks until it has shut down. + // RenderThread blocks until it has shut down. _destructing = true; _pThread.reset(); } diff --git a/src/renderer/base/renderer.hpp b/src/renderer/base/renderer.hpp index fb11023b51e..74f99f41be8 100644 --- a/src/renderer/base/renderer.hpp +++ b/src/renderer/base/renderer.hpp @@ -16,9 +16,7 @@ Author(s): #pragma once -#include "../inc/IRenderer.hpp" -#include "../inc/IRenderEngine.hpp" -#include "../inc/IRenderData.hpp" +#include "../inc/IRenderTarget.hpp" #include "thread.hpp" @@ -27,19 +25,19 @@ Author(s): namespace Microsoft::Console::Render { - class Renderer sealed : public IRenderer + class Renderer : public IRenderTarget { public: Renderer(IRenderData* pData, _In_reads_(cEngines) IRenderEngine** const pEngine, const size_t cEngines, - std::unique_ptr thread); + std::unique_ptr thread); - virtual ~Renderer() override; + virtual ~Renderer(); [[nodiscard]] HRESULT PaintFrame(); - void TriggerSystemRedraw(const RECT* const prcDirtyClient) override; + void TriggerSystemRedraw(const RECT* const prcDirtyClient); void TriggerRedraw(const Microsoft::Console::Types::Viewport& region) override; void TriggerRedraw(const COORD* const pcoord) override; void TriggerRedrawCursor(const COORD* const pcoord) override; @@ -55,23 +53,23 @@ namespace Microsoft::Console::Render void TriggerFontChange(const int iDpi, const FontInfoDesired& FontInfoDesired, - _Out_ FontInfo& FontInfo) override; + _Out_ FontInfo& FontInfo); void UpdateSoftFont(const gsl::span bitPattern, const SIZE cellSize, - const size_t centeringHint) override; + const size_t centeringHint); [[nodiscard]] HRESULT GetProposedFont(const int iDpi, const FontInfoDesired& FontInfoDesired, - _Out_ FontInfo& FontInfo) override; + _Out_ FontInfo& FontInfo); - bool IsGlyphWideByFont(const std::wstring_view glyph) override; + bool IsGlyphWideByFont(const std::wstring_view glyph); - void EnablePainting() override; - void WaitForPaintCompletionAndDisable(const DWORD dwTimeoutMs) override; - void WaitUntilCanRender() override; + void EnablePainting(); + void WaitForPaintCompletionAndDisable(const DWORD dwTimeoutMs); + void WaitUntilCanRender(); - void AddRenderEngine(_In_ IRenderEngine* const pEngine) override; + void AddRenderEngine(_In_ IRenderEngine* const pEngine); void SetRendererEnteredErrorStateCallback(std::function pfn); void ResetErrorStateAndResume(); @@ -103,7 +101,7 @@ namespace Microsoft::Console::Render std::array _engines{}; IRenderData* _pData = nullptr; // Non-ownership pointer - std::unique_ptr _pThread; + std::unique_ptr _pThread; static constexpr size_t _firstSoftFontChar = 0xEF20; size_t _lastSoftFontChar = 0; std::optional::interval> _hoveredInterval; diff --git a/src/renderer/base/thread.cpp b/src/renderer/base/thread.cpp index 1aa45e7b506..1abb908d360 100644 --- a/src/renderer/base/thread.cpp +++ b/src/renderer/base/thread.cpp @@ -2,9 +2,10 @@ // Licensed under the MIT license. #include "precomp.h" - #include "thread.hpp" +#include "renderer.hpp" + #pragma hdrstop using namespace Microsoft::Console::Render; @@ -56,12 +57,12 @@ RenderThread::~RenderThread() // - Create all of the Events we'll need, and the actual thread we'll be doing // work on. // Arguments: -// - pRendererParent: the IRenderer that owns this thread, and which we should +// - pRendererParent: the Renderer that owns this thread, and which we should // trigger frames for. // Return Value: // - S_OK if we succeeded, else an HRESULT corresponding to a failure to create // an Event or Thread. -[[nodiscard]] HRESULT RenderThread::Initialize(IRenderer* const pRendererParent) noexcept +[[nodiscard]] HRESULT RenderThread::Initialize(Renderer* const pRendererParent) noexcept { _pRenderer = pRendererParent; diff --git a/src/renderer/base/thread.hpp b/src/renderer/base/thread.hpp index 62ffb42ce9f..8542b9ac90c 100644 --- a/src/renderer/base/thread.hpp +++ b/src/renderer/base/thread.hpp @@ -14,24 +14,23 @@ Author(s): #pragma once -#include "../inc/IRenderer.hpp" -#include "../inc/IRenderThread.hpp" - namespace Microsoft::Console::Render { - class RenderThread final : public IRenderThread + class Renderer; + + class RenderThread { public: RenderThread(); - virtual ~RenderThread() override; + ~RenderThread(); - [[nodiscard]] HRESULT Initialize(_In_ IRenderer* const pRendererParent) noexcept; + [[nodiscard]] HRESULT Initialize(Renderer* const pRendererParent) noexcept; - void NotifyPaint() override; + void NotifyPaint(); - void EnablePainting() override; - void DisablePainting() override; - void WaitForPaintCompletionAndDisable(const DWORD dwTimeoutMs) override; + void EnablePainting(); + void DisablePainting(); + void WaitForPaintCompletionAndDisable(const DWORD dwTimeoutMs); private: static DWORD WINAPI s_ThreadProc(_In_ LPVOID lpParameter); @@ -43,7 +42,7 @@ namespace Microsoft::Console::Render HANDLE _hPaintEnabledEvent; HANDLE _hPaintCompletedEvent; - IRenderer* _pRenderer; // Non-ownership pointer + Renderer* _pRenderer; // Non-ownership pointer bool _fKeepRunning; std::atomic _fNextFrameRequested; diff --git a/src/renderer/inc/IRenderEngine.hpp b/src/renderer/inc/IRenderEngine.hpp index 3397cfa6e75..ecf9daecfd3 100644 --- a/src/renderer/inc/IRenderEngine.hpp +++ b/src/renderer/inc/IRenderEngine.hpp @@ -31,7 +31,7 @@ namespace Microsoft::Console::Render std::optional cursorInfo; }; - class IRenderEngine + class __declspec(novtable) IRenderEngine { public: enum class GridLines diff --git a/src/renderer/inc/IRenderThread.hpp b/src/renderer/inc/IRenderThread.hpp deleted file mode 100644 index b9ddba16bdf..00000000000 --- a/src/renderer/inc/IRenderThread.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation -Licensed under the MIT license. - -Module Name: -- IRenderThread.hpp - -Abstract: -- an abstraction for all the actions a render thread needs to perform. - -Author(s): -- Mike Griese (migrie) 16 Jan 2019 ---*/ - -#pragma once -namespace Microsoft::Console::Render -{ - class IRenderThread - { - public: - virtual ~IRenderThread() = 0; - IRenderThread(const IRenderThread&) = default; - IRenderThread(IRenderThread&&) = default; - IRenderThread& operator=(const IRenderThread&) = default; - IRenderThread& operator=(IRenderThread&&) = default; - - virtual void NotifyPaint() = 0; - virtual void EnablePainting() = 0; - virtual void DisablePainting() = 0; - virtual void WaitForPaintCompletionAndDisable(const DWORD dwTimeoutMs) = 0; - - protected: - IRenderThread() = default; - }; - - inline Microsoft::Console::Render::IRenderThread::~IRenderThread(){}; -} diff --git a/src/renderer/inc/IRenderer.hpp b/src/renderer/inc/IRenderer.hpp deleted file mode 100644 index a3894bdb74c..00000000000 --- a/src/renderer/inc/IRenderer.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation -Licensed under the MIT license. - -Module Name: -- IRenderer.hpp - -Abstract: -- This serves as the entry point for console rendering activities. - -Author(s): -- Michael Niksa (MiNiksa) 17-Nov-2015 ---*/ - -#pragma once - -#include "FontInfoDesired.hpp" -#include "IRenderEngine.hpp" -#include "IRenderTarget.hpp" -#include "../types/inc/viewport.hpp" - -namespace Microsoft::Console::Render -{ - class IRenderer : public IRenderTarget - { - public: - ~IRenderer() = 0; - IRenderer(const IRenderer&) = default; - IRenderer(IRenderer&&) = default; - IRenderer& operator=(const IRenderer&) = default; - IRenderer& operator=(IRenderer&&) = default; - - [[nodiscard]] virtual HRESULT PaintFrame() = 0; - - virtual void TriggerSystemRedraw(const RECT* const prcDirtyClient) = 0; - - virtual void TriggerRedraw(const Microsoft::Console::Types::Viewport& region) = 0; - virtual void TriggerRedraw(const COORD* const pcoord) = 0; - virtual void TriggerRedrawCursor(const COORD* const pcoord) = 0; - - virtual void TriggerRedrawAll() = 0; - virtual void TriggerTeardown() noexcept = 0; - - virtual void TriggerSelection() = 0; - virtual void TriggerScroll() = 0; - virtual void TriggerScroll(const COORD* const pcoordDelta) = 0; - virtual void TriggerCircling() = 0; - virtual void TriggerTitleChange() = 0; - virtual void TriggerFontChange(const int iDpi, - const FontInfoDesired& FontInfoDesired, - _Out_ FontInfo& FontInfo) = 0; - - virtual void UpdateSoftFont(const gsl::span bitPattern, - const SIZE cellSize, - const size_t centeringHint) = 0; - - [[nodiscard]] virtual HRESULT GetProposedFont(const int iDpi, - const FontInfoDesired& FontInfoDesired, - _Out_ FontInfo& FontInfo) = 0; - - virtual bool IsGlyphWideByFont(const std::wstring_view glyph) = 0; - - virtual void EnablePainting() = 0; - virtual void WaitForPaintCompletionAndDisable(const DWORD dwTimeoutMs) = 0; - virtual void WaitUntilCanRender() = 0; - - virtual void AddRenderEngine(_In_ IRenderEngine* const pEngine) = 0; - - protected: - IRenderer() = default; - }; - - inline Microsoft::Console::Render::IRenderer::~IRenderer() {} - -} diff --git a/src/renderer/vt/VtSequences.cpp b/src/renderer/vt/VtSequences.cpp index c11e8cc4dcc..d819e7cc65c 100644 --- a/src/renderer/vt/VtSequences.cpp +++ b/src/renderer/vt/VtSequences.cpp @@ -3,6 +3,8 @@ #include "precomp.h" #include "vtrenderer.hpp" + +#include "../renderer/base/renderer.hpp" #include "../../inc/conattrs.hpp" #pragma hdrstop diff --git a/src/renderer/vt/XtermEngine.cpp b/src/renderer/vt/XtermEngine.cpp index 1c09225facd..9d5a74665cd 100644 --- a/src/renderer/vt/XtermEngine.cpp +++ b/src/renderer/vt/XtermEngine.cpp @@ -512,7 +512,7 @@ CATCH_RETURN(); } // Method Description: -// - Wrapper for ITerminalOutputConnection. Write either an ascii-only, or a +// - Wrapper for _Write. Write either an ascii-only, or a // proper utf-8 string, depending on our mode. // Arguments: // - wstr - wstring of text to be written diff --git a/src/renderer/vt/state.cpp b/src/renderer/vt/state.cpp index 93ad4ade64a..2d60910ab24 100644 --- a/src/renderer/vt/state.cpp +++ b/src/renderer/vt/state.cpp @@ -4,7 +4,7 @@ #include "precomp.h" #include "vtrenderer.hpp" #include "../../inc/conattrs.hpp" -#include "../../types/inc/convert.hpp" +#include "../../host/VtIo.hpp" // For _vcprintf #include @@ -133,7 +133,7 @@ VtEngine::VtEngine(_In_ wil::unique_hfile pipe, } // Method Description: -// - Wrapper for ITerminalOutputConnection. See _Write. +// - Wrapper for _Write. [[nodiscard]] HRESULT VtEngine::WriteTerminalUtf8(const std::string_view str) noexcept { return _Write(str); @@ -359,7 +359,7 @@ bool VtEngine::_AllIsInvalid() const return S_OK; } -void VtEngine::SetTerminalOwner(Microsoft::Console::ITerminalOwner* const terminalOwner) +void VtEngine::SetTerminalOwner(Microsoft::Console::VirtualTerminal::VtIo* const terminalOwner) { _terminalOwner = terminalOwner; } diff --git a/src/renderer/vt/vtrenderer.hpp b/src/renderer/vt/vtrenderer.hpp index 9a39f559998..96da01ca2f7 100644 --- a/src/renderer/vt/vtrenderer.hpp +++ b/src/renderer/vt/vtrenderer.hpp @@ -16,8 +16,6 @@ Author(s): #pragma once #include "../inc/RenderEngineBase.hpp" -#include "../../inc/ITerminalOutputConnection.hpp" -#include "../../inc/ITerminalOwner.hpp" #include "../../types/inc/Viewport.hpp" #include "tracing.hpp" #include @@ -31,9 +29,14 @@ namespace TerminalCoreUnitTests }; #endif +namespace Microsoft::Console::VirtualTerminal +{ + class VtIo; +} + namespace Microsoft::Console::Render { - class VtEngine : public RenderEngineBase, public Microsoft::Console::ITerminalOutputConnection + class VtEngine : public RenderEngineBase { public: // See _PaintUtf8BufferLine for explanation of this value. @@ -73,7 +76,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT InheritCursor(const COORD coordCursor) noexcept; [[nodiscard]] HRESULT WriteTerminalUtf8(const std::string_view str) noexcept; [[nodiscard]] virtual HRESULT WriteTerminalW(const std::wstring_view str) noexcept = 0; - void SetTerminalOwner(Microsoft::Console::ITerminalOwner* const terminalOwner); + void SetTerminalOwner(Microsoft::Console::VirtualTerminal::VtIo* const terminalOwner); void BeginResizeRequest(); void EndResizeRequest(); void SetResizeQuirk(const bool resizeQuirk); @@ -113,7 +116,7 @@ namespace Microsoft::Console::Render bool _pipeBroken; HRESULT _exitResult; - Microsoft::Console::ITerminalOwner* _terminalOwner; + Microsoft::Console::VirtualTerminal::VtIo* _terminalOwner; Microsoft::Console::VirtualTerminal::RenderTracing _trace; bool _inResizeRequest{ false }; diff --git a/src/terminal/parser/OutputStateMachineEngine.cpp b/src/terminal/parser/OutputStateMachineEngine.cpp index 0c4532ec599..7a87fdef39a 100644 --- a/src/terminal/parser/OutputStateMachineEngine.cpp +++ b/src/terminal/parser/OutputStateMachineEngine.cpp @@ -2,20 +2,17 @@ // Licensed under the MIT license. #include "precomp.h" - -#include "stateMachine.hpp" #include "OutputStateMachineEngine.hpp" -#include "base64.hpp" #include "ascii.hpp" +#include "base64.hpp" +#include "stateMachine.hpp" #include "../../types/inc/utils.hpp" +#include "../renderer/vt/vtrenderer.hpp" using namespace Microsoft::Console; using namespace Microsoft::Console::VirtualTerminal; -// the console uses 0xffffffff as an "invalid color" value -constexpr COLORREF INVALID_COLOR = 0xffffffff; - // takes ownership of pDispatch OutputStateMachineEngine::OutputStateMachineEngine(std::unique_ptr pDispatch) : _dispatch(std::move(pDispatch)), @@ -1085,7 +1082,7 @@ CATCH_LOG_RETURN_FALSE() // currently processing. // Return Value: // - -void OutputStateMachineEngine::SetTerminalConnection(ITerminalOutputConnection* const pTtyConnection, +void OutputStateMachineEngine::SetTerminalConnection(Render::VtEngine* const pTtyConnection, std::function pfnFlushToTerminal) { this->_pTtyConnection = pTtyConnection; diff --git a/src/terminal/parser/OutputStateMachineEngine.hpp b/src/terminal/parser/OutputStateMachineEngine.hpp index 0a9c2e6a96c..6370eedd758 100644 --- a/src/terminal/parser/OutputStateMachineEngine.hpp +++ b/src/terminal/parser/OutputStateMachineEngine.hpp @@ -15,7 +15,11 @@ Module Name: #include "../adapter/termDispatch.hpp" #include "telemetry.hpp" #include "IStateMachineEngine.hpp" -#include "../../inc/ITerminalOutputConnection.hpp" + +namespace Microsoft::Console::Render +{ + class VtEngine; +} namespace Microsoft::Console::VirtualTerminal { @@ -56,7 +60,7 @@ namespace Microsoft::Console::VirtualTerminal bool DispatchControlCharsFromEscape() const noexcept override; bool DispatchIntermediatesFromEscape() const noexcept override; - void SetTerminalConnection(Microsoft::Console::ITerminalOutputConnection* const pTtyConnection, + void SetTerminalConnection(Microsoft::Console::Render::VtEngine* const pTtyConnection, std::function pfnFlushToTerminal); const ITermDispatch& Dispatch() const noexcept; @@ -64,7 +68,7 @@ namespace Microsoft::Console::VirtualTerminal private: std::unique_ptr _dispatch; - Microsoft::Console::ITerminalOutputConnection* _pTtyConnection; + Microsoft::Console::Render::VtEngine* _pTtyConnection; std::function _pfnFlushToTerminal; wchar_t _lastPrintedChar;