r5319 vince - in /branches/vince/netsurf-fb/framebuffer: fb_16bpp_plotters.c fb_32bpp_plotters.c

netsurf at semichrome.net netsurf at semichrome.net
Mon Sep 15 12:09:02 BST 2008


Author: vince
Date: Mon Sep 15 06:09:02 2008
New Revision: 5319

URL: http://source.netsurf-browser.org?rev=5319&view=rev
Log:
make plotters OS agnostic again

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c

Modified: branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c?rev=5319&r1=5318&r2=5319&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c Mon Sep 15 06:09:02 2008
@@ -210,7 +210,7 @@
 			const char *text, size_t length, colour bg, colour c)
 {
         const struct fb_font_desc* fb_font = fb_get_font(style);
-        const u8_t *font_data;
+        const uint8_t *font_data;
         int xloop, yloop;
         unsigned char row;
         size_t chr;

Modified: branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c?rev=5319&r1=5318&r2=5319&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c Mon Sep 15 06:09:02 2008
@@ -107,52 +107,65 @@
 			const char *text, size_t length, colour bg, colour c)
 {
         const struct fb_font_desc* fb_font = fb_get_font(style);
-        uint32_t *pvideo;
-        const u8_t *font_data;
+        const uint8_t *font_data;
         int xloop, yloop;
         unsigned char row;
-        argb_t *bitc;
         size_t chr;
-        argb_t fg_colour;
-        argb_t bg_colour;
-
-        fg_colour.r = c & 0xff;
-        fg_colour.g = (c & 0xff00) >> 8;
-        fg_colour.b = (c & 0xff00) >> 16;
-
-        bg_colour.r = bg & 0xff;
-        bg_colour.g = (bg & 0xff00) >> 8;
-        bg_colour.b = (bg & 0xff00) >> 16;
-
-        LOG(("%s(%d, %d, %p, %.*s , %d, 0x%lx, 0x%lx)\n", __func__, 
-             x,y,style,length,text,length,bg,c));
+
+        uint32_t *pvideo;
+        uint32_t fgcol;
+
+	char *buffer = NULL;
+
+        if (y > fb_plot_ctx.y1)
+                return true;
+
+        if (x > fb_plot_ctx.x1)
+                return true;
+
+        if (y < fb_plot_ctx.y0)
+                return true;
+
+        if (x < fb_plot_ctx.x0)
+                return true;
+
+	utf8_to_local_encoding(text, length, &buffer);
+	if (!buffer) 
+                return true;
+
+        length = strlen(buffer);
+
+        /* y is given to the fonts baseline we need it to the fonts top */
+        y-=(fb_font->height * 75)/100;
+
+        fgcol = ((c & 0xFF) << 16) | 
+                ((c & 0xFF00)) | 
+                ((c & 0xFF0000) >> 16);
+
+
+
+        /*LOG(("x %d, y %d, style %p, txt %.*s , len %d, bg 0x%lx, fg 0x%lx",
+          x,y,style,length,text,length,bg,c));*/
 
         for (chr=0; chr < length; chr++) {
                 pvideo = fb_32bpp_get_xy_loc(x + (chr * (fb_font->width)), y, current_window);
 
                 /* move our font-data to the correct position */
-                font_data = fb_font->data + (text[chr] * fb_font->height);
-
-                pvideo += fb_font->width;
+                font_data = fb_font->data + (buffer[chr] * fb_font->height);
+
                 for (yloop = 0; yloop < fb_font->height; yloop++) {
                         row = font_data[yloop];
-                        for (xloop = 0; xloop < fb_font->width; xloop ++) {
-                                if ((row & (1 << xloop)) == 0)
-                                        bitc = &bg_colour;
-                                else
-                                        bitc = &fg_colour;
-
-                                pvideo[0] = bitc->b;
-                                pvideo[1] = bitc->g;
-                                pvideo[2] = bitc->r;
-                                pvideo[3] = bitc->a;
-                                pvideo -= 4;
+                        for (xloop = fb_font->width; xloop > 0 ; xloop--) {
+                                if ((row & 1) != 0)
+                                        *(pvideo + xloop) = fgcol;
+                                row = row >> 1;
                         }
-                        pvideo += (framebuffer->linelen >> 2) + fb_font->width;
+                        pvideo += (framebuffer->linelen >> 2);
                 }
 
         }
 
+	free(buffer);
 	return true;
 }
 




More information about the netsurf-commits mailing list