From a6e0dfe80071956f2d6478e92d1db097bcb99e00 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 27 Mar 2009 17:49:39 +0000 Subject: Fix off by one at line end. svn path=/trunk/netsurf/; revision=6945 --- framebuffer/fb_16bpp_plotters.c | 48 +++++++++++++------------- framebuffer/fb_32bpp_plotters.c | 74 ++++++++++++++++++++--------------------- 2 files changed, 61 insertions(+), 61 deletions(-) (limited to 'framebuffer') diff --git a/framebuffer/fb_16bpp_plotters.c b/framebuffer/fb_16bpp_plotters.c index 8de86d802..b97c42da5 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,14 +114,14 @@ 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; pvideo++; y += dyabs; - if (y >= dxabs) { + if (y > dxabs) { y -= dxabs; pvideo += sdy * (framebuffer->linelen>>1); } @@ -133,13 +133,13 @@ static bool fb_16bpp_line(int x0, int y0, int x1, int y1, int width, pvideo += sdy * (framebuffer->linelen >> 1); x += dxabs; - if (x >= dyabs) { + if (x > dyabs) { x -= dyabs; pvideo++; } } } - + } @@ -261,7 +261,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; @@ -290,7 +290,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))); } @@ -322,17 +322,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; @@ -362,7 +362,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); @@ -371,7 +371,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. */ @@ -401,7 +401,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); @@ -455,7 +455,7 @@ static bool fb_16bpp_bitmap(int x, int y, int width, int height, /* 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; @@ -464,7 +464,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; @@ -475,7 +475,7 @@ static bool fb_16bpp_bitmap(int x, int y, int width, int height, return true; - LOG(("%d, %d %d, %d bitmap %p, content %p", + LOG(("%d, %d %d, %d bitmap %p, content %p", x0,y0,x1,y1,bitmap,content)); if (height > (y1 - y0)) @@ -506,7 +506,7 @@ static bool fb_16bpp_bitmap(int x, int y, int width, int height, 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))); } @@ -525,7 +525,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); } diff --git a/framebuffer/fb_32bpp_plotters.c b/framebuffer/fb_32bpp_plotters.c index 39d2a87e1..6f61b2428 100644 --- a/framebuffer/fb_32bpp_plotters.c +++ b/framebuffer/fb_32bpp_plotters.c @@ -33,8 +33,8 @@ static inline uint32_t * fb_32bpp_get_xy_loc(int x, int y) { - return (uint32_t *)(framebuffer->ptr + - (y * framebuffer->linelen) + + return (uint32_t *)(framebuffer->ptr + + (y * framebuffer->linelen) + (x << 2)); } @@ -52,8 +52,8 @@ static inline uint32_t fb_colour_to_pixel(colour c) #else static inline colour fb_32bpp_to_colour(uint32_t pixel) { - return ((pixel & 0xFF) << 16) | - ((pixel & 0xFF00)) | + return ((pixel & 0xFF) << 16) | + ((pixel & 0xFF00)) | ((pixel & 0xFF0000) >> 16); } @@ -119,9 +119,9 @@ static bool fb_32bpp_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++) { + for (i = 0; i < dxabs; i++) { *pvideo = ent; pvideo++; @@ -133,7 +133,7 @@ static bool fb_32bpp_line(int x0, int y0, int x1, int y1, int width, } } else { /* the line is more vertical than horizontal */ - for (i = 0; i <= dyabs; i++) { + for (i = 0; i < dyabs; i++) { *pvideo = ent; pvideo += sdy * (framebuffer->linelen >> 2); @@ -144,7 +144,7 @@ static bool fb_32bpp_line(int x0, int y0, int x1, int y1, int width, } } } - + } return true; @@ -218,10 +218,10 @@ static bool fb_32bpp_fill(int x0, int y0, int x1, int y1, colour c) static bool fb_32bpp_clg(colour c) { - fb_32bpp_fill(fb_plot_ctx.x0, - fb_plot_ctx.y0, - fb_plot_ctx.x1, - fb_plot_ctx.y1, + fb_32bpp_fill(fb_plot_ctx.x0, + fb_plot_ctx.y0, + fb_plot_ctx.x1, + fb_plot_ctx.y1, c); return true; } @@ -252,7 +252,7 @@ fb_32bpp_draw_ft_monobitmap(FT_Bitmap *bp, int x, int y, colour c) 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. */ @@ -285,16 +285,16 @@ fb_32bpp_draw_ft_monobitmap(FT_Bitmap *bp, int x, int y, colour c) if ((xloop % 8) == 0) { row = *fntd++; } - + if ((row & 0x80) != 0) { *(pvideo + xloop) = fgcol; - } + } row = row << 1; } pvideo += (framebuffer->linelen >> 2); } - + return true; } @@ -313,7 +313,7 @@ fb_32bpp_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; @@ -343,7 +343,7 @@ fb_32bpp_draw_ft_bitmap(FT_Bitmap *bp, int x, int y, colour c) if ((abpixel & 0xFF000000) != 0) { /* pixel is not transparent */ if ((abpixel & 0xFF000000) != 0xFF000000) { - abpixel = fb_plotters_ablend(abpixel, + abpixel = fb_plotters_ablend(abpixel, fb_32bpp_to_colour(*(pvideo + xloop))); } @@ -369,23 +369,23 @@ static bool fb_32bpp_text(int x, int y, const struct css_style *style, nxtchr = utf8_next(text, length, nxtchr); glyph = fb_getglyph(style, ucs4); - if (glyph == NULL) + if (glyph == NULL) continue; 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_32bpp_draw_ft_monobitmap(&bglyph->bitmap, - x + bglyph->left, + fb_32bpp_draw_ft_monobitmap(&bglyph->bitmap, + x + bglyph->left, y - bglyph->top, - c); + c); } else { - fb_32bpp_draw_ft_bitmap(&bglyph->bitmap, - x + bglyph->left, + fb_32bpp_draw_ft_bitmap(&bglyph->bitmap, + x + bglyph->left, y - bglyph->top, - c); + c); } } x += glyph->advance.x >> 16; @@ -413,7 +413,7 @@ static bool fb_32bpp_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); @@ -422,7 +422,7 @@ static bool fb_32bpp_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. */ @@ -452,7 +452,7 @@ static bool fb_32bpp_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_32bpp_get_xy_loc(x, y0); @@ -496,7 +496,7 @@ static inline colour ablend(colour pixel) static bool fb_32bpp_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, + struct bitmap *bitmap, colour bg, struct content *content) { uint32_t *pvideo; @@ -506,11 +506,11 @@ static bool fb_32bpp_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; @@ -519,7 +519,7 @@ static bool fb_32bpp_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; @@ -556,7 +556,7 @@ static bool fb_32bpp_bitmap(int x, int y, int width, int height, abpixel = pixel[yloop + xloop + xoff]; if ((abpixel & 0xFF000000) != 0) { if ((abpixel & 0xFF000000) != 0xFF000000) { - abpixel = fb_plotters_ablend(abpixel, + abpixel = fb_plotters_ablend(abpixel, fb_32bpp_to_colour(*(pvideo + xloop))); } @@ -572,10 +572,10 @@ static bool fb_32bpp_bitmap(int x, int y, int width, int height, static bool fb_32bpp_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, - bool repeat_x, bool repeat_y, + 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_32bpp_bitmap); } @@ -606,7 +606,7 @@ const struct plotter_table framebuffer_32bpp_plot = { .arc = fb_32bpp_arc, .bitmap = fb_32bpp_bitmap, .bitmap_tile = fb_32bpp_bitmap_tile, - .flush = fb_32bpp_flush, + .flush = fb_32bpp_flush, .path = fb_32bpp_path, .option_knockout = true, }; -- cgit v1.2.3