Skip to content

Commit

Permalink
Check if there are any lines to paint in the grid line renderer befor…
Browse files Browse the repository at this point in the history
…e looking up the color.
  • Loading branch information
j4james committed Jul 6, 2020
1 parent ee673af commit 7d637b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/renderer/base/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,13 +879,16 @@ void Renderer::_PaintBufferOutputGridLineHelper(_In_ IRenderEngine* const pEngin
const size_t cchLine,
const COORD coordTarget)
{
const COLORREF rgb = _pData->GetAttributeColors(textAttribute).first;

// Convert console grid line representations into rendering engine enum representations.
IRenderEngine::GridLines lines = Renderer::s_GetGridlines(textAttribute);

// Draw the lines
LOG_IF_FAILED(pEngine->PaintBufferGridLines(lines, rgb, cchLine, coordTarget));
// Return early if there are no lines to paint.
if (lines != IRenderEngine::GridLines::None)
{
// Get the current foreground color to render the lines.
const COLORREF rgb = _pData->GetAttributeColors(textAttribute).first;
// Draw the lines
LOG_IF_FAILED(pEngine->PaintBufferGridLines(lines, rgb, cchLine, coordTarget));
}
}

// Routine Description:
Expand Down
3 changes: 0 additions & 3 deletions src/renderer/gdi/paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,6 @@ using namespace Microsoft::Console::Render;
// - S_OK or suitable GDI HRESULT error or E_FAIL for GDI errors in functions that don't reliably return a specific error code.
[[nodiscard]] HRESULT GdiEngine::PaintBufferGridLines(const GridLines lines, const COLORREF color, const size_t cchLine, const COORD coordTarget) noexcept
{
// Return early if there are no lines to paint.
RETURN_HR_IF(S_OK, GridLines::None == lines);

LOG_IF_FAILED(_FlushBufferLines());

// Convert the target from characters to pixels.
Expand Down

0 comments on commit 7d637b8

Please sign in to comment.