From 482a13cf879ae07a5f6c72fba84d994bde3a4852 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 7 Mar 2026 10:27:10 +1100 Subject: In visible whitespace modes, when there are contiguous spaces, paint the background of the whole space range in one FillRectangleAligned call instead of a call per space. This reduces graphics calls and eliminates seams between the spaces when drawn in some scaled environments. The main background filling call was moved outside the representation test to emphasize that it always occurs thus causing all the text area to have a defined background colour. --- src/EditView.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/EditView.cxx b/src/EditView.cxx index a1b0d61ab..d1e9c4103 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1683,21 +1683,27 @@ void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &v // Blob display inIndentation = false; } - surface->FillRectangleAligned(rcSegment, Fill(textBack)); - } else { + } + surface->FillRectangleAligned(rcSegment, Fill(textBack)); + if (!ts.representation) { // Normal text display - surface->FillRectangleAligned(rcSegment, Fill(textBack)); if (vsDraw.viewWhitespace != WhiteSpace::Invisible) { - for (int cpos = 0; cpos <= i - ts.start; cpos++) { - if (ll->chars[cpos + ts.start] == ' ') { + for (int cpos = 0; cpos <= i - ts.start; ) { + int countSpaces = 0; + while ((countSpaces <= i - ts.start - cpos) && (ll->chars[cpos + ts.start + countSpaces] == ' ')) { + countSpaces++; + } + if (countSpaces) { if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) { const PRectangle rcSpace = Intersection(rcLine, - ll->SpanByte(cpos + ts.start).Offset(horizontalOffset)); + ll->Span(cpos + ts.start, cpos + ts.start + countSpaces).Offset(horizontalOffset)); surface->FillRectangleAligned(rcSpace, vsDraw.ElementColourForced(Element::WhiteSpaceBack).Opaque()); } + cpos += countSpaces; } else { inIndentation = false; + cpos++; } } } -- cgit v1.2.3