r5377 vince - in /branches/vince/netsurf-fb/framebuffer: fb_16bpp_plotters.c fb_font.c fb_font.h fb_gui.c fb_plotters.c fb_plotters.h font_8x16.c

netsurf at semichrome.net netsurf at semichrome.net
Sat Sep 20 14:06:23 BST 2008


Author: vince
Date: Sat Sep 20 08:06:22 2008
New Revision: 5377

URL: http://source.netsurf-browser.org?rev=5377&view=rev
Log:
Improve scrolling

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_font.c
    branches/vince/netsurf-fb/framebuffer/fb_font.h
    branches/vince/netsurf-fb/framebuffer/fb_gui.c
    branches/vince/netsurf-fb/framebuffer/fb_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_plotters.h
    branches/vince/netsurf-fb/framebuffer/font_8x16.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=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c Sat Sep 20 08:06:22 2008
@@ -302,6 +302,7 @@
         colour abpixel; /* alphablended pixel */
         int xloop, yloop;
         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", 
            x,y,width,height,bitmap,content));*/
@@ -332,12 +333,15 @@
         if (width > (x1 - x0))
                 width = (x1 - x0);
 
+	xoff = x0 - x;
+	yoff = y0 - y;
+
         /* plot the image */
         pvideo = fb_16bpp_get_xy_loc(x0, y0, current_window);
 
         for (yloop = 0; yloop < height; yloop++) {
                 for (xloop = 0; xloop < width; xloop++) {
-                        abpixel = pixel[(yloop * bitmap->width) + xloop];
+                        abpixel = pixel[((yoff + yloop) * bitmap->width) + xloop + xoff];
                         if ((abpixel & 0xFF000000) != 0) {
                                 if ((abpixel & 0xFF000000) != 0xFF) {
                                         abpixel = fb_plotters_ablend(abpixel, 

Modified: branches/vince/netsurf-fb/framebuffer/fb_font.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_font.c?rev=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_font.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_font.c Sat Sep 20 08:06:22 2008
@@ -22,10 +22,11 @@
 #include <assert.h>
 #include "css/css.h"
 #include "render/font.h"
+#include "desktop/options.h"
+#include "utils/utf8.h"
+
 #include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_font.h"
-#include "desktop/options.h"
-#include "utils/utf8.h"
 
 const struct fb_font_desc*
 fb_get_font(const struct css_style *style)
@@ -33,10 +34,20 @@
         return &font_vga_8x16;
 }
 
-utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
-	char **result)
+utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
+				       const char *string, 
+				       size_t len,
+				       char **result)
 {
-	return utf8_to_enc(string, "ASCII", len, result);
+	return utf8_to_enc(string, font->encoding, len, result);
+
+}
+
+utf8_convert_ret utf8_to_local_encoding(const char *string, 
+				       size_t len,
+				       char **result)
+{
+	return utf8_to_enc(string, "CP437", len, result);
 
 }
 

Modified: branches/vince/netsurf-fb/framebuffer/fb_font.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_font.h?rev=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_font.h (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_font.h Sat Sep 20 08:06:22 2008
@@ -20,10 +20,15 @@
 struct fb_font_desc {
     const char *name;
     int width, height;
-    const unsigned char *data;
+    const char *encoding;
+    const uint8_t *data;
 };
 
 extern const struct fb_font_desc font_vga_8x16;
 
-const struct fb_font_desc* fb_get_font(const struct css_style *style);
+extern const struct fb_font_desc* fb_get_font(const struct css_style *style);
 
+extern utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
+				       const char *string, 
+				       size_t len,
+				       char **result);

Modified: branches/vince/netsurf-fb/framebuffer/fb_gui.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_gui.c?rev=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_gui.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_gui.c Sat Sep 20 08:06:22 2008
@@ -235,12 +235,39 @@
 	g->redraw_required = true;
 }
 
-void fb_window_scroll(struct gui_window *g, int scrollby)
-{
-	g->scrolly += scrollby;
-	if (g->scrolly < 0)
-		g->scrolly = 0;
-	gui_window_redraw_window(g);
+static void fb_queue_pan(struct gui_window *g, int x, int y)
+{
+	if (!g) return;
+
+        LOG(("%p, %d, %d, %d, %d", g, x0 , y0, x1, y1));
+
+        g->panx +=x;
+        g->pany +=y;
+
+        redraws_pending = true;
+	g->redraw_required = true;
+}
+
+void fb_window_scroll(struct gui_window *g, int scrollby) 
+{
+	if ((g->scrolly + scrollby) < 0)
+		scrollby = -g->scrolly;
+
+	if ((g->scrolly + scrollby) > g->bw->current_content->height)
+		scrollby = g->bw->current_content->height - g->scrolly;
+
+	if (scrollby < 0) {
+		fb_plotters_move_block(g->x, g->y, g->width, g->height + scrollby, g->x, g->y - scrollby);
+		g->scrolly += scrollby;
+		fb_queue_redraw(g, g->x, g->y, 
+				g->x + g->width, g->y - scrollby);
+	}
+	if (scrollby > 0) {
+		fb_plotters_move_block(g->x, g->y + scrollby, g->width, g->height - scrollby, g->x, g->y);
+		g->scrolly += scrollby;
+		fb_queue_redraw(g, g->x, g->y + g->height - scrollby, 
+				g->x + g->width, g->y + g->height);
+	}
 }
 
 void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)

Modified: branches/vince/netsurf-fb/framebuffer/fb_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_plotters.c?rev=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_plotters.c Sat Sep 20 08:06:22 2008
@@ -204,6 +204,20 @@
 	return true;
 }
 
+bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+	LOG(("from (%d,%d) w %d h %d to (%d,%d)",srcx,srcy,width,height,dstx,dsty));
+	uint8_t *srcptr = (framebuffer->ptr + 
+                           (srcy * framebuffer->linelen) + 
+			   (srcx));
+
+	uint8_t *dstptr = (framebuffer->ptr + 
+                           (dsty * framebuffer->linelen) + 
+			   (dstx));
+
+	memmove(dstptr, srcptr, (width * height * framebuffer->bpp) / 8);
+}
+
 /*
  * Local Variables:
  * c-basic-offset:8

Modified: branches/vince/netsurf-fb/framebuffer/fb_plotters.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_plotters.h?rev=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_plotters.h (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_plotters.h Sat Sep 20 08:06:22 2008
@@ -38,6 +38,8 @@
 
 colour fb_plotters_ablend(colour pixel, colour scrpixel);
 
+bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int dsty);
+
 /* generic plotter entry points */
 bool fb_clip(int x0, int y0, int x1, int y1);
 

Modified: branches/vince/netsurf-fb/framebuffer/font_8x16.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/font_8x16.c?rev=5377&r1=5376&r2=5377&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/font_8x16.c (original)
+++ branches/vince/netsurf-fb/framebuffer/font_8x16.c Sat Sep 20 08:06:22 2008
@@ -17,6 +17,8 @@
  */
 
 #include "desktop/plotters.h"
+#include "utils/utf8.h"
+
 #include "framebuffer/fb_font.h"
 
 #define FONTDATAMAX 4096
@@ -4638,5 +4640,6 @@
 	.name = "VGA8x16",
 	.width = 8,
 	.height = 16,
+	.encoding = "CP437",
 	.data = fontdata_8x16,
 };




More information about the netsurf-commits mailing list