From ec1b9e53f44084faf1b6199766fa38fc23bea287 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 18 Jan 2025 11:43:22 +0100 Subject: [PATCH] Codechange: use std::vector over ReallocT for dirty blocks --- src/gfx.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gfx.cpp b/src/gfx.cpp index b9698b000f..5c5684713c 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -8,7 +8,6 @@ /** @file gfx.cpp Handling of drawing text and other gfx related stuff. */ #include "stdafx.h" -#include "core/alloc_func.hpp" #include "gfx_layout.h" #include "progress.h" #include "zoom_func.h" @@ -79,7 +78,7 @@ static const uint DIRTY_BLOCK_HEIGHT = 8; static const uint DIRTY_BLOCK_WIDTH = 64; static uint _dirty_bytes_per_line = 0; -static uint8_t *_dirty_blocks = nullptr; +static std::vector _dirty_blocks; extern uint _dirty_block_colour; void GfxScroll(int left, int top, int width, int height, int xo, int yo) @@ -1273,7 +1272,7 @@ std::pair GetBroadestDigit(FontSize size) void ScreenSizeChanged() { _dirty_bytes_per_line = CeilDiv(_screen.width, DIRTY_BLOCK_WIDTH); - _dirty_blocks = ReallocT(_dirty_blocks, static_cast(_dirty_bytes_per_line) * CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT)); + _dirty_blocks.resize(static_cast(_dirty_bytes_per_line) * CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT)); /* check the dirty rect */ if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width; @@ -1401,7 +1400,7 @@ void RedrawScreenRect(int left, int top, int right, int bottom) */ void DrawDirtyBlocks() { - uint8_t *b = _dirty_blocks; + uint8_t *b = _dirty_blocks.data(); const int w = Align(_screen.width, DIRTY_BLOCK_WIDTH); const int h = Align(_screen.height, DIRTY_BLOCK_HEIGHT); int x; @@ -1509,7 +1508,7 @@ void AddDirtyBlock(int left, int top, int right, int bottom) left /= DIRTY_BLOCK_WIDTH; top /= DIRTY_BLOCK_HEIGHT; - b = _dirty_blocks + top * _dirty_bytes_per_line + left; + b = _dirty_blocks.data() + top * _dirty_bytes_per_line + left; width = ((right - 1) / DIRTY_BLOCK_WIDTH) - left + 1; height = ((bottom - 1) / DIRTY_BLOCK_HEIGHT) - top + 1;