From 51daecb26cf6621f2021594e63d33fe71b4d0326 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sat, 12 Feb 2011 19:26:49 +0000 Subject: Optimized drawing of repeating 1px sized bitmaps. svn path=/trunk/netsurf/; revision=11651 --- atari/plot.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'atari/plot.c') diff --git a/atari/plot.c b/atari/plot.c index 1dd807356..2bfe37923 100755 --- a/atari/plot.c +++ b/atari/plot.c @@ -150,12 +150,31 @@ static bool plot_bitmap(int x, int y, int width, int height, struct bitmap * bm = NULL; bool repeat_x = (flags & BITMAPF_REPEAT_X); bool repeat_y = (flags & BITMAPF_REPEAT_Y); - + int bmpw,bmph; + struct s_clipping clip; + if( option_suppress_images != 0 ) { return( true ); } - if( width != bitmap_get_width(bitmap) || height != bitmap_get_height( bitmap) ) { + bmpw = bitmap_get_width(bitmap); + bmph = bitmap_get_height(bitmap); + + if ( repeat_x || repeat_y ) { + plotter_get_clip( plotter, &clip ); + if( repeat_x && width == 1 && repeat_y && height == 1 ){ + width = MAX( width, clip.x1 - x ); + height = MAX( height, clip.y1 - y ); + } + else if( repeat_x && width == 1 ){ + width = MAX( width, clip.x1 - x); + } + else if( repeat_y && height == 1){ + height = MAX( height, clip.y1 - y ); + } + } + + if( width != bmpw || height != bmph ) { assert( plotter->bitmap_resize(plotter, bitmap, width, height ) == 0); bm = bitmap->resized; } else { @@ -170,8 +189,6 @@ static bool plot_bitmap(int x, int y, int width, int height, plotter->bitmap( plotter, bm, x, y, bg, flags ); } else { int xf,yf; - struct s_clipping clip; - plotter_get_clip( plotter, &clip ); int xoff = x; int yoff = y; /* for now, repeating just works in the rigth / down direction */ @@ -181,6 +198,7 @@ static bool plot_bitmap(int x, int y, int width, int height, if(repeat_y == true ) yoff = clip.y0; */ + for( xf = xoff; xf < clip.x1; xf += width ) { for( yf = yoff; yf < clip.y1; yf += height ) { plotter->bitmap( plotter, bm, xf, yf, bg, flags ); -- cgit v1.2.3