r5351 vince - in /branches/vince/netsurf-fb/framebuffer: fb_16bpp_plotters.c fb_1bpp_plotters.c fb_32bpp_plotters.c fb_8bpp_plotters.c fb_gui.c fb_gui.h fb_init_able.c fb_init_linux.c fb_plotters.c fb_plotters.h fb_schedule.c

netsurf at semichrome.net netsurf at semichrome.net
Tue Sep 16 17:17:09 BST 2008


Author: vince
Date: Tue Sep 16 11:17:09 2008
New Revision: 5351

URL: http://source.netsurf-browser.org?rev=5351&view=rev
Log:
framebuffer scheduler now works, plotters tweaked, gui tracks window redraw requirements better, keypresses not duplicated under linux fb

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_1bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_8bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_gui.c
    branches/vince/netsurf-fb/framebuffer/fb_gui.h
    branches/vince/netsurf-fb/framebuffer/fb_init_able.c
    branches/vince/netsurf-fb/framebuffer/fb_init_linux.c
    branches/vince/netsurf-fb/framebuffer/fb_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_plotters.h
    branches/vince/netsurf-fb/framebuffer/fb_schedule.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=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c Tue Sep 16 11:17:09 2008
@@ -17,17 +17,18 @@
  */
 
 #include <sys/types.h>
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
 #include "utils/log.h"
-
+#include "utils/utf8.h"
+#include "desktop/plotters.h"
+
+#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
-#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_bitmap.h"
 #include "framebuffer/fb_font.h"
-
-#include "utils/utf8.h"
 
 
 extern framebuffer_t *framebuffer;

Modified: branches/vince/netsurf-fb/framebuffer/fb_1bpp_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_1bpp_plotters.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_1bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_1bpp_plotters.c Tue Sep 16 11:17:09 2008
@@ -17,15 +17,18 @@
  */
 
 #include <sys/types.h>
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "desktop/plotters.h"
+
+#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
-#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_bitmap.h"
 #include "framebuffer/fb_font.h"
-
-#include "utils/log.h"
 
 extern struct fb_info_s *fbinfo;
 

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=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_32bpp_plotters.c Tue Sep 16 11:17:09 2008
@@ -17,15 +17,18 @@
  */
 
 #include <sys/types.h>
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "desktop/plotters.h"
+
+#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
-#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_bitmap.h"
 #include "framebuffer/fb_font.h"
-
-#include "utils/log.h"
 
 extern framebuffer_t *framebuffer;
 extern struct gui_window *current_window;

Modified: branches/vince/netsurf-fb/framebuffer/fb_8bpp_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_8bpp_plotters.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_8bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_8bpp_plotters.c Tue Sep 16 11:17:09 2008
@@ -17,15 +17,18 @@
  */
 
 #include <sys/types.h>
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "desktop/plotters.h"
+
+#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
-#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_bitmap.h"
 #include "framebuffer/fb_font.h"
-
-#include "utils/log.h"
 
 extern framebuffer_t *framebuffer;
 extern struct gui_window *current_window;

Modified: branches/vince/netsurf-fb/framebuffer/fb_gui.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_gui.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_gui.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_gui.c Tue Sep 16 11:17:09 2008
@@ -23,6 +23,7 @@
 #include <unistd.h>
 
 #include "desktop/gui.h"
+#include "desktop/plotters.h"
 #include "desktop/netsurf.h"
 #include "desktop/options.h"
 #include "utils/messages.h"
@@ -36,8 +37,11 @@
 
 char *default_stylesheet_url;
 char *adblock_stylesheet_url;
-struct gui_window *current_window;
+struct gui_window *input_window = NULL;
 struct gui_window *search_current_window;
+struct gui_window *window_list = NULL;
+
+bool redraws_pending = false;
 
 framebuffer_t *framebuffer;
 
