--- a/fontservices/fontstore/inc/OPENFONT.H Wed Sep 15 14:10:32 2010 +0300
+++ b/fontservices/fontstore/inc/OPENFONT.H Wed Oct 13 16:35:09 2010 +0300
@@ -327,7 +327,7 @@
TBool HasCharacterL(TInt aCode) const;
TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const;
void OnFileDeleted();
- COpenFontGlyphCache* GetGlyphCache() const;
+ COpenFontGlyphCache* GetGlyphCache();
inline TInt FontCapitalAscent() const;
inline TInt FontMaxAscent() const;
inline TInt FontStandardDescent() const;
@@ -368,7 +368,7 @@
private:
const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
- const COpenFontGlyph* FontCacheGlyph(TInt aCode) const;
+ const COpenFontGlyph* FontCacheGlyph(TInt aCode);
void SetGlyphCache(COpenFontGlyphCache* aGlyphCache);
--- a/fontservices/fontstore/inc/openfontsprivate.h Wed Sep 15 14:10:32 2010 +0300
+++ b/fontservices/fontstore/inc/openfontsprivate.h Wed Oct 13 16:35:09 2010 +0300
@@ -133,6 +133,8 @@
private:
inline COpenFontSessionCacheEntry(const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics);
~COpenFontSessionCacheEntry();
+public:
+ TInt iLastAccess; // serial number of the last access to the glyph
private:
TInt iFontOffset; // offset of the font that contains this glyph, (not owned by this class!)
@@ -146,21 +148,20 @@
*/
class COpenFontSessionCache
{
- friend class COpenFontSessionCacheList;
public:
static COpenFontSessionCache* NewL(RHeap* aHeap, TInt aSessionHandle, TInt aEntries);
void Delete(RHeap* aHeap);
TInt SessionHandle() { return iSessionHandle; }
- const COpenFontGlyph* Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex) const;
+ const COpenFontGlyph* Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex);
void Insert(RHeap* aHeap, COpenFontSessionCacheEntry* aEntry, TInt aIndex);
private:
COpenFontSessionCache(TInt aSessionHandle);
~COpenFontSessionCache();
-private:
- TInt iSessionHandle;
- TInt64 iRandomSeed;
+public:
+ TInt iSessionHandle;
+ TInt iLastAccess;
ROffsetArray<COpenFontSessionCacheEntry> iEntryArray;
};
--- a/fontservices/fontstore/src/OPENFONT.CPP Wed Sep 15 14:10:32 2010 +0300
+++ b/fontservices/fontstore/src/OPENFONT.CPP Wed Oct 13 16:35:09 2010 +0300
@@ -26,7 +26,6 @@
#include "linkedfontsprivate.h"
#include <graphics/openfontrasterizer.h>
#include <graphics/gdi/glyphsample.h>
-#include <e32math.h>
const TInt KSessionCacheEntries = 512;
const TInt KDefaultSlantFactor = 20480;
@@ -849,13 +848,13 @@
iFileOffset = 0;
}
-COpenFontGlyphCache* COpenFont::GetGlyphCache() const
+COpenFontGlyphCache* COpenFont::GetGlyphCache()
{
if (iGlyphCacheOffset == 0)
{
return NULL;
}
- return reinterpret_cast<COpenFontGlyphCache*>(PtrAdd(const_cast<COpenFont*>(this), iGlyphCacheOffset));
+ return reinterpret_cast<COpenFontGlyphCache*>(PtrAdd(this, iGlyphCacheOffset));
}
const COpenFontGlyph* COpenFont::Glyph(TInt aSessionHandle, TInt aCode) const
@@ -894,7 +893,7 @@
@param aCode The code for the glpyh to look for in the cache
@return A pointer to the requested glyph if it was found in the glyph cache, NULL if it was not found.
*/
-const COpenFontGlyph* COpenFont::FontCacheGlyph(TInt aCode) const
+const COpenFontGlyph* COpenFont::FontCacheGlyph(TInt aCode)
{
if (COpenFontGlyphCache* glyphCache = GetGlyphCache())
{
@@ -1057,52 +1056,58 @@
iEntryArray.Close(aHeap);
}
-const COpenFontGlyph* COpenFontSessionCache::Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex) const
+const COpenFontGlyph* COpenFontSessionCache::Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex)
{
aIndex = -1;
+ TInt oldest = KMaxTInt;
+ TInt oldest_index = 0;
TInt numEntries = iEntryArray.Count();
TInt index = GLYPH_CODE(aCode) % numEntries; // simple hash function to shorten searches
for (TInt i = 0; i < numEntries; ++i, ++index)
{
if (index >= numEntries)
- {
index = 0;
- }
- const COpenFontSessionCacheEntry* entry = iEntryArray[index];
+ COpenFontSessionCacheEntry* entry = iEntryArray[index];
if (entry == NULL)
{
- if (aIndex < 0)
+ if (aIndex == -1)
+ aIndex = index;
+ }
+ else
+ {
+ if (entry->Font() == aFont && entry->iCode == aCode)
{
- aIndex = index;
+ entry->iLastAccess = iLastAccess++;
+ return entry;
+ }
+ if (entry->iLastAccess < oldest)
+ {
+ oldest = entry->iLastAccess;
+ oldest_index = index;
}
}
- else if (entry->Font() == aFont && entry->iCode == aCode)
- {
- return entry;
- }
}
+ if (aIndex == -1)
+ aIndex = oldest_index;
return NULL;
}
void COpenFontSessionCache::Insert(RHeap* aHeap, COpenFontSessionCacheEntry* aEntry, TInt aIndex)
{
- if (aIndex >= iEntryArray.Count())
+ if (aIndex < 0 || aIndex >= iEntryArray.Count())
{
Panic(EFntSessionCacheIndexOutOfRange);
}
- if (aIndex < 0)
- {
- aIndex = Math::Rand(iRandomSeed) % iEntryArray.Count();
- }
COpenFontSessionCacheEntry::Delete(aHeap, iEntryArray[aIndex]);
iEntryArray.SetAt(aIndex, aEntry);
+ aEntry->iLastAccess = iLastAccess++;
}
COpenFontSessionCache::COpenFontSessionCache(TInt aSessionHandle):
iSessionHandle(aSessionHandle),
- iRandomSeed(0)
- {
+ iLastAccess(0)
+ {
}
TInt COpenFontSessionCacheList::AddCache(COpenFontSessionCache* aCache)
--- a/textrendering/textformatting/tagma/TMINTERP.CPP Wed Sep 15 14:10:32 2010 +0300
+++ b/textrendering/textformatting/tagma/TMINTERP.CPP Wed Oct 13 16:35:09 2010 +0300
@@ -2745,7 +2745,6 @@
CFont::TMeasureTextInput input;
input.iFlags = CFont::TMeasureTextInput::EFVisualOrder;
input.iStartInputChar = 1;
- input.iEndInputChar = aEnd;
extra_pixels = text_bounds.Width() - aFont->MeasureText(aText, &input);
}