From 7a4486a8f0f66ee1d6c3b314304120b5fd18c409 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 13 Feb 2008 11:32:19 +0000 Subject: [PATCH] More optimizations. --- src/raster/algo.c | 25 ++++++++++----- src/raster/dirty.c | 78 ++-------------------------------------------- src/raster/dirty.h | 5 --- 3 files changed, 19 insertions(+), 89 deletions(-) diff --git a/src/raster/algo.c b/src/raster/algo.c index f4a391eb5..90cac0ce1 100644 --- a/src/raster/algo.c +++ b/src/raster/algo.c @@ -26,17 +26,26 @@ void algo_dirty(Dirty *dirty, void *data, AlgoHLine proc) { - int u, v; + register struct DirtyRow *row; + register struct DirtyCol *col; + struct DirtyRow *rowend; + struct DirtyCol *colend; - for (v=0; vrows; v++) - for (u=0; urow[v].cols; u++) - if (dirty->row[v].col[u].flags & DIRTY_MUSTBE_UPDATED) { - (*proc)(dirty->row[v].col[u].x, - dirty->row[v].y, - dirty->row[v].col[u].x+dirty->row[v].col[u].w-1, data); + row = dirty->row; + rowend = row+dirty->rows; + for (; rowcol; + colend = col+row->cols; + for (; colflags & DIRTY_MUSTBE_UPDATED) { + (*proc)(col->x, + row->y, + col->x+col->w-1, data); - dirty->row[v].col[u].flags ^= DIRTY_MUSTBE_UPDATED; + col->flags ^= DIRTY_MUSTBE_UPDATED; } + } + } } /* Algorightm from Allegro (allegro/src/gfx.c) diff --git a/src/raster/dirty.c b/src/raster/dirty.c index 572b531cb..78b1edc40 100644 --- a/src/raster/dirty.c +++ b/src/raster/dirty.c @@ -69,7 +69,7 @@ sizeof(struct DirtyCol) * (row->cols-2-u)); \ \ row->cols--; \ - row->col = jrealloc(row->col, sizeof(struct DirtyCol) * row->cols); \ + row->col = jrealloc(row->col, sizeof(struct DirtyCol) * row->cols); \ col = row->col+u; \ } @@ -527,8 +527,7 @@ void dirty_hline(Dirty *dirty, int x1, int y, int x2) /* inside the column */ if (x2 <= col->x+col->w-1) { - col->data = jrealloc(col->data, - DIRTY_LINE_SIZE(col->w)); + col->data = jrealloc(col->data, DIRTY_LINE_SIZE(col->w)); return; } /* extend this column to "x2" */ @@ -580,21 +579,6 @@ void dirty_rectfill(Dirty *dirty, int x1, int y1, int x2, int y2) dirty_hline(dirty, x1, y, x2); } -/* void dirty_putpixel_thick (Dirty *dirty, int x, int y, int thickness) */ -/* { */ -/* AlgoData data = { dirty, NULL, thickness }; */ -/* algo_putthick (x, y, &data); */ -/* } */ - -/* void dirty_line_thick (Dirty *dirty, int x1, int y1, int x2, int y2, int thickness) */ -/* { */ -/* AlgoData data = { dirty, NULL, thickness }; */ -/* algo_line (x1, y1, x2, y2, &data, */ -/* (thickness == 1)? */ -/* (AlgoPixel)algo_putpixel: */ -/* (AlgoPixel)algo_putthick); */ -/* } */ - void dirty_putpixel_brush(Dirty *dirty, Brush *brush, int x, int y) { AlgoData data = { dirty, brush, 0 }; @@ -626,56 +610,6 @@ void dirty_line_brush(Dirty *dirty, Brush *brush, int x1, int y1, int x2, int y2 (AlgoPixel)algo_putbrush); } -#if 0 -static void remove_column(Dirty *dirty, int u, int v) -{ - jfree(dirty->row[v].col[u].data); - - memmove(dirty->row[v].col+u, dirty->row[v].col+u+1, - sizeof(struct DirtyCol) * ((dirty->row[v].cols - u) - 1)); - - dirty->row[v].cols--; - dirty->row[v].col = - jrealloc(dirty->row[v].col, - sizeof(struct DirtyCol) * dirty->row[v].cols); -} - -/* joins all consecutive columns */ -void dirty_optimize(Dirty *dirty) -{ - int u, v, w; - - for (v=0; vrows; ++v) { - for (u=0; urow[v].cols; ++u) { - for (w=0; wrow[v].cols; ++w) { - if (u == w) - continue; - - if ((dirty->row[v].col[u].x+dirty->row[v].col[u].w == dirty->row[v].col[w].x)) { - int oldw = dirty->row[v].col[u].w; - - dirty->row[v].col[u].w += dirty->row[v].col[w].w; - dirty->row[v].col[u].data = - jrealloc(dirty->row[v].col[u].data, - DIRTY_LINE_SIZE(dirty->row[v].col[u].w)); - - memcpy(dirty->row[v].col[u].data + DIRTY_LINE_SIZE (oldw), - dirty->row[v].col[w].data, - DIRTY_LINE_SIZE(dirty->row[v].col[w].w)); - - dirty->row[v].col[u].flags |= DIRTY_VALID_COLUMN; - dirty->row[v].col[u].flags |= DIRTY_MUSTBE_UPDATED; - - remove_column(dirty, w, v); - u = -1; - break; - } - } - } - } -} -#endif - void dirty_get(Dirty *dirty) { register int v, u, shift = IMAGE_SHIFT(dirty->image); @@ -748,14 +682,6 @@ static void algo_putpixel(int x, int y, AlgoData *data) dirty_putpixel(data->dirty, x, y); } -/* static void algo_putthick (int x, int y, AlgoData *data) */ -/* { */ -/* register int t1 = -data->thickness/2; */ -/* register int t2 = t1+data->thickness-1; */ - -/* dirty_rectfill (data->dirty, x+t1, y+t1, x+t2, y+t2); */ -/* } */ - static void algo_putbrush(int x, int y, AlgoData *data) { register struct BrushScanline *scanline = data->brush->scanline; diff --git a/src/raster/dirty.h b/src/raster/dirty.h index 52871585d..4d618cc68 100644 --- a/src/raster/dirty.h +++ b/src/raster/dirty.h @@ -77,15 +77,10 @@ void dirty_line(Dirty *dirty, int x1, int y1, int x2, int y2); void dirty_rect(Dirty *dirty, int x1, int y1, int x2, int y2); void dirty_rectfill(Dirty *dirty, int x1, int y1, int x2, int y2); -/* void dirty_putpixel_thick(Dirty *dirty, int x, int y, int thickness); */ -/* void dirty_line_thick(Dirty *dirty, int x1, int y1, int x2, int y2, int thickness); */ - void dirty_putpixel_brush(Dirty *dirty, struct Brush *brush, int x, int y); void dirty_hline_brush(Dirty *dirty, struct Brush *brush, int x1, int y, int x2); void dirty_line_brush(Dirty *dirty, struct Brush *brush, int x1, int y1, int x2, int y2); -/* void dirty_optimize(Dirty *dirty); */ - void dirty_get(Dirty *dirty); void dirty_put(Dirty *dirty); void dirty_swap(Dirty *dirty);