Author: vince
Date: Thu Feb 26 15:37:22 2009
New Revision: 6644
URL:
http://source.netsurf-browser.org?rev=6644&view=rev
Log:
try and improve plotter perfomance futher
Modified:
trunk/netsurf/framebuffer/fb_16bpp_plotters.c
trunk/netsurf/framebuffer/fb_32bpp_plotters.c
trunk/netsurf/framebuffer/fb_plotters.c
trunk/netsurf/framebuffer/fb_plotters.h
Modified: trunk/netsurf/framebuffer/fb_16bpp_plotters.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_16bpp_plot...
==============================================================================
--- trunk/netsurf/framebuffer/fb_16bpp_plotters.c (original)
+++ trunk/netsurf/framebuffer/fb_16bpp_plotters.c Thu Feb 26 15:37:22 2009
@@ -45,6 +45,12 @@
((pixel & 0xF800) >> 8);
}
+/* convert a colour value to a 16bpp pixel value ready for screen output */
+static inline uint16_t fb_colour_to_pixel(colour c)
+{
+ return ((c & 0xF8) << 8) | ((c & 0xFC00 ) >> 5) | ((c &
0xF80000) >> 19);
+}
+
#define SIGN(x) ((x<0) ? -1 : ((x>0) ? 1 : 0))
static bool fb_16bpp_line(int x0, int y0, int x1, int y1, int width,
@@ -66,9 +72,7 @@
if (y0 < fb_plot_ctx.y0)
return true;
- ent = ((c & 0xF8) << 8) |
- ((c & 0xFC00 ) >> 5) |
- ((c & 0xF80000) >> 19);
+ ent = fb_colour_to_pixel(c);
if (y0 == y1) {
/* horizontal line special cased */
@@ -162,25 +166,25 @@
static bool fb_16bpp_fill(int x0, int y0, int x1, int y1, colour c)
{
int w;
- int y;
+ uint16_t *pvid;
uint16_t ent;
- uint16_t *pvideo;
+ uint32_t llen;
+ uint32_t width;
+ uint32_t height;
if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
return true; /* fill lies outside current clipping region */
- ent = ((c & 0xF8) << 8) |
- ((c & 0xFC00 ) >> 5) |
- ((c & 0xF80000) >> 19);
-
- pvideo = fb_16bpp_get_xy_loc(x0, y0);
-
- for (y = y0; y < y1; y++) {
- w = x1 - x0;
- while (w-- > 0) {
- *(pvideo + w) = ent;
- }
- pvideo += (framebuffer->linelen >> 1);
+ ent = fb_colour_to_pixel(c);
+ width = x1 - x0;
+ height = y1 - y0;
+ llen = (framebuffer->linelen >> 1) - width;
+
+ pvid = fb_16bpp_get_xy_loc(x0, y0);
+
+ while (height-- > 0) {
+ for (w = width; w > 0; w--) *pvid++ = ent;
+ pvid += llen;
}
return true;
@@ -252,10 +256,7 @@
fb_16bpp_to_colour(*(pvideo + xloop)));
}
- *(pvideo + xloop) =
- ((abpixel & 0xF8) << 8) |
- ((abpixel & 0xFC00 ) >> 5) |
- ((abpixel & 0xF80000) >> 19);
+ *(pvideo + xloop) = fb_colour_to_pixel(abpixel);
}
}
@@ -351,14 +352,9 @@
xoff = x0 - x;
yoff = y0 - y;
- fgcol = ((c & 0xF8) << 8) |
- ((c & 0xFC00 ) >> 5) |
- ((c & 0xF80000) >> 19);
-
- bgcol = ((bg & 0xF8) << 8) |
- ((bg & 0xFC00 ) >> 5) |
- ((bg & 0xF80000) >> 19);
-
+ fgcol = fb_colour_to_pixel(c);
+
+ bgcol = fb_colour_to_pixel(bg);
/*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));*/
@@ -463,11 +459,7 @@
fb_16bpp_to_colour(*(pvideo + xloop)));
}
- *(pvideo + xloop) =
- ((abpixel & 0xF8) << 8) |
- ((abpixel & 0xFC00 ) >> 5) |
- ((abpixel & 0xF80000) >> 19);
-
+ *(pvideo + xloop) = fb_colour_to_pixel(abpixel);
}
}
pvideo += (framebuffer->linelen >> 1);
Modified: trunk/netsurf/framebuffer/fb_32bpp_plotters.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_32bpp_plot...
==============================================================================
--- trunk/netsurf/framebuffer/fb_32bpp_plotters.c (original)
+++ trunk/netsurf/framebuffer/fb_32bpp_plotters.c Thu Feb 26 15:37:22 2009
@@ -174,7 +174,6 @@
static bool fb_32bpp_fill(int x0, int y0, int x1, int y1, colour c)
{
int w;
- uint32_t *pvid_line;
uint32_t *pvid;
uint32_t ent;
uint32_t llen;
@@ -185,18 +184,15 @@
return true; /* fill lies outside current clipping region */
ent = fb_colour_to_pixel(c);
- llen = (framebuffer->linelen >> 2);
width = x1 - x0;
height = y1 - y0;
-
- pvid_line = fb_32bpp_get_xy_loc(x0, y0);
-
- while (height > 0) {
- height--;
- pvid = pvid_line;
- pvid_line += llen;
- w = width;
- while (w-- > 0) *pvid++ = ent;
+ llen = (framebuffer->linelen >> 2) - width;
+
+ pvid = fb_32bpp_get_xy_loc(x0, y0);
+
+ while (height-- > 0) {
+ for (w = width; w > 0; w--) *pvid++ = ent;
+ pvid += llen;
}
return true;
Modified: trunk/netsurf/framebuffer/fb_plotters.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_plotters.c...
==============================================================================
--- trunk/netsurf/framebuffer/fb_plotters.c (original)
+++ trunk/netsurf/framebuffer/fb_plotters.c Thu Feb 26 15:37:22 2009
@@ -210,23 +210,6 @@
return true;
}
-colour fb_plotters_ablend(colour pixel, colour scrpixel)
-{
- int opacity = (pixel >> 24) & 0xFF;
- int r,g,b;
-
- r = (((pixel & 0xFF) * opacity) >> 8) +
- (((scrpixel & 0xFF) * (0xFF - opacity)) >> 8);
-
- g = ((((pixel & 0xFF00) >> 8) * opacity) >> 8) +
- ((((scrpixel & 0xFF00) >> 8) * (0xFF - opacity)) >> 8);
-
- b = ((((pixel & 0xFF0000) >> 16) * opacity) >> 8) +
- ((((scrpixel & 0xFF0000) >> 16) * (0xFF - opacity)) >> 8);
-
- return r | (g << 8) | (b << 16);
-}
-
typedef bool (linefn_t)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted,
bool dashed);
typedef struct dcPt_s {
Modified: trunk/netsurf/framebuffer/fb_plotters.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/framebuffer/fb_plotters.h...
==============================================================================
--- trunk/netsurf/framebuffer/fb_plotters.h (original)
+++ trunk/netsurf/framebuffer/fb_plotters.h Thu Feb 26 15:37:22 2009
@@ -47,7 +47,24 @@
colour bg,
struct content *content));
-colour fb_plotters_ablend(colour pixel, colour scrpixel);
+/* alpha blend two pixels together */
+static inline colour fb_plotters_ablend(colour pixel, colour scrpixel)
+{
+ int opacity = (pixel >> 24) & 0xFF;
+ int r,g,b;
+
+ r = (((pixel & 0xFF) * opacity) >> 8) +
+ (((scrpixel & 0xFF) * (0xFF - opacity)) >> 8);
+
+ g = ((((pixel & 0xFF00) >> 8) * opacity) >> 8) +
+ ((((scrpixel & 0xFF00) >> 8) * (0xFF - opacity)) >> 8);
+
+ b = ((((pixel & 0xFF0000) >> 16) * opacity) >> 8) +
+ ((((scrpixel & 0xFF0000) >> 16) * (0xFF - opacity)) >> 8);
+
+ return r | (g << 8) | (b << 16);
+}
+
bool fb_plotters_move_block(int srcx, int srcy, int width, int height, int dstx, int
dsty);