summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-07-27 09:53:43 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2012-07-27 09:53:43 (GMT)
commit198e8c2e38c9e7bbc85e61a80217c323819e8597 (patch)
tree1ed88f39b50cf69649823e3ff71cbbaf9c01e9c6
parentbabd30a2b471d1177895327fd555175ca04017a0 (diff)
downloadlibnsfb-198e8c2e38c9e7bbc85e61a80217c323819e8597.tar.gz
libnsfb-198e8c2e38c9e7bbc85e61a80217c323819e8597.tar.bz2
Fix horizontal scroll of internal text. Simplify and optimise internal text renderer.
-rw-r--r--src/plot/common.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/plot/common.c b/src/plot/common.c
index 5a83942..185e323 100644
--- a/src/plot/common.c
+++ b/src/plot/common.c
@@ -138,15 +138,17 @@ glyph1(nsfb_t *nsfb,
nsfb_colour_t c)
{
PLOT_TYPE *pvideo;
+ PLOT_TYPE const *pvideo_limit;
PLOT_TYPE fgcol;
- int xloop, yloop;
+ int xloop;
int xoff, yoff; /* x and y offset into image */
int x = loc->x0;
int y = loc->y0;
int width;
int height;
- const uint8_t *fntd;
- uint8_t row;
+ const size_t line_len = PLOT_LINELEN(nsfb->linelen);
+ const int first_col = 1 << (loc->x1 - loc->x0 - 1);
+ const uint8_t *row;
if (!nsfb_plot_clip_ctx(nsfb, loc))
return true;
@@ -157,26 +159,22 @@ glyph1(nsfb_t *nsfb,
xoff = loc->x0 - x;
yoff = loc->y0 - y;
- pvideo = get_xy_loc(nsfb, loc->x0, loc->y0);
-
fgcol = colour_to_pixel(nsfb, c);
- for (yloop = yoff; yloop < height; yloop++) {
- fntd = pixel + (yloop * (pitch>>3)) + (xoff>>3);
- row = (*fntd++) << (xoff & 3);
- for (xloop = xoff; xloop < width ; xloop++) {
- if (((xloop % 8) == 0) && (xloop != 0)) {
- row = *fntd++;
- }
+ pitch >>= 3; /* bits to bytes */
+
+ pvideo = get_xy_loc(nsfb, x, loc->y0);
+ pvideo_limit = pvideo + line_len * (height - yoff);
+ row = pixel + yoff * pitch;
- if ((row & 0x80) != 0) {
+ for (; pvideo < pvideo_limit; pvideo += line_len) {
+ for (xloop = xoff; xloop < width; xloop++) {
+
+ if ((*row & (first_col >> xloop)) != 0) {
*(pvideo + xloop) = fgcol;
}
- row = row << 1;
-
}
-
- pvideo += PLOT_LINELEN(nsfb->linelen);
+ row += pitch;
}
return true;