summaryrefslogtreecommitdiff
path: root/navit/font
diff options
context:
space:
mode:
authorSebastian Leske <sebastian.leske@sleske.name>2015-10-05 08:12:57 +0200
committerSebastian Leske <sebastian.leske@sleske.name>2015-10-06 16:11:18 +0200
commit31d3cd58aa702a94d82aff5e56d5ee34690da6cd (patch)
tree213a0c275fee6e6fee9912c609d6b57e156b1bad /navit/font
parent940cfe058571e655c933b92681396b589b80a307 (diff)
downloadnavit-31d3cd58aa702a94d82aff5e56d5ee34690da6cd.tar.gz
Remove unused parameter 'depth' from get_glyph/get_shadow.R6299
The 'depth' parameter was only required for the gtk_drawing_area graphics plugin, before it was switched to use Cairo. Now all graphics drivers use depth=32, so that case is now hardcoded.
Diffstat (limited to 'navit/font')
-rw-r--r--navit/font/freetype/font_freetype.c232
-rw-r--r--navit/font/freetype/font_freetype.h20
2 files changed, 50 insertions, 202 deletions
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c
index ede39c06c..f41eff314 100644
--- a/navit/font/freetype/font_freetype.c
+++ b/navit/font/freetype/font_freetype.c
@@ -535,34 +535,19 @@ font_freetype_font_new(struct graphics_priv *gr,
/** Implementation of font_freetype_methods.get_shadow. */
static int
font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
- unsigned char *data, int depth, int stride, struct color *foreground, struct color *background)
+ unsigned char *data, int stride, struct color *foreground, struct color *background)
{
- int mask0, mask1, mask2, x, y, w = g->w, h = g->h;
+ int x, y, w = g->w, h = g->h;
unsigned int bg, fg;
unsigned char *pm, *psp,*ps,*psn;
- switch (depth) {
- case 1:
- fg=0xff;
- bg=0x00;
- break;
- case 8:
- fg=foreground->a>>COL_SHIFT;
- bg=background->a>>COL_SHIFT;
- break;
- case 24:
- case 32:
- fg=((foreground->a>>COL_SHIFT)<<24)|
- ((foreground->r>>COL_SHIFT)<<16)|
- ((foreground->g>>COL_SHIFT)<<8)|
- ((foreground->b>>COL_SHIFT)<<0);
- bg=((background->a>>COL_SHIFT)<<24)|
- ((background->r>>COL_SHIFT)<<16)|
- ((background->g>>COL_SHIFT)<<8)|
- ((background->b>>COL_SHIFT)<<0);
- break;
- default:
- return 0;
- }
+ fg=((foreground->a>>COL_SHIFT)<<24)|
+ ((foreground->r>>COL_SHIFT)<<16)|
+ ((foreground->g>>COL_SHIFT)<<8)|
+ ((foreground->b>>COL_SHIFT)<<0);
+ bg=((background->a>>COL_SHIFT)<<24)|
+ ((background->r>>COL_SHIFT)<<16)|
+ ((background->g>>COL_SHIFT)<<8)|
+ ((background->b>>COL_SHIFT)<<0);
for (y = 0; y < h+2; y++) {
if (stride) {
ps = data + stride * y;
@@ -570,25 +555,8 @@ font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
unsigned char **dataptr=(unsigned char **)data;
ps = dataptr[y];
}
- switch (depth) {
- case 1:
- memset(ps, bg, (w+9)/2);
- break;
- case 8:
- memset(ps, bg, w+2);
- break;
- case 24:
- for (x = 0 ; x < w+2 ; x++) {
- ps[x*3]=bg>>16;
- ps[x*3+1]=bg>>8;
- ps[x*3+2]=bg;
- }
- break;
- case 32:
- for (x = 0 ; x < w+2 ; x++)
- ((unsigned int *)ps)[x]=bg;
- break;
- }
+ for (x = 0 ; x < w+2 ; x++)
+ ((unsigned int *)ps)[x]=bg;
}
for (y = 0; y < h; y++) {
pm = g->pixmap + y * w;
@@ -602,94 +570,18 @@ font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
ps = dataptr[y+1];
psn = dataptr[y+2];
}
- switch (depth) {
- case 1:
- mask0 = 0x4000;
- mask1 = 0xe000;
- mask2 = 0x4000;
- for (x = 0; x < w; x++) {
- if (*pm) {
- psp[0] |= (mask0 >> 8);
- if (mask0 & 0xff)
- psp[1] |= mask0;
- ps[0] |= (mask1 >> 8);
- if (mask1 & 0xff)
- ps[1] |= mask1;
- psn[0] |= (mask2 >> 8);
- if (mask2 & 0xff)
- psn[1] |= mask2;
- }
- mask0 >>= 1;
- mask1 >>= 1;
- mask2 >>= 1;
- if (!
- ((mask0 >> 8) | (mask1 >> 8) |
- (mask2 >> 8))) {
- mask0 <<= 8;
- mask1 <<= 8;
- mask2 <<= 8;
- psp++;
- ps++;
- psn++;
- }
- pm++;
- }
- break;
- case 8:
- for (x = 0; x < w; x++) {
- if (*pm) {
- psp[1] = fg;
- ps[0] = fg;
- ps[1] = fg;
- ps[2] = fg;
- psn[1] = fg;
- }
- psp++;
- ps++;
- psn++;
- pm++;
+ for (x = 0; x < w; x++) {
+ if (*pm) {
+ ((unsigned int *)psp)[1]=fg;
+ ((unsigned int *)ps)[0]=fg;
+ ((unsigned int *)ps)[1]=fg;
+ ((unsigned int *)ps)[2]=fg;
+ ((unsigned int *)psn)[1]=fg;
}
- break;
- case 24:
- for (x = 0; x < w; x++) {
- if (*pm) {
- psp[3]=fg>>16;
- psp[4]=fg>>8;
- psp[5]=fg;
- ps[0]=fg>>16;
- ps[1]=fg>>8;
- ps[2]=fg;
- ps[3]=fg>>16;
- ps[4]=fg>>8;
- ps[5]=fg;
- ps[6]=fg>>16;
- ps[7]=fg>>8;
- ps[8]=fg;
- psn[3]=fg>>16;
- psn[4]=fg>>8;
- psn[5]=fg;
- }
- psp+=3;
- ps+=3;
- psn+=3;
- pm++;
- }
- break;
- case 32:
- for (x = 0; x < w; x++) {
- if (*pm) {
- ((unsigned int *)psp)[1]=fg;
- ((unsigned int *)ps)[0]=fg;
- ((unsigned int *)ps)[1]=fg;
- ((unsigned int *)ps)[2]=fg;
- ((unsigned int *)psn)[1]=fg;
- }
- psp+=4;
- ps+=4;
- psn+=4;
- pm++;
- }
- break;
+ psp+=4;
+ ps+=4;
+ psn+=4;
+ pm++;
}
}
return 1;
@@ -698,25 +590,15 @@ font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
/** Implementation of font_freetype_methods.get_glyph. */
static int
font_freetype_glyph_get_glyph(struct font_freetype_glyph *g,
- unsigned char *data, int depth, int stride, struct color *fg, struct color *bg, struct color *transparent)
+ unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent)
{
int x, y, w = g->w, h = g->h;
unsigned int tr;
unsigned char v,vi,*pm, *ps;
- switch (depth) {
- case 8:
- tr=transparent->a>>COL_SHIFT;
- break;
- case 24:
- case 32:
- tr=((transparent->a>>COL_SHIFT)<<24)|
- ((transparent->r>>COL_SHIFT)<<16)|
- ((transparent->g>>COL_SHIFT)<<8)|
- ((transparent->b>>COL_SHIFT)<<0);
- break;
- default:
- return 0;
- }
+ tr=((transparent->a>>COL_SHIFT)<<24)|
+ ((transparent->r>>COL_SHIFT)<<16)|
+ ((transparent->g>>COL_SHIFT)<<8)|
+ ((transparent->b>>COL_SHIFT)<<0);
for (y = 0; y < h; y++) {
pm = g->pixmap + y * w;
if (stride) {
@@ -725,51 +607,19 @@ font_freetype_glyph_get_glyph(struct font_freetype_glyph *g,
unsigned char **dataptr=(unsigned char **)data;
ps = dataptr[y];
}
- switch (depth) {
- case 8:
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v)
- *ps=fg->a;
- else
- *ps=tr;
- ps++;
- pm++;
- }
- break;
- case 24:
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v) {
- vi=255-v;
- ps[0]=(((fg->r*v+bg->r*vi)/255)>>COL_SHIFT);
- ps[1]=(((fg->g*v+bg->g*vi)/255)>>COL_SHIFT);
- ps[2]=(((fg->b*v+bg->b*vi)/255)>>COL_SHIFT);
- } else {
- ps[0]=tr >> 16;
- ps[1]=tr >> 8;
- ps[2]=tr;
- }
- ps+=3;
- pm++;
- }
- break;
- case 32:
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v) {
- vi=255-v;
- ((unsigned int *)ps)[0]=
- ((((fg->a*v+bg->a*vi)/255)>>COL_SHIFT)<<24)|
- ((((fg->r*v+bg->r*vi)/255)>>COL_SHIFT)<<16)|
- ((((fg->g*v+bg->g*vi)/255)>>COL_SHIFT)<<8)|
- ((((fg->b*v+bg->b*vi)/255)>>COL_SHIFT)<<0);
- } else
- ((unsigned int *)ps)[0]=tr;
- ps+=4;
- pm++;
- }
- break;
+ for (x = 0; x < w; x++) {
+ v=*pm;
+ if (v) {
+ vi=255-v;
+ ((unsigned int *)ps)[0]=
+ ((((fg->a*v+bg->a*vi)/255)>>COL_SHIFT)<<24)|
+ ((((fg->r*v+bg->r*vi)/255)>>COL_SHIFT)<<16)|
+ ((((fg->g*v+bg->g*vi)/255)>>COL_SHIFT)<<8)|
+ ((((fg->b*v+bg->b*vi)/255)>>COL_SHIFT)<<0);
+ } else
+ ((unsigned int *)ps)[0]=tr;
+ ps+=4;
+ pm++;
}
}
return 1;
diff --git a/navit/font/freetype/font_freetype.h b/navit/font/freetype/font_freetype.h
index d09dec59d..e4ef58bb9 100644
--- a/navit/font/freetype/font_freetype.h
+++ b/navit/font/freetype/font_freetype.h
@@ -63,39 +63,37 @@ struct font_freetype_methods {
/**
* @brief Get glyph "shadow", a glyph bitmap to be used as background.
*
- * This method returns a glyph shadow, a bitmap with the glyph, where individual glyphs have been
- * "fattened" by expanding them by one pixel on each side.
+ * This method returns a glyph shadow, a bitmap with the glyph, where the glyph has been
+ * "fattened" by expanding it by one pixel on each side.
* In Navit, the shadow is used as the background behind the glyph bitmaps (returned by
* font_freetype_methods.get_glyph() ), to make the text easier to read.
*
* @param g glyph to render, usually created via font_freetype_methods.text_new()
- * @param data buffer for result image bitmap. Size must be at least (stride * (g->h+2)).
- * @param depth bit depth for result bitmap
+ * @param data buffer for result image bitmap. Size must be at least (4 * stride * (g->h+2)).
* @param stride see font_freetype_methods.get_glyph(). Minimum: g->w+2.
* @param foreground color for rendering the "shadow"
* @param background color for rest of the bitmap (typically set to transparent)
* @returns 0 if depth is invalid, 1 otherwise
*/
int (*get_shadow) (struct font_freetype_glyph * glyph,
- unsigned char *data, int depth, int stride, struct color *fg, struct color *tr);
+ unsigned char *data, int stride, struct color *fg, struct color *tr);
/**
* @brief Get a glyph bitmap.
*
* This method returns a bitmap for rendering the supplied glyph.
*
* @param g glyph to render, usually obtained from a struct font_freetype_text created via font_freetype_methods.text_new()
- * @param data buffer for result image bitmap. Size must be at least (stride * g->h).
- * @param depth bit depth for result bitmap
+ * @param data buffer for result image bitmap. Size must be at least (4 * stride * g->h).
* @param stride stride (bytes per data row) for result bitmap; must be at least g->w, but may include padding.
* Special case:
* If set to 0, 'data' is interpreted as an array of pointers to image data rows (i.e. unsigned char**).
- * @param fg color for rendering the glyphs (depth 8 only uses alpha channel)
- * @param bg color to alpha blend with fg for semi-transparent glyph pixels (only for depth 24 & 32)
- * @param transparent color for background pixels (depth 8 only uses alpha channel)
+ * @param fg color for rendering the glyph
+ * @param bg color to alpha blend with fg for semi-transparent glyph pixels
+ * @param transparent color for background pixels
* @returns 0 if depth is invalid, 1 otherwise
*/
int (*get_glyph) (struct font_freetype_glyph * glyph,
- unsigned char *data, int depth, int stride,
+ unsigned char *data, int stride,
struct color * fg, struct color * bg, struct color *tr);
};