diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2009-02-26 23:05:06 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2009-02-26 23:05:06 +0000 |
commit | 6b064b526c52743873c35d262ac28fc66aeafd37 (patch) | |
tree | f0cc0377a19f1ebcdab4a9a3358829da146847a8 /framebuffer/fb_16bpp_plotters.c | |
parent | 7af238ab7fee2fc44d03a846c09e992f2f3c62e1 (diff) | |
download | netsurf-6b064b526c52743873c35d262ac28fc66aeafd37.tar.gz netsurf-6b064b526c52743873c35d262ac28fc66aeafd37.tar.bz2 |
Possibly slightly faster bitmap plotter.
svn path=/trunk/netsurf/; revision=6647
Diffstat (limited to 'framebuffer/fb_16bpp_plotters.c')
-rw-r--r-- | framebuffer/fb_16bpp_plotters.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/framebuffer/fb_16bpp_plotters.c b/framebuffer/fb_16bpp_plotters.c index bb1c29f78..5198025eb 100644 --- a/framebuffer/fb_16bpp_plotters.c +++ b/framebuffer/fb_16bpp_plotters.c @@ -33,14 +33,14 @@ static inline uint16_t * fb_16bpp_get_xy_loc(int x, int y) { - return (void *)(framebuffer->ptr + - (y * framebuffer->linelen) + + return (void *)(framebuffer->ptr + + (y * framebuffer->linelen) + (x << 1)); } static inline colour fb_16bpp_to_colour(uint16_t pixel) { - return ((pixel & 0x1F) << 19) | + return ((pixel & 0x1F) << 19) | ((pixel & 0x7E0) << 5) | ((pixel & 0xF800) >> 8); } @@ -114,7 +114,7 @@ static bool fb_16bpp_line(int x0, int y0, int x1, int y1, int width, x = dyabs >> 1; y = dxabs >> 1; - if (dxabs >= dyabs) { + if (dxabs >= dyabs) { /* the line is more horizontal than vertical */ for (i = 0; i <= dxabs; i++) { *pvideo = ent; @@ -139,7 +139,7 @@ static bool fb_16bpp_line(int x0, int y0, int x1, int y1, int width, } } } - + } @@ -240,7 +240,7 @@ fb_16bpp_draw_ft_bitmap(FT_Bitmap *bp, int x, int y, colour c) uint32_t fgcol; /* The part of the scaled image actually displayed is cropped to the - * current context. + * current context. */ x0 = x; y0 = y; @@ -269,7 +269,7 @@ fb_16bpp_draw_ft_bitmap(FT_Bitmap *bp, int x, int y, colour c) abpixel = (pixel[((yoff + yloop) * bp->pitch) + xloop + xoff] << 24) | fgcol; if ((abpixel & 0xFF000000) != 0) { if ((abpixel & 0xFF000000) != 0xFF000000) { - abpixel = fb_plotters_ablend(abpixel, + abpixel = fb_plotters_ablend(abpixel, fb_16bpp_to_colour(*(pvideo + xloop))); } @@ -301,17 +301,17 @@ static bool fb_16bpp_text(int x, int y, const struct css_style *style, if (glyph->format == FT_GLYPH_FORMAT_BITMAP) { bglyph = (FT_BitmapGlyph)glyph; - /* now, draw to our target surface */ + /* now, draw to our target surface */ if (bglyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { - fb_16bpp_draw_ft_monobitmap(&bglyph->bitmap, - x + bglyph->left, + fb_16bpp_draw_ft_monobitmap(&bglyph->bitmap, + x + bglyph->left, y - bglyph->top, - c); + c); } else { - fb_16bpp_draw_ft_bitmap(&bglyph->bitmap, - x + bglyph->left, + fb_16bpp_draw_ft_bitmap(&bglyph->bitmap, + x + bglyph->left, y - bglyph->top, - c); + c); } } x += glyph->advance.x >> 16; @@ -341,7 +341,7 @@ static bool fb_16bpp_text(int x, int y, const struct css_style *style, /* aquire thge text in local font encoding */ utf8_to_font_encoding(fb_font, text, length, (char **)&buffer); - if (!buffer) + if (!buffer) return true; length = strlen((char *)buffer); @@ -350,7 +350,7 @@ static bool fb_16bpp_text(int x, int y, const struct css_style *style, y-=((fb_font->height * 75)/100); y+=1; /* the coord is the bottom-left of the pixels offset by 1 to make - * it work since fb coords are the top-left of pixels + * it work since fb coords are the top-left of pixels */ /* The part of the text displayed is cropped to the current context. */ @@ -380,7 +380,7 @@ static bool fb_16bpp_text(int x, int y, const struct css_style *style, if ((x + fb_font->width) > x1) break; - if (x < x0) + if (x < x0) continue; pvideo = fb_16bpp_get_xy_loc(x, y0); @@ -432,11 +432,11 @@ static bool fb_16bpp_bitmap(int x, int y, int width, int height, int x0,y0,x1,y1; int xoff, yoff; /* x and y offset into image */ - /* LOG(("x %d, y %d, width %d, height %d, bitmap %p, content %p", + /* LOG(("x %d, y %d, width %d, height %d, bitmap %p, content %p", x,y,width,height,bitmap,content));*/ /* TODO here we should scale the image from bitmap->width to width, for - * now simply crop. + * now simply crop. */ if (width > bitmap->width) width = bitmap->width; @@ -445,7 +445,7 @@ static bool fb_16bpp_bitmap(int x, int y, int width, int height, height = bitmap->height; /* The part of the scaled image actually displayed is cropped to the - * current context. + * current context. */ x0 = x; y0 = y; @@ -462,17 +462,18 @@ static bool fb_16bpp_bitmap(int x, int y, int width, int height, width = (x1 - x0); xoff = x0 - x; - yoff = y0 - y; + yoff = (y0 - y) * bitmap->width; + height *= bitmap->width; /* plot the image */ pvideo = fb_16bpp_get_xy_loc(x0, y0); - for (yloop = 0; yloop < height; yloop++) { + for (yloop = yoff; yloop < height; yloop += bitmap->width) { for (xloop = 0; xloop < width; xloop++) { - abpixel = pixel[((yoff + yloop) * bitmap->width) + xloop + xoff]; + abpixel = pixel[yloop + xloop + xoff]; if ((abpixel & 0xFF000000) != 0) { if ((abpixel & 0xFF000000) != 0xFF000000) { - abpixel = fb_plotters_ablend(abpixel, + abpixel = fb_plotters_ablend(abpixel, fb_16bpp_to_colour(*(pvideo + xloop))); } @@ -490,7 +491,7 @@ static bool fb_16bpp_bitmap_tile(int x, int y, int width, int height, bool repeat_x, bool repeat_y, struct content *content) { - return fb_plotters_bitmap_tile(x, y, width, height, + return fb_plotters_bitmap_tile(x, y, width, height, bitmap, bg, repeat_x, repeat_y, content, fb_16bpp_bitmap); } |