r5388 vince - in /branches/vince/netsurf-fb/framebuffer: fb_16bpp_plotters.c fb_cursor.c

netsurf at semichrome.net netsurf at semichrome.net
Sun Sep 21 16:24:19 BST 2008


Author: vince
Date: Sun Sep 21 10:24:18 2008
New Revision: 5388

URL: http://source.netsurf-browser.org?rev=5388&view=rev
Log:
improve vertical text clipping

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c
    branches/vince/netsurf-fb/framebuffer/fb_cursor.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=5388&r1=5387&r2=5388&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_16bpp_plotters.c Sun Sep 21 10:24:18 2008
@@ -210,26 +210,42 @@
         uint16_t bgcol;
 
 	char *buffer = NULL;
+        int x0,y0,x1,y1;
+	int xoff, yoff; /* x and y offset into image */
+        int width, height;
+
+        /* aquire thge text in local font encoding */
+	utf8_to_font_encoding(fb_font, 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);
 
         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 
-              */
-
-        if (y + fb_font->height > fb_plot_ctx.y1)
-                return true;
-
-        if (y < fb_plot_ctx.y0)
-                return true;
-
-	utf8_to_local_encoding(text, length, &buffer);
-	if (!buffer) 
-                return true;
-
-        length = strlen(buffer);
-
+               *   it work since fb coords are the top-left of pixels 
+               */
+
+        /* The part of the text displayed is cropped to the current context. */
+        x0 = x;
+        y0 = y;
+        x1 = x + (fb_font->width * length);
+        y1 = y + fb_font->height;
+
+        if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
+                return true; /* text lies outside current clipping region */
+
+        /* find width and height to plot */
+        if (height > (y1 - y0))
+                height = (y1 - y0);
+
+        if (width > (x1 - x0))
+                width = (x1 - x0);
+
+	xoff = x0 - x;
+	yoff = y0 - y;
 
         fgcol = ((c & 0xF8) << 8) |
               ((c & 0xFC00 ) >> 5) |
@@ -244,19 +260,19 @@
           x,y,style,length,text,length,bg,c));*/
 
         for (chr = 0; chr < length; chr++, x += fb_font->width) {
-                if ((x + fb_font->width) > fb_plot_ctx.x1)
+                if ((x + fb_font->width) > x1)
                         break;
 
-                if (x < fb_plot_ctx.x0) 
+                if (x < x0) 
                         continue;
 
-                pvideo = fb_16bpp_get_xy_loc(x, y);
+                pvideo = fb_16bpp_get_xy_loc(x, y0);
 
                 /* move our font-data to the correct position */
                 font_data = fb_font->data + (buffer[chr] * fb_font->height);
 
-                for (yloop = 0; yloop < fb_font->height; yloop++) {
-                        row = font_data[yloop];
+                for (yloop = 0; yloop < height; yloop++) {
+                        row = font_data[yoff + yloop];
                         for (xloop = fb_font->width; xloop > 0 ; xloop--) {
                                 if ((row & 1) != 0)
                                         *(pvideo + xloop) = fgcol;

Modified: branches/vince/netsurf-fb/framebuffer/fb_cursor.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_cursor.c?rev=5388&r1=5387&r2=5388&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_cursor.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_cursor.c Sun Sep 21 10:24:18 2008
@@ -82,8 +82,8 @@
         int yloop;
         int height = fb->cursor->height;
 
-        if ((fb->height - fb->cursor->y - 1) < height)
-                height = (fb->height - fb->cursor->y - 1);
+        if ((fb->height - fb->cursor->y) < height)
+                height = fb->height - fb->cursor->y;
 
         if (height == 0) {
                 if (fb->cursor->savedata != NULL)
@@ -121,8 +121,8 @@
         int yloop;
         int height = fb->cursor->height;
 
-        if ((fb->height - fb->cursor->y - 1) < height)
-                height = (fb->height - fb->cursor->y - 1);
+        if ((fb->height - fb->cursor->y) < height)
+                height = fb->height - fb->cursor->y ;
 
         if (height == 0)
                 return;




More information about the netsurf-commits mailing list