@@ -48,24 +52,23 @@
 static void fb_redraw(struct gui_window *g)
 {
 	struct content *c;
-        int width, height;
-        int vertical;
+
+        if (!g)
+                return;
 
 	c = g->bw->current_content;
 
-	if(!c) return;
+	if (!c) return;
 	if (c->locked) return;
 
-        width = g->width;
-        height = g->height;
-        vertical = g->scrolly;
-
-        content_redraw(c, 0, -vertical, width, height,
-                       0, 0, width,height,
+        content_redraw(c, 0, -g->scrolly, g->width, g->height,
+                       g->redraw_box.x0, g->redraw_box.y0, g->redraw_box.x1, g->redraw_box.y1,
                        g->bw->scale, 0xFFFFFF);
 
 	g->redraw_required = false;
-
+        g->redraw_box.y0 = g->redraw_box.x0 = INT_MAX;
+        g->redraw_box.y1 = g->redraw_box.x1 = -(INT_MAX);
+        redraws_pending = false;
 }
 
 
@@ -139,10 +142,19 @@
     //LOG(("enter schedule run"));
     schedule_run();
 
-    fb_os_input(current_window);
-
-    if (current_window && current_window->redraw_required)
-            fb_redraw(current_window);
+    fb_os_input(input_window);
+
+    if (redraws_pending == true) {
+            struct gui_window *g;
+            
+            redraws_pending = false;
+
+            for (g = window_list; g != NULL; g = g->next) {
+                    if (g->redraw_required == true) {
+                            fb_redraw(g);
+                    }
+            }
+    }
 
 }
 
@@ -157,7 +169,7 @@
                                              struct browser_window *clone,
                                              bool new_tab)
 {
-        struct gui_window *g;
+        struct gui_window *g, *p;
         LOG(("bw %p, clone %p", bw, clone));
 
         g = calloc(1, sizeof(struct gui_window));
@@ -170,13 +182,35 @@
         g->height = framebuffer->height;
         g->bw = bw;
 
+        if (window_list == NULL) {
+                window_list = input_window = g;
+        } else {
+                for(p = window_list; p->next != NULL; p = p->next);
+                p->next = g;
+                g->prev = p;
+        }
+
         return g;
 }
 
 void gui_window_destroy(struct gui_window *g)
 {
-        LOG(("%s(%p)", __func__, g));
-        netsurf_quit = true;
+        struct gui_window *p;
+        LOG(("g %p", g));
+        
+        if (g->prev == NULL) {
+                window_list = input_window = g->next;
+        } else {
+                g->prev->next = g->next;
+        }
+        if (g->next != NULL)
+                g->next->prev = g->prev;
+
+        free(g);
+
+
+        if (window_list == NULL)
+                netsurf_quit = true;
 
 }
 
@@ -185,25 +219,55 @@
         LOG(("%s(%p, %s)", __func__, g, title));
 }
 
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+static void fb_queue_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
+{
+	if (!g) return;
+
+        LOG(("%p, %d, %d, %d, %d", g, x0 , y0, x1, y1));
+
+        g->redraw_box.x0 = MIN(g->redraw_box.x0, x0);
+        g->redraw_box.y0 = MIN(g->redraw_box.y0, y0);
+        g->redraw_box.x1 = MAX(g->redraw_box.x1, x1);
+        g->redraw_box.y1 = MAX(g->redraw_box.y1, y1);
+
+        redraws_pending = true;
+	g->redraw_required = true;
+}
+
 void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
 {
-        LOG(("%s(%p, %d, %d, %d, %d)", __func__, g, x0 , y0, x1, y1));
+	if (!g) return;
+
+        fb_queue_redraw(g, x0, y0, x1, y1);
 }
 
 void gui_window_redraw_window(struct gui_window *g)
 {
-        LOG(("%s(%p)", __func__, g));
-
 	if (!g) return;
 
-        current_window = g;
-	g->redraw_required = true;
+        fb_queue_redraw(g, 0, 0, g->width, g->height);
 }
 
 void gui_window_update_box(struct gui_window *g,
 		const union content_msg_data *data)
 {
-        LOG(("%s(%p, %p)", __func__, g, data));
+	struct content *c;
+
+	if (!g) return;
+
+        c = g->bw->current_content;
+
+	if (c == NULL) return;
+
+        gui_window_redraw(g, data->redraw.x, data->redraw.y, data->redraw.x + data->redraw.width, data->redraw.y + data->redraw.height);
 }
 
 bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)

