summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
-rw-r--r--HISTORY4
-rw-r--r--font.c22
3 files changed, 20 insertions, 7 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 8565c331..aa74d116 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -1782,6 +1782,7 @@ Martin Wache <M.Wache@gmx.net>
for adding a sleep in cDvbPlayer::Action() in case there is no data to send to the
device, which avoids a busy loop on very fast machines
for fixing a possible crash when loading an invalid XPM file
+ for suggesting to speed up anti-aliased font rendering by caching the blend indexes
Matthias Lenk <matthias.lenk@amd.com>
for reporting an out-of-bounds memory access with audio language ids
diff --git a/HISTORY b/HISTORY
index 9af72e8e..c63bc66d 100644
--- a/HISTORY
+++ b/HISTORY
@@ -5579,7 +5579,7 @@ Video Disk Recorder Revision History
is not available, in order to allow staying on an encrypted channel that takes
a while for the CAM to start decrypting.
-2008-02-08: Version 1.5.15
+2008-02-09: Version 1.5.15
- Updated the Italian OSD texts (thanks to Diego Pierotto).
- Added option -i to the pictures plugin's pic2mpg to ignore unknown file types.
@@ -5591,3 +5591,5 @@ Video Disk Recorder Revision History
file if you have already used version 1.5.14, because it introduced new parameters.
- Added the new command line option --userdump to enable core dumps in case VDR
is run as root with option -u (thanks to Hans-Werner Hilse).
+- Speeded up anti-aliased font rendering by caching the blend indexes (based on
+ a suggestion by Martin Wache).
diff --git a/font.c b/font.c
index 73b77fbb..2f14d14f 100644
--- a/font.c
+++ b/font.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: font.c 1.22 2007/11/04 11:08:12 kls Exp $
+ * $Id: font.c 1.23 2008/02/09 11:52:25 kls Exp $
*/
#include "font.h"
@@ -241,10 +241,16 @@ int cFreetypeFont::Width(const char *s) const
return w;
}
+#define MAX_BLEND_LEVELS 256
+
void cFreetypeFont::DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
{
if (s && height) { // checking height to make sure we actually have a valid font
bool AntiAliased = Setup.AntiAlias && Bitmap->Bpp() >= 8;
+ bool TransparentBackground = ColorBg == clrTransparent;
+ int16_t BlendLevelIndex[MAX_BLEND_LEVELS]; // tIndex is 8 bit unsigned, so a negative value can be used to mark unused entries
+ if (AntiAliased && !TransparentBackground)
+ memset(BlendLevelIndex, 0xFF, sizeof(BlendLevelIndex)); // initializes the array with negative values
tIndex fg = Bitmap->Index(ColorFg);
uint prevSym = 0;
while (*s) {
@@ -266,12 +272,16 @@ void cFreetypeFont::DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColo
if (bt > 0x00) {
int px = x + pitch + g->Left() + kerning;
int py = y + row + (height - Bottom() - g->Top());
+ tColor bg;
if (bt == 0xFF)
- Bitmap->SetIndex(px, py, fg);
- else {
- tColor bg = (ColorBg != clrTransparent) ? ColorBg : Bitmap->GetColor(px, py);
- Bitmap->SetIndex(px, py, Bitmap->Index(Bitmap->Blend(ColorFg, bg, bt)));
- }
+ bg = fg;
+ else if (TransparentBackground)
+ bg = Bitmap->Index(Bitmap->Blend(ColorFg, Bitmap->GetColor(px, py), bt));
+ else if (BlendLevelIndex[bt] >= 0)
+ bg = BlendLevelIndex[bt];
+ else
+ bg = BlendLevelIndex[bt] = Bitmap->Index(Bitmap->Blend(ColorFg, ColorBg, bt));
+ Bitmap->SetIndex(px, py, bg);
}
}
else { //monochrome rendering