diff --git a/src/buffer/out/OutputCellView.cpp b/src/buffer/out/OutputCellView.cpp index 57a9449889..cd1f16a764 100644 --- a/src/buffer/out/OutputCellView.cpp +++ b/src/buffer/out/OutputCellView.cpp @@ -28,6 +28,7 @@ OutputCellView::OutputCellView(const std::wstring_view view, // Return Value: // - Reference to UTF-16 character data // C26445 - suppressed to enable the `TextBufferTextIterator::operator->` method which needs a non-temporary memory location holding the wstring_view. +// TODO: GH 2681 - remove this suppression by reconciling the probably bad design of the iterators that leads to this being required. [[gsl::suppress(26445)]] const std::wstring_view& OutputCellView::Chars() const noexcept { return _view; diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index 0372dc5903..a64406f074 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -1065,7 +1065,7 @@ std::string TextBuffer::GenHTML(const TextAndColor& rows, const int fontHeightPo { try { - // TODO: the font name needs to be passed and stored around as an actual bounded type, not an implicit bounds on LF_FACESIZE + // TODO: GH 602 the font name needs to be passed and stored around as an actual bounded type, not an implicit bounds on LF_FACESIZE const auto faceLength = wcsnlen_s(fontFaceName, LF_FACESIZE); const std::wstring_view faceNameView{ fontFaceName, faceLength }; diff --git a/src/buffer/out/textBufferCellIterator.cpp b/src/buffer/out/textBufferCellIterator.cpp index 999370cfa7..285a4ec204 100644 --- a/src/buffer/out/textBufferCellIterator.cpp +++ b/src/buffer/out/textBufferCellIterator.cpp @@ -212,7 +212,7 @@ void TextBufferCellIterator::_SetPos(const COORD newPos) if (newPos.X != _pos.X) { - const ptrdiff_t diff = gsl::narrow_cast(newPos.X) - gsl::narrow_cast(_pos.X); + const auto diff = gsl::narrow_cast(newPos.X) - gsl::narrow_cast(_pos.X); _attrIter += diff; } diff --git a/src/buffer/out/textBufferTextIterator.cpp b/src/buffer/out/textBufferTextIterator.cpp index c0cc3ad088..9687e31758 100644 --- a/src/buffer/out/textBufferTextIterator.cpp +++ b/src/buffer/out/textBufferTextIterator.cpp @@ -25,6 +25,7 @@ TextBufferTextIterator::TextBufferTextIterator(const TextBufferCellIterator& cel // - Returns the text information from the text buffer position addressed by this iterator. // Return Value: // - Read only UTF-16 text data +// TODO GH 2682, fix design so this doesn't have to be suppressed. [[gsl::suppress(26434)]] const std::wstring_view TextBufferTextIterator::operator*() const noexcept { return _view.Chars(); @@ -34,6 +35,7 @@ TextBufferTextIterator::TextBufferTextIterator(const TextBufferCellIterator& cel // - Returns the text information from the text buffer position addressed by this iterator. // Return Value: // - Read only UTF-16 text data +// TODO GH 2682, fix design so this doesn't have to be suppressed. [[gsl::suppress(26434)]] const std::wstring_view* TextBufferTextIterator::operator->() const noexcept { return &_view.Chars(); diff --git a/src/renderer/dx/CustomTextRenderer.cpp b/src/renderer/dx/CustomTextRenderer.cpp index b071f69e19..c0e545faf2 100644 --- a/src/renderer/dx/CustomTextRenderer.cpp +++ b/src/renderer/dx/CustomTextRenderer.cpp @@ -257,7 +257,7 @@ using namespace Microsoft::Console::Render; // Then make a copy for the baseline origin (which is part way down the left side of the text, not the top or bottom). // We'll use this baseline Origin for drawing the actual text. - const D2D1_POINT_2F baselineOrigin = { origin.x, origin.y + drawingContext->spacing.baseline }; + const D2D1_POINT_2F baselineOrigin{ origin.x, origin.y + drawingContext->spacing.baseline }; ::Microsoft::WRL::ComPtr d2dContext; RETURN_IF_FAILED(drawingContext->renderTarget->QueryInterface(d2dContext.GetAddressOf())); @@ -270,10 +270,7 @@ using namespace Microsoft::Console::Render; rect.right = rect.left; const auto advancesSpan = gsl::make_span(glyphRun->glyphAdvances, glyphRun->glyphCount); - for (const auto& advance : advancesSpan) - { - rect.right += advance; - } + rect.right = std::accumulate(advancesSpan.cbegin(), advancesSpan.cend(), rect.right); d2dContext->FillRectangle(rect, drawingContext->backgroundBrush); @@ -377,7 +374,7 @@ using namespace Microsoft::Console::Render; // This run is solid-color outlines, either from non-color // glyphs or from COLR glyph layers. Use Direct2D to draw them. - ID2D1Brush* layerBrush = nullptr; + ID2D1Brush* layerBrush{ nullptr }; // The rule is "if 0xffff, use current brush." See: // https://docs.microsoft.com/en-us/windows/desktop/api/dwrite_2/ns-dwrite_2-dwrite_color_glyph_run if (colorRun->paletteIndex == 0xFFFF) diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 2effe1b4af..a3d5eab270 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -25,7 +25,7 @@ using namespace Microsoft::Console::Types; // - Constructs a DirectX-based renderer for console text // which primarily uses DirectWrite on a Direct2D surface #pragma warning(suppress : 26455) -// TODO: The default constructor should not throw. +// TODO GH 2683: The default constructor should not throw. DxEngine::DxEngine() : RenderEngineBase(), _isInvalidUsed{ false }, @@ -149,12 +149,11 @@ DxEngine::~DxEngine() // D3D11_CREATE_DEVICE_DEBUG | D3D11_CREATE_DEVICE_SINGLETHREADED; - std::array FeatureLevels; - FeatureLevels.at(0) = D3D_FEATURE_LEVEL_11_1; - FeatureLevels.at(1) = D3D_FEATURE_LEVEL_11_0; - FeatureLevels.at(2) = D3D_FEATURE_LEVEL_10_1; - FeatureLevels.at(3) = D3D_FEATURE_LEVEL_10_0; - FeatureLevels.at(4) = D3D_FEATURE_LEVEL_9_1; + const std::array FeatureLevels{ D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_1 }; // Trying hardware first for maximum performance, then trying WARP (software) renderer second // in case we're running inside a downlevel VM where hardware passthrough isn't enabled like @@ -164,7 +163,7 @@ DxEngine::~DxEngine() nullptr, DeviceFlags, FeatureLevels.data(), - gsl::narrow(FeatureLevels.size()), + gsl::narrow_cast(FeatureLevels.size()), D3D11_SDK_VERSION, &_d3dDevice, nullptr, @@ -177,7 +176,7 @@ DxEngine::~DxEngine() nullptr, DeviceFlags, FeatureLevels.data(), - gsl::narrow(FeatureLevels.size()), + gsl::narrow_cast(FeatureLevels.size()), D3D11_SDK_VERSION, &_d3dDevice, nullptr, @@ -1132,6 +1131,7 @@ enum class CursorPaintType { // Enforce min/max cursor height ULONG ulHeight = std::clamp(options.ulCursorHeightPercent, s_ulMinCursorHeightPercent, s_ulMaxCursorHeightPercent); + ulHeight = gsl::narrow((_glyphCell.cy * ulHeight) / 100); rect.top = rect.bottom - ulHeight; break; @@ -1794,14 +1794,3 @@ float DxEngine::GetScaling() const noexcept FAIL_FAST_HR(E_NOTIMPL); } } - -// Routine Description: -// - Helps convert a Direct2D ColorF into a DXGI RGBA -// Arguments: -// - color - Direct2D Color F -// Return Value: -// - DXGI RGBA -[[nodiscard]] constexpr DXGI_RGBA DxEngine::s_RgbaFromColorF(const D2D1_COLOR_F color) noexcept -{ - return { color.r, color.g, color.b, color.a }; -} diff --git a/src/renderer/dx/DxRenderer.hpp b/src/renderer/dx/DxRenderer.hpp index 2f238ad908..f096012031 100644 --- a/src/renderer/dx/DxRenderer.hpp +++ b/src/renderer/dx/DxRenderer.hpp @@ -213,6 +213,15 @@ namespace Microsoft::Console::Render [[nodiscard]] D2D1_COLOR_F _ColorFFromColorRef(const COLORREF color) noexcept; - [[nodiscard]] static constexpr DXGI_RGBA s_RgbaFromColorF(const D2D1_COLOR_F color) noexcept; + // Routine Description: + // - Helps convert a Direct2D ColorF into a DXGI RGBA + // Arguments: + // - color - Direct2D Color F + // Return Value: + // - DXGI RGBA + [[nodiscard]] constexpr DXGI_RGBA s_RgbaFromColorF(const D2D1_COLOR_F color) noexcept + { + return { color.r, color.g, color.b, color.a }; + } }; } diff --git a/src/types/ScreenInfoUiaProviderBase.cpp b/src/types/ScreenInfoUiaProviderBase.cpp index 3f0baf3e43..27cf40c14e 100644 --- a/src/types/ScreenInfoUiaProviderBase.cpp +++ b/src/types/ScreenInfoUiaProviderBase.cpp @@ -253,11 +253,9 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetRuntimeId(_Outptr_result_maybenull_ *ppRuntimeId = nullptr; // AppendRuntimeId is a magic Number that tells UIAutomation to Append its own Runtime ID(From the HWND) - std::array rId; - rId.at(0) = UiaAppendRuntimeId; - rId.at(1) = -1; + const std::array rId{ UiaAppendRuntimeId, -1 }; - const auto span = std::basic_string_view(rId.data(), rId.size()); + const std::basic_string_view span{ rId.data(), rId.size() }; // BuildIntSafeArray is a custom function to hide the SafeArray creation *ppRuntimeId = BuildIntSafeArray(span); RETURN_IF_NULL_ALLOC(*ppRuntimeId);