Skip to content

Commit

Permalink
clear window line by line, skipping untouched lines (CleverRaven#72035)
Browse files Browse the repository at this point in the history
* clear window line by line, skipping untouched lines
Many of the windows in the game, especially the ones with scrollbars,
create multiple overlapping windows and then draw them in an odd
order. This results in overdraw, but that was partly compensated for
by the cache that we removed. Now that we clear the whole window in
one go, this causes artifacts as we erase text that was already drawn
in a different window that overlaps the current one. By erasing only
the lines that are touched, we avoid the problem.

Fixes CleverRaven#71994.

* format the code to placate astyle

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
db48x and github-actions[bot] authored Feb 28, 2024
1 parent 25af268 commit 60757df
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,14 +1155,25 @@ static bool draw_window( Font_Ptr &font, const catacurses::window &w, const poin
WindowHeight / scaling_factor );
}

clear_window_area( w );
cata_cursesport::WINDOW *const win = w.get<cata_cursesport::WINDOW>();

// TODO: Get this from UTF system to make sure it is exactly the kind of space we need
static const std::string space_string = " ";

bool update = false;
for( int j = 0; j < win->height; j++ ) {
if( !win->line[j].touched ) {
continue;
}

// Although it would be simpler to clear the whole window at
// once, the code sometimes creates overlapping windows. By
// only clearing those lines that are touched, we avoid
// clearing lines that were already drawn in a previous
// window but are untouched in this one.
geometry->rect( renderer, point( win->pos.x * fontwidth, ( win->pos.y + j ) * fontheight ),
win->width * fontwidth, fontheight,
color_as_sdl( catacurses::black ) );
update = true;
win->line[j].touched = false;
for( int i = 0; i < win->width; i++ ) {
Expand Down

0 comments on commit 60757df

Please sign in to comment.