# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1283455394 -10800 # Node ID 01e38b33e72a46eba55e57b94f50dcfde7e1b890 # Parent a7c93843475483e58dd75f96b88245fb1635f84d Revision: 201035 Kit: 201035 diff -r a7c938434754 -r 01e38b33e72a fontservices/fontstore/inc/OPENFONT.H --- a/fontservices/fontstore/inc/OPENFONT.H Wed Aug 18 11:34:25 2010 +0300 +++ b/fontservices/fontstore/inc/OPENFONT.H Thu Sep 02 22:23:14 2010 +0300 @@ -328,7 +328,7 @@ TBool HasCharacterL(TInt aCode) const; TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const; void OnFileDeleted(); - COpenFontGlyphCache* GetGlyphCache(); + COpenFontGlyphCache* GetGlyphCache() const; inline TInt FontCapitalAscent() const; inline TInt FontMaxAscent() const; inline TInt FontStandardDescent() const; @@ -371,7 +371,7 @@ private: const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const; - const COpenFontGlyph* FontCacheGlyph(TInt aCode); + const COpenFontGlyph* FontCacheGlyph(TInt aCode) const; void SetGlyphCache(COpenFontGlyphCache* aGlyphCache); diff -r a7c938434754 -r 01e38b33e72a fontservices/fontstore/inc/openfontsprivate.h --- a/fontservices/fontstore/inc/openfontsprivate.h Wed Aug 18 11:34:25 2010 +0300 +++ b/fontservices/fontstore/inc/openfontsprivate.h Thu Sep 02 22:23:14 2010 +0300 @@ -135,8 +135,6 @@ 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!) @@ -150,20 +148,21 @@ */ 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 COpenFontGlyph* Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex) const; void Insert(RHeap* aHeap, COpenFontSessionCacheEntry* aEntry, TInt aIndex); private: COpenFontSessionCache(TInt aSessionHandle); ~COpenFontSessionCache(); -public: - TInt iSessionHandle; - TInt iLastAccess; +private: + TInt iSessionHandle; + TInt64 iRandomSeed; ROffsetArray iEntryArray; }; diff -r a7c938434754 -r 01e38b33e72a fontservices/fontstore/src/OPENFONT.CPP --- a/fontservices/fontstore/src/OPENFONT.CPP Wed Aug 18 11:34:25 2010 +0300 +++ b/fontservices/fontstore/src/OPENFONT.CPP Thu Sep 02 22:23:14 2010 +0300 @@ -26,6 +26,7 @@ #include "linkedfontsprivate.h" #include #include +#include #include "OstTraceDefinitions.h" #ifdef OST_TRACE_COMPILER_IN_USE @@ -904,13 +905,13 @@ iFileOffset = 0; } -COpenFontGlyphCache* COpenFont::GetGlyphCache() +COpenFontGlyphCache* COpenFont::GetGlyphCache() const { if (iGlyphCacheOffset == 0) { return NULL; } - return reinterpret_cast(PtrAdd(this, iGlyphCacheOffset)); + return reinterpret_cast(PtrAdd(const_cast(this), iGlyphCacheOffset)); } const COpenFontGlyph* COpenFont::Glyph(TInt aSessionHandle, TInt aCode) const @@ -949,7 +950,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 COpenFontGlyph* COpenFont::FontCacheGlyph(TInt aCode) const { if (COpenFontGlyphCache* glyphCache = GetGlyphCache()) { @@ -1112,58 +1113,52 @@ iEntryArray.Close(aHeap); } -const COpenFontGlyph* COpenFontSessionCache::Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex) +const COpenFontGlyph* COpenFontSessionCache::Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex) const { 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; - COpenFontSessionCacheEntry* entry = iEntryArray[index]; + } + const COpenFontSessionCacheEntry* entry = iEntryArray[index]; if (entry == NULL) { - if (aIndex == -1) - aIndex = index; - } - else - { - if (entry->Font() == aFont && entry->iCode == aCode) + if (aIndex < 0) { - entry->iLastAccess = iLastAccess++; - return entry; - } - if (entry->iLastAccess < oldest) - { - oldest = entry->iLastAccess; - oldest_index = index; + aIndex = 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 < 0 || aIndex >= iEntryArray.Count()) + if (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), - iLastAccess(0) - { + iRandomSeed(0) + { } TInt COpenFontSessionCacheList::AddCache(COpenFontSessionCache* aCache) diff -r a7c938434754 -r 01e38b33e72a fontservices/fontstore/tfs/T_FontMetrics.cpp --- a/fontservices/fontstore/tfs/T_FontMetrics.cpp Wed Aug 18 11:34:25 2010 +0300 +++ b/fontservices/fontstore/tfs/T_FontMetrics.cpp Thu Sep 02 22:23:14 2010 +0300 @@ -300,26 +300,33 @@ */ void CTFontMetrics::GetNearestFontToDesignHeightInPixels() { + INFO_PRINTF3(_L("iKPixelWidthInTwips = %d; iKPixelHeightInTwips = %d"), + iFontStore->iKPixelWidthInTwips, iFontStore->iKPixelHeightInTwips); + TOpenFontSpec openFontSpec = GetTOpenFontSpec(); + INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangNone")); CFont* font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangNone); iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec); Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics()); iFontStore->ReleaseFont(font); + INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangFinnish")); font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangFinnish); iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec); Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics()); iFontStore->ReleaseFont(font); + INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangGreek")); font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangGreek); iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec); Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics()); iFontStore->ReleaseFont(font); + INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangRussian")); font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangRussian); iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec); @@ -330,6 +337,12 @@ void CTFontMetrics::Verify_GetNearestFontToDesignHeightInPixels(const CFont& aFont, TInt aScript) { VerifyTypefaceNameAndID(aFont); + INFO_PRINTF4(_L("HeightInPixels() = %d; AscentInPixels() = %d; DescentInPixels() = %d"), + aFont.HeightInPixels(), aFont.AscentInPixels(), aFont.DescentInPixels()); + INFO_PRINTF4(_L("FontCapitalAscent() = %d; FontStandardDescent() = %d; FontMaxAscent() = %d"), + aFont.FontCapitalAscent(), aFont.FontStandardDescent(), aFont.FontMaxAscent()); + INFO_PRINTF4(_L("FontMaxDescent() = %d; FontMaxHeight() = %d; FontLineGap() = %d"), + aFont.FontMaxDescent(), aFont.FontMaxHeight(), aFont.FontLineGap()); // Old metrics TEST(KRequiredHeight == aFont.HeightInPixels()); TEST(19 == aFont.AscentInPixels()); @@ -337,30 +350,15 @@ // New metrics TEST(18 == aFont.FontCapitalAscent()); TEST(5 == aFont.FontStandardDescent()); - if (GlyphSample::EScriptNone == aScript) + if (GlyphSample::EScriptNone == aScript || + GlyphSample::EScriptLatin == aScript || + GlyphSample::EScriptGreek == aScript || + GlyphSample::EScriptCyrillic == aScript) { TEST(28 == aFont.FontMaxAscent()); TEST(8 == aFont.FontMaxDescent()); TEST(42 == aFont.FontLineGap()); } - else if (GlyphSample::EScriptLatin == aScript) - { - TEST(24 == aFont.FontMaxAscent()); - TEST(5 == aFont.FontMaxDescent()); - TEST(35 == aFont.FontLineGap()); - } - else if (GlyphSample::EScriptGreek == aScript) - { - TEST(22 == aFont.FontMaxAscent()); - TEST(5 == aFont.FontMaxDescent()); - TEST(33 == aFont.FontLineGap()); - } - else if (GlyphSample::EScriptCyrillic == aScript) - { - TEST(23 == aFont.FontMaxAscent()); - TEST(5 == aFont.FontMaxDescent()); - TEST(34 == aFont.FontLineGap()); - } else TEST(1 == 0); TEST(aFont.FontMaxAscent() + aFont.FontMaxDescent() == aFont.FontMaxHeight()); INFO_PRINTF2(_L("MaxCharWidthInPixels() returns %d"), aFont.MaxCharWidthInPixels()); @@ -393,24 +391,28 @@ { TOpenFontSpec openFontSpec = GetTOpenFontSpec(); + INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangNone")); CFont* font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangNone); iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight); Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics()); iFontStore->ReleaseFont(font); + INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangFinnish")); font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangFinnish); iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight); Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics()); iFontStore->ReleaseFont(font); + INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangGreek")); font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangGreek); iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight); Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics()); iFontStore->ReleaseFont(font); + INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangRussian")); font = NULL; openFontSpec.SetScriptTypeForMetrics(ELangRussian); iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight); @@ -421,62 +423,42 @@ void CTFontMetrics::Verify_GetNearestFontToMaxHeightInPixels(const CFont& aFont, TInt aScript) { VerifyTypefaceNameAndID(aFont); + INFO_PRINTF4(_L("HeightInPixels() = %d; AscentInPixels() = %d; DescentInPixels() = %d"), + aFont.HeightInPixels(), aFont.AscentInPixels(), aFont.DescentInPixels()); + INFO_PRINTF4(_L("FontCapitalAscent() = %d; FontStandardDescent() = %d; FontMaxAscent() = %d"), + aFont.FontCapitalAscent(), aFont.FontStandardDescent(), aFont.FontMaxAscent()); + INFO_PRINTF4(_L("FontMaxDescent() = %d; FontMaxHeight() = %d; FontLineGap() = %d"), + aFont.FontMaxDescent(), aFont.FontMaxHeight(), aFont.FontLineGap()); if (GlyphSample::EScriptNone == aScript) { // Old metrics - TEST(15 == aFont.HeightInPixels()); - TEST(12 == aFont.AscentInPixels()); - TEST(15 - 12 == aFont.DescentInPixels()); - // New metrics - TEST(11 == aFont.FontCapitalAscent()); - TEST(3 == aFont.FontStandardDescent()); - TEST(18 == aFont.FontMaxAscent()); - TEST(5 == aFont.FontMaxDescent()); - TEST(KRequiredHeight - 1 == aFont.FontMaxHeight()); - TEST(29 == aFont.FontLineGap()); - } - else if (GlyphSample::EScriptLatin == aScript) - { - // Old metrics - TEST(20 == aFont.HeightInPixels()); - TEST(16 == aFont.AscentInPixels()); - TEST(20 - 16 == aFont.DescentInPixels()); - // New metrics - TEST(15 == aFont.FontCapitalAscent()); - TEST(4 == aFont.FontStandardDescent()); - TEST(20 == aFont.FontMaxAscent()); - TEST(4 == aFont.FontMaxDescent()); - TEST(KRequiredHeight == aFont.FontMaxHeight()); - TEST(30 == aFont.FontLineGap()); + TEST(16 == aFont.HeightInPixels()); + TEST(13 == aFont.AscentInPixels()); + TEST(16 - 13 == aFont.DescentInPixels()); + // New metrics + TEST(12 == aFont.FontCapitalAscent()); + TEST(3 == aFont.FontStandardDescent()); + TEST(19 == aFont.FontMaxAscent()); + TEST(6 == aFont.FontMaxDescent()); + TEST(KRequiredHeight + 1 == aFont.FontMaxHeight()); + TEST(31 == aFont.FontLineGap()); } - else if (GlyphSample::EScriptGreek == aScript) - { - // Old metrics - TEST(20 == aFont.HeightInPixels()); - TEST(16 == aFont.AscentInPixels()); - TEST(20 - 16 == aFont.DescentInPixels()); - // New metrics - TEST(15 == aFont.FontCapitalAscent()); - TEST(4 == aFont.FontStandardDescent()); - TEST(18 == aFont.FontMaxAscent()); - TEST(5 == aFont.FontMaxDescent()); - TEST(KRequiredHeight - 1 == aFont.FontMaxHeight()); - TEST(29 == aFont.FontLineGap()); - } - else if (GlyphSample::EScriptCyrillic == aScript) - { - // Old metrics - TEST(21 == aFont.HeightInPixels()); - TEST(16 == aFont.AscentInPixels()); - TEST(21 - 16 == aFont.DescentInPixels()); - // New metrics - TEST(16 == aFont.FontCapitalAscent()); - TEST(4 == aFont.FontStandardDescent()); - TEST(20 == aFont.FontMaxAscent()); - TEST(4 == aFont.FontMaxDescent()); - TEST(KRequiredHeight == aFont.FontMaxHeight()); - TEST(30 == aFont.FontLineGap()); - } + else if (GlyphSample::EScriptLatin == aScript || + GlyphSample::EScriptGreek == aScript || + GlyphSample::EScriptCyrillic == aScript) + { + // Old metrics + TEST(24 == aFont.HeightInPixels()); + TEST(19 == aFont.AscentInPixels()); + TEST(24 - 19 == aFont.DescentInPixels()); + // New metrics + TEST(18 == aFont.FontCapitalAscent()); + TEST(5 == aFont.FontStandardDescent()); + TEST(28 == aFont.FontMaxAscent()); + TEST(8 == aFont.FontMaxDescent()); + TEST(KRequiredHeight + 12 == aFont.FontMaxHeight()); + TEST(42 == aFont.FontLineGap()); + } else TEST(1 == 0); INFO_PRINTF2(_L("MaxCharWidthInPixels() returns %d"), aFont.MaxCharWidthInPixels()); } diff -r a7c938434754 -r 01e38b33e72a layers.sysdef.xml --- a/layers.sysdef.xml Wed Aug 18 11:34:25 2010 +0300 +++ b/layers.sysdef.xml Thu Sep 02 22:23:14 2010 +0300 @@ -96,9 +96,9 @@ - + + + diff -r a7c938434754 -r 01e38b33e72a package_definition.xml --- a/package_definition.xml Wed Aug 18 11:34:25 2010 +0300 +++ b/package_definition.xml Thu Sep 02 22:23:14 2010 +0300 @@ -2,13 +2,22 @@ - + + + + - + + + + - + + + + @@ -16,12 +25,15 @@ - + + + + - - + + @@ -30,10 +42,10 @@ - + - + @@ -41,18 +53,18 @@ - + - + - + - + - + @@ -61,7 +73,7 @@ - + @@ -74,18 +86,16 @@ - - - - - - - - - + + + + + + + diff -r a7c938434754 -r 01e38b33e72a package_map.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_map.xml Thu Sep 02 22:23:14 2010 +0300 @@ -0,0 +1,1 @@ +