Modified: branches/vince/netsurf-fb/framebuffer/fb_gui.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_gui.h?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_gui.h (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_gui.h Tue Sep 16 11:17:09 2008
@@ -16,6 +16,14 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/* bounding box */
+typedef struct bbox_s {
+        int x0;
+        int y0;
+        int x1;
+        int y1;
+} bbox_t;
+
 typedef struct {
     int width;
     int height;
@@ -31,9 +39,12 @@
     int width; /**< Window width */
     int height; /**< window height */
 
+    bbox_t redraw_box;
     int scrolly; /**< y scroll offset */
     bool redraw_required; /**< flag indicating the foreground loop needs to redraw the window */
     struct browser_window *bw; /* The browser window connected to this gui window */
+
+    struct gui_window *next, *prev;
 };
 
 extern framebuffer_t *fb_os_init(int argc, char** argv);

Modified: branches/vince/netsurf-fb/framebuffer/fb_init_able.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_init_able.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_init_able.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_init_able.c Tue Sep 16 11:17:09 2008
@@ -81,14 +81,14 @@
 
         if (amt > 0) {
                 if (key == 'j') {
-                        g->redraw_required = true;
                         g->scrolly +=100;
+                        gui_window_redraw_window(g);
                 }
                 if (key == 'k') {
-                        g->redraw_required = true;
                         g->scrolly -=100;
                         if (g->scrolly < 0)
                                 g->scrolly = 0;
+                        gui_window_redraw_window(g);
                 }
                 if (key == 'q') {
                         browser_window_destroy(g->bw);

Modified: branches/vince/netsurf-fb/framebuffer/fb_init_linux.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_init_linux.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_init_linux.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_init_linux.c Tue Sep 16 11:17:09 2008
@@ -553,17 +553,20 @@
                 if (event.type != EV_KEY)
                         return;
 
+                if (event.value == 0)
+                        return;
+
                 switch (event.code) {
                 case KEY_J:
-                        g->redraw_required = true;
                         g->scrolly +=100;
+                        gui_window_redraw_window(g);
                         break;
 
                 case KEY_K:
-                        g->redraw_required = true;
                         g->scrolly -=100;
                         if (g->scrolly < 0)
                                 g->scrolly = 0;
+                        gui_window_redraw_window(g);
                         break;
 
                 case KEY_Q:

Modified: branches/vince/netsurf-fb/framebuffer/fb_plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_plotters.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_plotters.c Tue Sep 16 11:17:09 2008
@@ -17,14 +17,16 @@
  */
 
 #include <sys/types.h>
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
+#include "utils/log.h"
 #include "utils/utf8.h"
-#include "utils/log.h"
-
+#include "desktop/plotters.h"
+
+#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
-#include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_bitmap.h"
 #include "framebuffer/fb_font.h"
 
@@ -191,7 +193,7 @@
 fb_plotters_polygon(int *p, unsigned int n, colour fill,bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed))
 {
         unsigned int pnt;
-        int *cur;
+        int *cur = p;
         
         for (pnt = 1; pnt < n; pnt++) {
                 cur = p + (pnt << 1);

Modified: branches/vince/netsurf-fb/framebuffer/fb_plotters.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_plotters.h?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_plotters.h (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_plotters.h Tue Sep 16 11:17:09 2008
@@ -18,15 +18,6 @@
 
 #ifndef FRAMEBUFFER_PLOTTERS_H
 #define FRAMEBUFFER_PLOTTERS_H
-#include "desktop/plotters.h"
-
-/* framebuffer bounding box */
-typedef struct bbox_s {
-        int x0;
-        int y0;
-        int x1;
-        int y1;
-} bbox_t;
 
 extern const struct plotter_table framebuffer_1bpp_plot;
 extern const struct plotter_table framebuffer_8bpp_plot;

Modified: branches/vince/netsurf-fb/framebuffer/fb_schedule.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_schedule.c?rev=5351&r1=5350&r2=5351&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_schedule.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_schedule.c Tue Sep 16 11:17:09 2008
@@ -62,7 +62,7 @@
 
 	nscb = calloc(1, sizeof(struct nscallback));
 
-	gettimeofday(&tv, NULL);
+	gettimeofday(&nscb->tv, NULL);
 	timeradd(&nscb->tv, &tv, &nscb->tv);
 
 	nscb->callback = callback;
@@ -141,15 +141,12 @@
 
 	gettimeofday(&tv, NULL);
 
+        LOG(("Banana"));
+
         while (cur_nscb != NULL) {
                 if (timercmp(&tv, &cur_nscb->tv, >)) {
                         /* scheduled time */
                         
-                        LOG(("calling %p with %p",
-                             cur_nscb->callback, cur_nscb->p)); 
-                        /* call callback */
-                        cur_nscb->callback(cur_nscb->p);
-
                         /* remove callback */
                         unlnk_nscb = cur_nscb;
                         cur_nscb = unlnk_nscb->next;
@@ -159,6 +156,12 @@
                         } else {
                                 prev_nscb->next = cur_nscb;
                         }
+
+                        LOG(("calling %p with %p",
+                             unlnk_nscb->callback, unlnk_nscb->p)); 
+                        /* call callback */
+                        unlnk_nscb->callback(unlnk_nscb->p);
+
                         free (unlnk_nscb);
                 } else {
                         /* move to next element */




More information about the netsurf-commits mailing list