55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
/* DirtyRectList.c
|
|
Copyright (C) 2026 Pierre Sarrazin <http://sarrazip.com/>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "DirtyRectList.h"
|
|
|
|
|
|
void
|
|
DirtyRectList_init(DirtyRectList *self)
|
|
{
|
|
self->count = 0;
|
|
self->peak = 0;
|
|
}
|
|
|
|
|
|
BOOL
|
|
DirtyRectList_add(DirtyRectList *self, byte *addr, byte numRows)
|
|
{
|
|
byte *count = &self->count;
|
|
if (*count >= DirtyRectList_MAX_DIRTY_RECTS)
|
|
return FALSE;
|
|
|
|
DirtyRect *dr = &self->rects[(*count)++]; // next DirtyRect field to fill
|
|
dr->addr = addr;
|
|
dr->numRows = numRows;
|
|
#ifndef NDEBUG
|
|
if (*count > self->peak)
|
|
self->peak = *count;
|
|
#endif
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void
|
|
DirtyRectList_clean(DirtyRectList *self)
|
|
{
|
|
const DirtyRect *dr = self->rects;
|
|
for (byte i = self->count; i--; ++dr)
|
|
DirtyRect_clean(dr);
|
|
self->count = 0;
|
|
}
|