mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::vector over ReallocT for dirty blocks
parent
92b723cb4e
commit
ec1b9e53f4
|
@ -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<uint8_t> _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<uint8_t, uint8_t> GetBroadestDigit(FontSize size)
|
|||
void ScreenSizeChanged()
|
||||
{
|
||||
_dirty_bytes_per_line = CeilDiv(_screen.width, DIRTY_BLOCK_WIDTH);
|
||||
_dirty_blocks = ReallocT<uint8_t>(_dirty_blocks, static_cast<size_t>(_dirty_bytes_per_line) * CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT));
|
||||
_dirty_blocks.resize(static_cast<size_t>(_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;
|
||||
|
|
Loading…
Reference in New Issue