Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial refactor of IRenderEngine interface #10615

Closed
12 changes: 6 additions & 6 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (!modifiers.IsWinPressed())
{
_terminal->ClearSelection();
_renderer->TriggerSelection();
_renderer->TriggerIntereaction(::Microsoft::Console::Render::IntereactionType::Selection);
}

if (vkey == VK_ESCAPE)
Expand Down Expand Up @@ -462,7 +462,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_lastHoveredId = newId;
_lastHoveredInterval = newInterval;
_renderEngine->UpdateHyperlinkHoveredId(newId);
_renderer->UpdateLastHoveredInterval(newInterval);
_renderEngine->UpdateLastHoveredInterval(newInterval);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fantastic example of how this PR decouples renderer.cpp & DxEngine.

Only DxEngine actually needs UpdateLastHoveredInterval. UpdateLastHoveredInterval never should be inside renderer.cpp.

_renderer->TriggerRedrawAll();
}

Expand Down Expand Up @@ -808,7 +808,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation

// save location (for rendering) + render
_terminal->SetSelectionEnd(terminalPosition);
_renderer->TriggerSelection();
_renderer->TriggerIntereaction(::Microsoft::Console::Render::IntereactionType::Selection);
}

// Called when the Terminal wants to set something to the clipboard, i.e.
Expand Down Expand Up @@ -868,7 +868,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (!_settings.CopyOnSelect())
{
_terminal->ClearSelection();
_renderer->TriggerSelection();
_renderer->TriggerIntereaction(::Microsoft::Console::Render::IntereactionType::Selection);
}

// send data up for clipboard
Expand Down Expand Up @@ -1120,7 +1120,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
_terminal->SetBlockSelection(false);
search.Select();
_renderer->TriggerSelection();
_renderer->TriggerIntereaction(::Microsoft::Console::Render::IntereactionType::Selection);
}
}

Expand Down Expand Up @@ -1310,7 +1310,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
selectionNeedsToBeCopied = true;
}

_renderer->TriggerSelection();
_renderer->TriggerIntereaction(::Microsoft::Console::Render::IntereactionType::Selection);
}

void ControlCore::AttachUiaEngine(::Microsoft::Console::Render::IRenderEngine* const pEngine)
Expand Down
20 changes: 10 additions & 10 deletions src/host/ScreenBufferRenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ ScreenBufferRenderTarget::ScreenBufferRenderTarget(SCREEN_INFORMATION& owner) :
{
}

void ScreenBufferRenderTarget::TriggerIntereaction(Microsoft::Console::Render::IntereactionType type)
{
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
if (pRenderer != nullptr && pActive == &_owner)
{
pRenderer->TriggerIntereaction(type);
}
}

void ScreenBufferRenderTarget::TriggerRedraw(const Microsoft::Console::Types::Viewport& region)
{
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
Expand Down Expand Up @@ -61,16 +71,6 @@ void ScreenBufferRenderTarget::TriggerTeardown() noexcept
}
}

void ScreenBufferRenderTarget::TriggerSelection()
{
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
if (pRenderer != nullptr && pActive == &_owner)
{
pRenderer->TriggerSelection();
}
}

void ScreenBufferRenderTarget::TriggerScroll()
{
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
Expand Down
3 changes: 2 additions & 1 deletion src/host/ScreenBufferRenderTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Author(s):

#pragma once
#include "../renderer/inc/IRenderTarget.hpp"
#include "../renderer/inc/IRenderEngine.hpp"

// fwdecl
class SCREEN_INFORMATION;
Expand All @@ -28,13 +29,13 @@ class ScreenBufferRenderTarget final : public Microsoft::Console::Render::IRende
{
public:
ScreenBufferRenderTarget(SCREEN_INFORMATION& owner);
void TriggerIntereaction(Microsoft::Console::Render::IntereactionType type) override;

void TriggerRedraw(const Microsoft::Console::Types::Viewport& region) override;
void TriggerRedraw(const COORD* const pcoord) override;
void TriggerRedrawCursor(const COORD* const pcoord) override;
void TriggerRedrawAll() override;
void TriggerTeardown() noexcept override;
void TriggerSelection() override;
void TriggerScroll() override;
void TriggerScroll(const COORD* const pcoordDelta) override;
void TriggerCircling() override;
Expand Down
2 changes: 1 addition & 1 deletion src/host/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void Selection::_PaintSelection() const
{
if (ServiceLocator::LocateGlobals().pRender != nullptr)
{
ServiceLocator::LocateGlobals().pRender->TriggerSelection();
ServiceLocator::LocateGlobals().pRender->TriggerIntereaction(Microsoft::Console::Render::IntereactionType::Selection);
}
}

Expand Down
30 changes: 0 additions & 30 deletions src/interactivity/onecore/BgfxEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
return S_FALSE;
}

[[nodiscard]] HRESULT BgfxEngine::ScrollFrame() noexcept
{
return S_OK;
}

[[nodiscard]] HRESULT BgfxEngine::PaintBackground() noexcept
{
PVOID OldRunBase;
Expand Down Expand Up @@ -166,19 +161,6 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
CATCH_RETURN();
}

[[nodiscard]] HRESULT BgfxEngine::PaintBufferGridLines(GridLines const /*lines*/,
COLORREF const /*color*/,
size_t const /*cchLine*/,
COORD const /*coordTarget*/) noexcept
{
return S_OK;
}

[[nodiscard]] HRESULT BgfxEngine::PaintSelection(const SMALL_RECT /*rect*/) noexcept
{
return S_OK;
}

[[nodiscard]] HRESULT BgfxEngine::PaintCursor(const CursorOptions& options) noexcept
{
// TODO: MSFT: 11448021 - Modify BGFX to support rendering full-width
Expand Down Expand Up @@ -257,15 +239,3 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid
*pResult = false;
return S_OK;
}

// Method Description:
// - Updates the window's title string.
// Does nothing for BGFX.
// Arguments:
// - newTitle: the new string to use for the title of the window
// Return Value:
// - S_OK
[[nodiscard]] HRESULT BgfxEngine::_DoUpdateTitle(_In_ const std::wstring_view /*newTitle*/) noexcept
{
return S_OK;
}
3 changes: 0 additions & 3 deletions src/interactivity/onecore/BgfxEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ namespace Microsoft::Console::Render
[[nodiscard]] HRESULT GetFontSize(_Out_ COORD* const pFontSize) noexcept override;
[[nodiscard]] HRESULT IsGlyphWideByFont(const std::wstring_view glyph, _Out_ bool* const pResult) noexcept override;

protected:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you forget to remove some of them from this file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can't compile Bgfx & WDDM. I don't know if it can compile or not. So I just left it as it is.

[[nodiscard]] HRESULT _DoUpdateTitle(_In_ const std::wstring_view newTitle) noexcept override;

private:
ULONG_PTR _sharedViewBase;
SIZE_T _runLength;
Expand Down
Loading