summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-08-01 23:05:03 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-08-01 23:05:03 +0100
commitc0548fc472ac2c8e8bbc9e6254ee785f69cfadf2 (patch)
tree49b9192d84503ed40b758fe32fe6aa63ec832e09
parent8945e314c895cadf892bb3fcb27c27ec42c0aa85 (diff)
downloadnetsurf-c0548fc472ac2c8e8bbc9e6254ee785f69cfadf2.tar.gz
netsurf-c0548fc472ac2c8e8bbc9e6254ee785f69cfadf2.tar.bz2
Optimise glyph scaling.
-rw-r--r--framebuffer/font_internal.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/framebuffer/font_internal.c b/framebuffer/font_internal.c
index 492e37790..9028027ee 100644
--- a/framebuffer/font_internal.c
+++ b/framebuffer/font_internal.c
@@ -221,34 +221,26 @@ fb_get_font_size(const plot_font_style_t *fstyle)
return size;
}
+/** Lookup table to scale 4 bits to 8 bits, so e.g. 0101 --> 00110011 */
+const uint8_t glyph_lut[16] = {
+ 0x00, 0x03, 0x0c, 0x0f,
+ 0x30, 0x33, 0x3c, 0x3f,
+ 0xc0, 0xc3, 0xcc, 0xcf,
+ 0xf0, 0xf3, 0xfc, 0xff
+};
+
static const uint8_t *
glyph_scale_2(const uint8_t *glyph_data)
{
- int y, x;
+ const uint8_t *glyph_max = glyph_data + GLYPH_LEN;
uint8_t *pos = glyph_x2;
- for (y = 0; y < 16; y++) {
- *pos = 0;
- for (x = 0; x < 4; x++) {
- if (glyph_data[y] & (1 << (7 - x))) {
- *pos |= 1 << ((3 - x) * 2);
- *pos |= 1 << ((3 - x) * 2 + 1);
- }
- }
- pos++;
- *pos = 0;
- for (x = 4; x < 8; x++) {
- if (glyph_data[y] & (1 << (7 - x))) {
- *pos |= 1 << ((7 - x) * 2);
- *pos |= 1 << ((7 - x) * 2 + 1);
- }
- }
- pos++;
- *pos = *(pos - 2);
- pos++;
- *pos = *(pos - 2);
- pos++;
- }
+ do {
+ *pos++ = glyph_lut[*glyph_data >> 4];
+ *pos++ = glyph_lut[*glyph_data & 0xf];
+ *pos++ = glyph_lut[*glyph_data >> 4];
+ *pos++ = glyph_lut[*glyph_data & 0xf];
+ } while (++glyph_data < glyph_max);
return glyph_x2;
}