Painter: More optimisations

This commit is contained in:
Mirek Fidler 2023-12-27 23:39:45 +01:00
parent 5a51a1da90
commit df19a1be83
2 changed files with 17 additions and 13 deletions

View file

@ -192,7 +192,7 @@ private:
Pointf path_min, path_max;
};
enum { BATCH_SIZE = 128 }; // must be 2^n
enum { BATCH_SIZE = 256 }; // must be 2^n
Buffer<PathInfo> paths;
int path_index = 0;

View file

@ -46,10 +46,20 @@ void Rasterizer::Create(int cx, int cy, bool subpixel)
void Rasterizer::Free()
{
if(cell)
for(int i = 0; i <= sz.cy; i++)
if(cell[i].alloc != SVO_ALLOC)
if(cell) {
for(int i = min_y; i <= max_y; i++) {
if(cell[i].alloc != SVO_ALLOC) {
MemoryFree(cell[i].ptr);
cell[i].alloc = SVO_ALLOC;
}
cell[i].count = 0;
}
if(cell[sz.cy].alloc != SVO_ALLOC) { // check overrun
MemoryFree(cell[sz.cy].ptr);
cell[sz.cy].alloc = SVO_ALLOC;
}
cell[sz.cy].count = 0;
}
}
void Rasterizer::Init()
@ -61,13 +71,7 @@ void Rasterizer::Init()
void Rasterizer::Reset()
{
for(int i = min_y; i <= max_y; i++) {
if(cell[i].alloc != SVO_ALLOC) {
MemoryFree(cell[i].ptr);
cell[i].alloc = SVO_ALLOC;
}
cell[i].count = 0;
}
Free();
Init();
}
@ -251,7 +255,7 @@ void Rasterizer::LineRaw(int x1, int y1, int x2, int y2)
int dy = y2 - y1;
int fy1 = y1 & 255;
int fy2 = y2 & 255;
Cell *c;
int x_from, x_to;
@ -381,4 +385,4 @@ void Rasterizer::Render(int y, Rasterizer::Filler& g, bool evenodd)
g.End();
}
}
}