--- a/charconvfw/numbergrouping/Group/NumberGrouping.mmp Sat Feb 20 00:37:46 2010 +0200
+++ b/charconvfw/numbergrouping/Group/NumberGrouping.mmp Fri Mar 12 15:51:09 2010 +0200
@@ -59,7 +59,6 @@
LIBRARY euser.lib
LIBRARY bafl.lib
LIBRARY efsrv.lib
-LIBRARY commonengine.lib
LIBRARY centralrepository.lib // Central repository
// End of file.
--- a/charconvfw/numbergrouping/Src/StateMachine.cpp Sat Feb 20 00:37:46 2010 +0200
+++ b/charconvfw/numbergrouping/Src/StateMachine.cpp Fri Mar 12 15:51:09 2010 +0200
@@ -71,7 +71,7 @@
void CStateMachine::AddStateTransistionL(TInt aIndex, TInt aState, TInt aNextState)
{
- if(aIndex > iMaxNumberChars || aState > iMaxNumberStates || aNextState > iMaxNumberStates)
+ if(aIndex < 0 || aIndex > iMaxNumberChars || aState > iMaxNumberStates || aNextState > iMaxNumberStates)
User::Leave(KErrGeneral);
iStateTable[static_cast<TInt>(aIndex)][static_cast<TInt>(aState)] = static_cast<TInt>(aNextState);
--- a/fontservices/fontstore/bwins/FNTSTR2U.DEF Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/bwins/FNTSTR2U.DEF Fri Mar 12 15:51:09 2010 +0200
@@ -192,10 +192,4 @@
?UpdateLinkedTypefaceL@CFontStore@@QAEXABVTLinkedTypefaceSpecificationArgs@@@Z @ 191 NONAME ; void CFontStore::UpdateLinkedTypefaceL(class TLinkedTypefaceSpecificationArgs const &)
?KLinkedFontDrive@@3CB @ 192 NONAME ; signed char const KLinkedFontDrive
?GetFontFilePath@CFontStore@@QBEHABVTDesC16@@AAV?$TBuf@$0BAA@@@@Z @ 193 NONAME ; int CFontStore::GetFontFilePath(class TDesC16 const &, class TBuf<256> &) const
- ?ReleaseGlyphOutlines@CBitmapFont@@QAEXHPBIHH@Z @ 194 NONAME ; void CBitmapFont::ReleaseGlyphOutlines(int, unsigned int const *, int, int)
- ?GetGlyphOutline@CBitmapFont@@QAEHIHAAPAXAAHH@Z @ 195 NONAME ; int CBitmapFont::GetGlyphOutline(unsigned int, int, void * &, int &, int)
- ?KFontTable_GlyphOutline_CacheMaxMem@@3KB @ 196 NONAME ; unsigned long const KFontTable_GlyphOutline_CacheMaxMem
- ?CleanupCacheOnFbsSessionTermination@CFontStore@@QAEXH@Z @ 197 NONAME ; void CFontStore::CleanupCacheOnFbsSessionTermination(int)
- ?GetFontTable@CBitmapFont@@QAEHKAAPAXAAHH@Z @ 198 NONAME ; int CBitmapFont::GetFontTable(unsigned long, void * &, int &, int)
- ?ReleaseFontTable@CBitmapFont@@QAEXKH@Z @ 199 NONAME ; void CBitmapFont::ReleaseFontTable(unsigned long, int)
--- a/fontservices/fontstore/eabi/fntstr2U.def Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/eabi/fntstr2U.def Fri Mar 12 15:51:09 2010 +0200
@@ -245,10 +245,4 @@
_ZN10CFontStore21UpdateLinkedTypefaceLERK32TLinkedTypefaceSpecificationArgs @ 244 NONAME
_ZN28CLinkedTypefaceSpecification21UpdateLinkedTypefaceLER17CFbsTypefaceStore @ 245 NONAME
_ZNK10CFontStore15GetFontFilePathERK7TDesC16R4TBufILi256EE @ 246 NONAME
- KFontTable_GlyphOutline_CacheMaxMem @ 247 NONAME DATA 4
- _ZN10CFontStore35CleanupCacheOnFbsSessionTerminationEi @ 248 NONAME
- _ZN11CBitmapFont12GetFontTableEmRPvRii @ 249 NONAME
- _ZN11CBitmapFont15GetGlyphOutlineEjiRPvRii @ 250 NONAME
- _ZN11CBitmapFont16ReleaseFontTableEmi @ 251 NONAME
- _ZN11CBitmapFont20ReleaseGlyphOutlinesEiPKjii @ 252 NONAME
--- a/fontservices/fontstore/group/BLD.INF Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/group/BLD.INF Fri Mar 12 15:51:09 2010 +0200
@@ -67,7 +67,6 @@
../tfs/scripts/fntstoretest_T_All.script z:/fntstoretest/fntstoretest_t_all.script
../tfs/scripts/fntstoretest_T_Fnt.script z:/fntstoretest/fntstoretest_t_fnt.script
-../tfs/scripts/fntstoretest_T_Cache.script z:/fntstoretest/fntstoretest_T_Cache.script
../tfs/scripts/fntstoretest_T_FntMem.script z:/fntstoretest/fntstoretest_t_fntmem.script
../tfs/scripts/fntstoretest_T_FontBitmap.script z:/fntstoretest/fntstoretest_t_fontbitmap.script
../tfs/scripts/fntstoretest_T_FsOpen.script z:/fntstoretest/fntstoretest_t_fsopen.script
--- a/fontservices/fontstore/group/FntstoreTest.iby Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/group/FntstoreTest.iby Fri Mar 12 15:51:09 2010 +0200
@@ -32,7 +32,6 @@
//script files
data=DATAZ_\fntstoretest\fntstoretest_T_All.script \fntstoretest\fntstoretest_T_All.script
data=DATAZ_\fntstoretest\fntstoretest_T_Fnt.script \fntstoretest\fntstoretest_T_Fnt.script
-data=DATAZ_\fntstoretest\fntstoretest_T_Cache.script \fntstoretest\fntstoretest_T_Cache.script
data=DATAZ_\fntstoretest\fntstoretest_T_FntMem.script \fntstoretest\fntstoretest_T_FntMem.script
data=DATAZ_\fntstoretest\fntstoretest_T_FontBitmap.script \fntstoretest\fntstoretest_T_FontBitmap.script
data=DATAZ_\fntstoretest\fntstoretest_T_FsOpen.script \fntstoretest\fntstoretest_T_FsOpen.script
--- a/fontservices/fontstore/group/TFntStoreServer.mmp Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/group/TFntStoreServer.mmp Fri Mar 12 15:51:09 2010 +0200
@@ -61,7 +61,6 @@
SOURCE t_linkedfontscapability.cpp
SOURCE T_LinkedFontUpdateTests.cpp
SOURCE T_IsolatedFontStore.cpp
-SOURCE T_Cache.CPP
SOURCE T_FontSessionCache.cpp
SOURCEPATH ../src
--- a/fontservices/fontstore/inc/FNTSTORE.h Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/inc/FNTSTORE.h Fri Mar 12 15:51:09 2010 +0200
@@ -65,7 +65,6 @@
class COpenFontRasterizer;
class CLinkedTypefaceGroup;
IMPORT_C extern const TInt8 KLinkedFontDrive;
-IMPORT_C extern const TUint32 KFontTable_GlyphOutline_CacheMaxMem;
/**
WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases.
@@ -163,14 +162,7 @@
inline COpenFont* OpenFont() const;
inline TGlyphBitmapType GlyphBitmapType() const;
IMPORT_C TUint32 UniqueFontId();
- IMPORT_C TInt GetFontTable(TUint32 aTag, TAny*& aTableContent,
- TInt& aLength, TInt aSessionHandle);
- IMPORT_C TInt GetGlyphOutline(TUint aCode,
- TBool aHinted, TAny*& aOutline, TInt& aLength, TInt aSessionHandle);
- IMPORT_C void ReleaseGlyphOutlines(TInt aCount, const TUint* aCodes,
- TBool aHinted, TInt aSessionHandle);
- IMPORT_C void ReleaseFontTable(TUint32 aTag, TInt aSessionHandle);
-
+
private:
// From CFont
IMPORT_C virtual TUid DoTypeUid() const;
@@ -283,15 +275,6 @@
IMPORT_C void operator = (const COpenFontLinkedTypefaceSpecification& aRhs);
};
-
-
-class TUnhintedOutlineId;
-class THintedOutlineId;
-class CFontTableCache;
-class CUnhintedOutlineCache;
-class CHintedOutlineCache;
-class TFontTableGlyphOutlineCacheMemMonitor;
-
class CFontStore : public CTypefaceStore
/**
A store for fonts.
@@ -350,27 +333,6 @@
IMPORT_C void UpdateLinkedTypefaceL(const TLinkedTypefaceSpecificationArgs& aLinkedTypefaceSpec);
IMPORT_C void LoadFontsAtStartupL();
IMPORT_C TBool GetFontFilePath(const TDesC& aFontName, TFileName& aFilePath) const;
- IMPORT_C void CleanupCacheOnFbsSessionTermination(TInt aSessionHandle);
-
- TInt CacheFontTable(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt aLength);
- TInt ReleaseFontTable(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
- TInt FindFontTableInCache(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt& aLength);
- TInt IncFontTableRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
- TInt DecFontTableRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
- TInt CacheUnhintedOutline(const TUnhintedOutlineId& aOutlineId, TAny* aData,
- TInt aLength, TAny*& aOutline, TInt& aLen);
- TInt CacheHintedOutline(const THintedOutlineId& aOutlineId, TAny* aData, TInt aLength,
- TAny*& aOutline, TInt& aLen);
- TInt ReleaseUnhintedOutline(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt ReleaseHintedOutline(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt IncreaseUnhintedOutlineRefCount(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt IncreaseHintedOutlineRefCount(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt FindUnhintedOutlineInCache(const TUnhintedOutlineId& aOutlineId, TAny*& aData,
- TInt &aLength);
- TInt FindHintedOutlineInCache(const THintedOutlineId& aOutlineId, TAny*& aData, TInt& aLength);
- void CleanupCacheOnOpenFontRemoval(COpenFont* aFont);
- void CleanupCacheOnOpenFontFileRemoval(COpenFontFile* aFontFile);
-
private:
CFontStore(RHeap* aHeap);
void ConstructL();
@@ -433,11 +395,7 @@
CArrayPtrFlat<CFontBitmap> iFontBitmapList;
CArrayFixFlat<TTypefaceFontBitmap> iTypefaceFontBitmapList;
CArrayPtrFlat<COpenFontFile> iOpenFontFileList;
- TInt iReserved[2]; // keep iDefaultBitmapType at the correct offset
- CFontTableCache *iFontTableCache;
- CUnhintedOutlineCache *iUnhintedOutlineCache;
- CHintedOutlineCache *iHintedOutlineCache;
- TFontTableGlyphOutlineCacheMemMonitor *iCacheMemMon;
+ TInt iReserved[6]; // keep iDefaultBitmapType at the correct offset
CArrayPtrFlat<COpenFontRasterizer> iOpenFontRasterizerList;
COpenFontSessionCacheList* iOpenFontSessionCacheList;
TInt iOpenFontUid;
--- a/fontservices/fontstore/inc/OPENFONT.H Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/inc/OPENFONT.H Fri Mar 12 15:51:09 2010 +0200
@@ -82,7 +82,6 @@
@released
*/
const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
-const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE};
/**
Supplied to CShaper::ExtendedInterface() to get the language and script
@@ -338,8 +337,6 @@
inline TInt FontLineGap() const;
inline TInt FontMaxHeight() const;
void DeleteShaper() const;
- TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength);
- TInt GetGlyphOutline(TUint aCode, TBool aHinted, TAny*& aOutline, TInt& aLength);
protected:
/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
@@ -555,12 +552,6 @@
virtual TBool HasTrueTypeTable(TUint32 aTag) = 0;
};
-class MOpenFontGlyphOutlineExtension
- {
-public:
- virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
- TBool aHinted, TAny*& aOutline, TInt& aLength) = 0;
- };
/**
Font attribute base class.
--- a/fontservices/fontstore/inc/openfontsprivate.h Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/inc/openfontsprivate.h Fri Mar 12 15:51:09 2010 +0200
@@ -19,7 +19,6 @@
#ifndef __OPENFONTS_PRIVATE_H__
#define __OPENFONTS_PRIVATE_H__
-#include <e32hashtab.h>
class COpenFontShaperCacheEntry;
/* MSB is set to indicate a glyph code rather than a unicode value
@@ -211,225 +210,6 @@
TInt iCacheOffset;
};
-class TFontTableGlyphOutlineCacheMemMonitor
- {
-public:
- TFontTableGlyphOutlineCacheMemMonitor();
- void Inc(TInt aBytes);
- void Dec(TInt aBytes);
- TInt GetMemUsage();
-private:
- TInt iBytes;
- };
-
-struct TCacheUserInfo {
- TInt iSessionHandle;
- TInt iRefCount;
- TCacheUserInfo(TInt aSessionHandle, TInt aRefCount = 0):
- iSessionHandle(aSessionHandle), iRefCount(aRefCount) { }
-};
-
-class CFontTableCache;
-
-class CFontTableCacheItem
- {
-friend class CFontTableCache ;
-
-public:
- CFontTableCacheItem(TUid &aFileUid, const TUint32 aTag,
- TInt aOffset, TInt aLength);
- ~CFontTableCacheItem();
-
- TInt DecRefCount(TInt aSessionHandle);
- TInt IncRefCount(TInt aSessionHandle);
-
- TBool HasOutstandingRefCount();
- TInt FindUser(TInt aSessionHandle, TInt *id);
-
-#ifdef _DEBUG
- void SetUser(RPointerArray<TCacheUserInfo> users)
- {
- TInt len = users.Count();
- for( TInt i = 0; i < len ; i++ )
- {
- iUsers.Append(users[i]);
- }
- }
-#endif
-
-private:
- CFontTableCacheItem(const CFontTableCacheItem &); // disallow copy construction.
- CFontTableCacheItem& operator =(const CFontTableCacheItem &); // disallow assignment.
-
- TUid iFileUid;
- TUint32 iTag;
-
-
- TInt iOffset;
- TInt iLength;
- RPointerArray<TCacheUserInfo> iUsers;
- };
-
-
-class CFontTableCache
- {
-public:
- CFontTableCache(RHeap* aHeap, TFontTableGlyphOutlineCacheMemMonitor& aMon);
- ~CFontTableCache();
- TInt Append(TUid aFileUid, TUint32 aTag,
- TAny*& aContent, TInt aLength);
- TInt Find(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt& aLength, TInt* id);
- TInt IncRefCount(TUid FileUid, TUint32 aTag, TInt aSessionHandle);
- TInt DecRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
- TBool HasOutstandingRefCount();
- TBool HasOutstandingRefCountWithUid(TUid aFileUid);
- void CleanupCacheOnFbsSessionTermination(TInt aSessionHandle);
- void CleanupCacheOnOpenFontFileRemoval(COpenFontFile*);
-#ifdef _DEBUG
- void SetFontItem(RPointerArray<CFontTableCacheItem> cacheItems)
- {
- TInt len = cacheItems.Count();
- for(TInt i = 0; i < len; i++)
- {
- iCacheItems.Append(cacheItems[i]);
- }
- }
-#endif
-
-private:
- CFontTableCache(const CFontTableCache &); // no copy construction.
- CFontTableCache& operator =(const CFontTableCache &); // no assignment.
-#ifdef _DEBUG
- TInt GetCacheState(const char *func);
-#endif
-
- TFontTableGlyphOutlineCacheMemMonitor &iCacheMemMon;
- RHeap *iHeap;
- RPointerArray<CFontTableCacheItem> iCacheItems;
- };
-
-
-class TUnhintedOutlineCache;
-
-class TUnhintedOutlineId
- {
-public:
- TUnhintedOutlineId(TUid aFileUid, TInt aFaceIndex, TUint aId);
- TUid iFileUid;
- TInt iFaceIndex;
- TUint iId;
- };
-
-class COutlineCacheItem {
-friend class CUnhintedOutlineCache;
-friend class CHintedOutlineCache;
-
-public:
- COutlineCacheItem(TInt aOffset, TInt aLength);
- ~COutlineCacheItem() ;
-
- TInt DecRefCount(TInt aSessionHandle);
- TInt IncRefCount(TInt aSessionHandle);
-#ifdef _DEBUG
- void SetUser(RPointerArray<TCacheUserInfo> users)
- {
- TInt len = users.Count();
- for( TInt i = 0; i < len ; i++ )
- {
- iUsers.Append(users[i]);
- }
- }
-#endif
-
-private:
- TInt FindUser(TInt aSessionHandle, TInt *id);
-
-
- TInt iOffset;
- TInt iLength;
- RPointerArray<TCacheUserInfo> iUsers;
-};
-
-class CUnhintedOutlineCache {
-public:
- CUnhintedOutlineCache(RHeap* aHeap, TFontTableGlyphOutlineCacheMemMonitor& aMon);
- TInt Find(const TUnhintedOutlineId &aOutlineId, TAny*& aData, TInt& aLength);
- TInt IncRefCount(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt DecRefCount(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt CacheUnhintedOutline(const TUnhintedOutlineId& aOutlineId,
- TAny * const aData, const TInt aLength, TAny*& aOutline, TInt &aLen);
- TInt CleanupCacheOnOpenFontFileRemoval(COpenFontFile* aFontFile);
- TInt CleanupCacheOnFbsSessionTermination(TInt aSessionHandle);
-#ifdef _DEBUG
- TInt GetCacheState(const char *func);
-#endif
- ~CUnhintedOutlineCache();
-
-#ifdef _DEBUG
- void SetUnHintedItem(TUnhintedOutlineId id, COutlineCacheItem* item)
- {
- iItemIdMap.Insert(id, item);
- }
-#endif
-
-private:
- // disallow assignment and copy-construction
- CUnhintedOutlineCache(const CUnhintedOutlineCache &);
- CUnhintedOutlineCache& operator =(const CUnhintedOutlineCache &);
-
- static TUint32 IdHash(const TUnhintedOutlineId& aOutlineId);
- static TBool IdIdentity(const TUnhintedOutlineId& id1, const TUnhintedOutlineId& id2);
-
- TFontTableGlyphOutlineCacheMemMonitor& iCacheMemMon;
- RHeap* iHeap;
- RHashMap<TUnhintedOutlineId, COutlineCacheItem*> iItemIdMap; // map the identity to an index in 'iCacheItems'.
-};
-
-class CHintedOutlineCache;
-
-class THintedOutlineId
- {
-public:
- THintedOutlineId(COpenFont* aFont, TUint aId);
- COpenFont *iFont;
- TUint iId;
- };
-
-
-class CHintedOutlineCache {
-public:
- CHintedOutlineCache(RHeap* aHeap, TFontTableGlyphOutlineCacheMemMonitor& aMon);
- TInt Find(const THintedOutlineId& aOutlineId, TAny*& aData, TInt& aLength);
- TInt IncRefCount(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt DecRefCount(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
- TInt CacheHintedOutline(const THintedOutlineId& aOutlineId,
- TAny* aData, TInt aLength, TAny*& aOutline, TInt& aLen);
- TInt CleanupCacheOnOpenFontRemoval(COpenFont* aFont);
- TInt CleanupCacheOnFbsSessionTermination(TInt aSessionHandle);
-#ifdef _DEBUG
- TInt GetCacheState(const char *func);
- void SetHintedItem(THintedOutlineId id, COutlineCacheItem* item)
- {
- iItemIdMap.Insert(id, item);
- }
- RHashMap<THintedOutlineId, COutlineCacheItem*> GetHintedMap()
- {
- return iItemIdMap;
- }
-#endif
-
-private:
- // disallow assignment and copy-construction
- CHintedOutlineCache(const CHintedOutlineCache &);
- CHintedOutlineCache& operator =(const CHintedOutlineCache &);
- static TUint32 IdHash(const THintedOutlineId& aOutlineId);
- static TBool IdIdentity(const THintedOutlineId& id1, const THintedOutlineId& id2);
-
- TFontTableGlyphOutlineCacheMemMonitor& iCacheMemMon;
- RHeap* iHeap;
- RHashMap<THintedOutlineId, COutlineCacheItem*> iItemIdMap; // map the identity to an index in 'iCacheItems'.
- };
-
// inline functions
inline COpenFontSessionCacheEntry::COpenFontSessionCacheEntry(const COpenFont* aFont, TInt aCode, TInt aGlyphIndex,const TOpenFontCharMetrics& aMetrics) :
--- a/fontservices/fontstore/src/FNTSTORE.CPP Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/src/FNTSTORE.CPP Fri Mar 12 15:51:09 2010 +0200
@@ -35,10 +35,6 @@
#include <graphics/openfontrasterizer.h>
#include <graphics/openfontconstants.h>
-static const TUint32 KOutlineGlyphIdHashMask = 0x0000ffff;
-static const TUint32 KOutlineFileUidHashMask = 0x00ff0000;
-static const TUint32 KOutlineFaceIndexHashMask = 0x0f000000;
-static const TUint32 KOutlineFontPtrHashMask = 0x0fff0000;
// uncomment to enable some verbose debug prints
//#define VERBOSE_DEBUG 1
@@ -1111,185 +1107,6 @@
return NULL;
}
-/** Gets a font table.
-@param aTag: Input. The name of the font table.
-@param aTableContent: Output. To return the address of the table content.
-@param aLength: Output. To return the length (in bytes) of the table.
-@param aSessionHandle: Input. A handle to the session requesting this table.
-@return KErrNone on success, specific error code on failure.
-@internalTechnology
-*/
-EXPORT_C TInt CBitmapFont::GetFontTable(TUint32 aTag, TAny *&aTableContent,
- TInt &aLength, TInt aSessionHandle)
- {
- COpenFont *fontPtr = NULL;
- if (IsOpenFont())
- fontPtr = OpenFont();
- else
- return KErrNotSupported;
-
- // try to find it in cache.
- CFontStore *fntStore = fontPtr->File()->GetFontStore();
- TUid fileUid = fontPtr->File()->Uid();
- TInt ret = fntStore->FindFontTableInCache(fileUid, aTag, aTableContent, aLength);
- if (KErrNone == ret)
- {
- ret = fntStore->IncFontTableRefCount(fileUid, aTag, aSessionHandle);
- return ret;
- }
-
- // font table not found in cache.
- ret = fontPtr->GetFontTable(aTag, aTableContent, aLength);
- if (KErrNone == ret)
- {
- ret = fntStore->CacheFontTable(fileUid, aTag, aTableContent, aLength);
- if (KErrNone == ret)
- {
- ret = fntStore->IncFontTableRefCount(fileUid, aTag, aSessionHandle);
- }
- else
- {
- aTableContent = NULL;
- }
- }
-
- return ret;
- }
-
-/** Release a font table. Decrement its reference count. Remove from cache if
- * reference decreases to zero.
-@param aTag: Input. The name of the font table to be released.
-@param aSessionHandle: Input. Handle to the session releasing this table.
-@return KErrNone on success, specific error code on failure.
-@internalTechnology
-*/
-EXPORT_C void CBitmapFont::ReleaseFontTable(TUint32 aTag,
- TInt aSessionHandle)
- {
- COpenFont *fontPtr = NULL;
- if (IsOpenFont())
- fontPtr = OpenFont();
- else
- return;
-
- CFontStore *fntStore = fontPtr->File()->GetFontStore();
- TUid fileUid = fontPtr->File()->Uid();
- fntStore->ReleaseFontTable(fileUid, aTag, aSessionHandle);
- }
-
-
-/** Release a number of glyph outlines. Decrement their reference count.
- * Remove it from cache if reference count decreases to zero.
-@param aCount: Input. Number of outlines to be released.
-@param aCodes: Input. An array of codes. Its interpretation depends on the parameter
- 'aIsGlyphId' (see below).
-@param aIsGlyphId: Input. When aIsGlyphId==ETrue, 'aCodes' is an array of glyph ID's.
- When aIsGlyphId==EFalse, 'aCodes' is an array of Unicode values.
-@param aHinted: Input. To indicate if the outlines are hinted or unhinted.
-@param aSessionHandle: Input. Handle to the session releasing the outlines.
-@return KErrNone on success, specific error code on failure.
-@internalTechnology
-*/
-EXPORT_C void CBitmapFont::ReleaseGlyphOutlines(TInt aCount, const TUint *aCodes,
- TBool aHinted, TInt aSessionHandle)
- {
- COpenFont *fontPtr = NULL;
- if (IsOpenFont())
- fontPtr = OpenFont();
- else
- return;
-
- CFontStore *fontStore = fontPtr->File()->GetFontStore();
-
- for (TInt i = 0; i < aCount; ++i)
- {
- if (aHinted)
- {
- THintedOutlineId outlineId(fontPtr, aCodes[i]);
- fontStore->ReleaseHintedOutline(outlineId, aSessionHandle);
- }
- else
- {
- TInt faceId = fontPtr->FaceIndex();
- TUnhintedOutlineId outlineId(fontPtr->File()->Uid(), faceId, aCodes[i]);
- fontStore->ReleaseUnhintedOutline(outlineId, aSessionHandle);
- }
- }
- }
-
-/** Gets a font table.
-@param aCode: Input. An glyph code. Its interpretation depends on the parameter
- 'aIsGlyphId' (see below).
-@param aIsGlyphId: Input. When aIsGlyphId==ETrue, 'aCode' is a glyph ID.
- When aIsGlyphId==EFalse, 'aCode' is a Unicode values.
-@param aHinted: Input. To indicate if hinted or unhinted outline is needed.
-@param aOutline: Output. A 'void*' pointer, pointing to the outline in memory.
-@param aLength: Output. A TInt, recording the lenght (in bytes) of the outline.
-@param aSessionHandle: Input. Handle to the session requesting this outline.
-@return KErrNone on success, specific error code on failure.
-@internalTechnology
-*/
-EXPORT_C TInt CBitmapFont::GetGlyphOutline(TUint aCode,
- TBool aHinted, TAny *&aOutline, TInt &aLength, TInt aSessionHandle)
- {
- COpenFont *fontPtr = NULL;
- if (IsOpenFont())
- fontPtr = OpenFont();
- else
- return KErrNotSupported;
-
- CFontStore *fontStore = fontPtr->File()->GetFontStore();
- TAny *outlineData = NULL;
- TInt len = KErrGeneral;
- TInt ret = KErrNone;
- if (!aHinted)
- {
- TInt faceId = fontPtr->FaceIndex();
- TUnhintedOutlineId outlineId(fontPtr->File()->Uid(), faceId, aCode);
- ret = fontStore->FindUnhintedOutlineInCache(outlineId, outlineData, len);
- if (KErrNotFound == ret)
- {
- TAny* tmpOutline = 0;
- TInt tmpLen = 0;
- ret = fontPtr->GetGlyphOutline(aCode, aHinted, tmpOutline, tmpLen);
- if (KErrNone == ret)
- {
- fontStore->CacheUnhintedOutline(outlineId,
- tmpOutline, (TInt)tmpLen, outlineData, len);
- }
- User::Free(tmpOutline);
- }
- if (KErrNone == ret)
- {
- fontStore->IncreaseUnhintedOutlineRefCount(outlineId, aSessionHandle);
- }
- }
- else
- {
- THintedOutlineId outlineId(fontPtr, aCode);
- ret = fontStore->FindHintedOutlineInCache(outlineId, outlineData, len);
- if (KErrNotFound == ret)
- {
- TAny* tmpOutline = 0;
- TInt tmpLen = 0;
- ret = fontPtr->GetGlyphOutline(aCode, aHinted, tmpOutline, tmpLen);
- if (KErrNone == ret)
- {
- fontStore->CacheHintedOutline(outlineId,
- tmpOutline, (TInt)tmpLen, outlineData, len);
- }
- User::Free(tmpOutline);
- }
- if (KErrNone == ret)
- {
- fontStore->IncreaseHintedOutlineRefCount(outlineId, aSessionHandle);
- }
- }
-
- aOutline = outlineData;
- aLength = len;
- return KErrNone;
- }
EXPORT_C TUint32 CBitmapFont::UniqueFontId()
{
@@ -1340,866 +1157,6 @@
}
-CFontTableCacheItem::CFontTableCacheItem(TUid &aFileUid, const TUint32 aTag,
- TInt aOffset, TInt aLength): iFileUid(aFileUid), iTag(aTag),
- iOffset(aOffset), iLength(aLength)
- {
- // a null constructor
- }
-
-CFontTableCacheItem::~CFontTableCacheItem()
- {
- iUsers.ResetAndDestroy();
- iUsers.Close();
- }
-
-TBool CFontTableCacheItem::HasOutstandingRefCount()
- {
- TInt count = iUsers.Count();
- for (TInt j = 0; j < count; ++j)
- {
- if (iUsers[j]->iRefCount > 0)
- {
- return ETrue;
- }
- }
- return EFalse;
- }
-
-
-TInt CFontTableCacheItem::FindUser(TInt aSessionHandle, TInt *id)
- {
- TInt len = iUsers.Count();
- for (TInt i = 0; i < len; ++i)
- {
- if (aSessionHandle == iUsers[i]->iSessionHandle)
- {
- *id = i;
- return KErrNone;
- }
- }
- return KErrNotFound;
- }
-
-TInt CFontTableCacheItem::DecRefCount(TInt aSessionHandle)
- {
- TInt id = 0;
- TInt ret = FindUser(aSessionHandle, &id);
- if (KErrNone == ret)
- {
- iUsers[id]->iRefCount--;
- if (0 == iUsers[id]->iRefCount)
- {
- delete iUsers[id];
- iUsers.Remove(id);
- }
- return iUsers.Count();
- }
- return KErrNotFound;
- }
-
-TInt CFontTableCacheItem::IncRefCount(TInt aSessionHandle)
- {
- TInt id = 0;
- TInt ret = FindUser(aSessionHandle, &id);
- if (KErrNone == ret)
- {
- iUsers[id]->iRefCount++;
- }
- else
- {
- TCacheUserInfo *newUser = new TCacheUserInfo(aSessionHandle, 1);
- if (NULL != newUser)
- {
- TRAP(ret, iUsers.AppendL(newUser));
- }
- else
- {
- ret = KErrNoMemory;
- }
- //coverity[leaked_storage]
- // The 'newUser' is kept in iUsers. It will be deleted in DecRefCount().
- }
- return ret;
- }
-
-TInt CFontTableCache::Append(TUid aFileUid, TUint32 aTag,
- TAny *&aContent, TInt aLength)
- {
- TInt ret = 0;
- if ((TUint32)iCacheMemMon.GetMemUsage() >= KFontTable_GlyphOutline_CacheMaxMem)
- {
- RDebug::Printf("Table/Glyph cache full. Unable to add new item.");
- return KErrNoMemory;
- }
- // make a copy of the table content on the shared heap.
- TAny *sharedCopy = iHeap->Alloc(aLength);
- if (NULL == sharedCopy)
- {
- return KErrNoMemory;
- }
-
- Mem::Copy(sharedCopy, aContent, aLength);
-
- CFontTableCacheItem *newItem = NULL;
- TInt offset = PointerToOffset(sharedCopy, iHeap->Base());
- TRAP(ret, newItem = new(ELeave) CFontTableCacheItem(aFileUid, aTag, offset, aLength));
- if (KErrNone != ret)
- {
- iHeap->Free(sharedCopy);
- return ret;
- }
-
- TRAP(ret, iCacheItems.AppendL(newItem));
- if (KErrNone == ret)
- {
- // do not free 'aContent', because the mem is managed by
- // rasterizer cache.
- aContent = sharedCopy;
- iCacheMemMon.Inc(aLength);
- }
- else
- {
- iHeap->Free(sharedCopy);
- }
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- return ret;
- }
-
-TInt CFontTableCache::Find(TUid aFileUid, TUint32 aTag, TAny *&aContent,
- TInt &aLength, TInt *id)
- {
- *id = KErrNotFound;
- TInt len = iCacheItems.Count();
-
- TInt ret = KErrNotFound;
- for (TInt i = 0; i < len; ++i)
- {
- CFontTableCacheItem *item = iCacheItems[i];
- if (item->iFileUid == aFileUid && item->iTag == aTag)
- {
- aContent = OffsetToPointer(item->iOffset, iHeap->Base());
- aLength = item->iLength;
- *id = i;
- ret = KErrNone;
- break;
- }
- }
-
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- return ret;
- }
-
-CFontTableCache::CFontTableCache(RHeap *aHeap, TFontTableGlyphOutlineCacheMemMonitor &aMon):
- iCacheMemMon(aMon), iHeap(aHeap)
- {
- // null constructor
- }
-
-CFontTableCache::~CFontTableCache()
- {
- for (TInt i = 0; i < iCacheItems.Count(); ++i)
- {
- iHeap->Free(OffsetToPointer(iCacheItems[i]->iOffset, iHeap->Base()));
- }
- iCacheItems.ResetAndDestroy();
- iCacheItems.Close();
- }
-
-TInt CFontTableCache::IncRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle)
- {
- TAny *outline = NULL;
- TInt len = 0;
- TInt id = 0;
-
- TInt ret = Find(aFileUid, aTag, outline, len, &id);
- if (KErrNone == ret)
- {
- ret = iCacheItems[id]->IncRefCount(aSessionHandle);
- }
-
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- return ret;
- }
-
-TInt CFontTableCache::DecRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle)
- {
- TAny *outline = NULL;
- TInt len = 0;
- TInt id = 0;
-
- TInt ret = Find(aFileUid, aTag, outline, len, &id);
- if (KErrNone == ret)
- {
- TInt numUsers = iCacheItems[id]->DecRefCount(aSessionHandle);
- if (0 == numUsers)
- {
- // There is no outstanding reference to the cache item.
- iHeap->Free(outline);
- iCacheMemMon.Dec(len);
- delete (iCacheItems[id]);
- iCacheItems.Remove(id);
- }
- }
-
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- return ret;
- }
-
-TBool CFontTableCache::HasOutstandingRefCount()
- {
- TInt len = iCacheItems.Count();
-
- for (TInt i = 0; i < len; ++i)
- {
- if (iCacheItems[i]->HasOutstandingRefCount())
- {
- return ETrue;
- }
- }
- return EFalse;
- }
-
-TBool CFontTableCache::HasOutstandingRefCountWithUid(TUid aFileUid)
- {
- TInt len = iCacheItems.Count();
-
- for (TInt i = 0; i < len; ++i)
- {
- if (iCacheItems[i]->iFileUid == aFileUid)
- {
- if (iCacheItems[i]->HasOutstandingRefCount())
- {
- return ETrue;
- }
- }
- }
- return EFalse;
- }
-
-void CFontTableCache::CleanupCacheOnOpenFontFileRemoval(COpenFontFile *)
- {
- // In CFontStore::RemoveFile(), a font file is not allowed to be removed if
- // there are outstanding ref counts on any table in it. If that check passed
- // and this function is called, there shall be no cache item for that file.
-
- // Currently a cache item having a refcount of 0 is removed immediately.
- // If this strategy is changed in the future, we may need to do some
- // cleanup here.
- }
-
-void CFontTableCache::CleanupCacheOnFbsSessionTermination(TInt aSessionHandle)
- {
- TInt len = iCacheItems.Count();
-
- for (TInt i = 0; i < len; ++i)
- {
- TInt id = -1;
- if (KErrNone == iCacheItems[i]->FindUser(aSessionHandle, &id))
- {
- iCacheItems[i]->iUsers.Remove(id);
- if (iCacheItems[i]->iUsers.Count() == 0)
- {
- iHeap->Free(OffsetToPointer(iCacheItems[i]->iOffset, iHeap->Base()));
- iCacheMemMon.Dec(iCacheItems[i]->iLength);
- delete iCacheItems[i];
- iCacheItems.Remove(i);
- }
- }
- }
- }
-
-
-#ifdef _DEBUG
-TInt CFontTableCache::GetCacheState(const char *func)
- {
- RDebug::Printf("%s called from %s: ", __func__, func);
- TBuf<256> buf;
-
- int len = iCacheItems.Count();
- int numTables = 0, numSessions = 0, totalRef = 0;
- buf.Append(_L("Table cache: "));
- for (int i = 0; i < len; ++i)
- {
- ++numTables;
- TInt abc = iCacheItems[i]->iUsers.Count();
- numSessions += abc;
- for (int j = 0; j < abc; ++j)
- {
- totalRef += iCacheItems[i]->iUsers[j]->iRefCount;
- }
- }
- if (0 == iCacheItems.Count())
- {
- buf.Append(_L("cache empty. "));
- }
- else
- {
- buf.AppendFormat(_L("%d tables referenced by %d sessions, total ref count %d"),
- numTables, numSessions, totalRef);
- }
- RDebug::RawPrint(buf);
- return 0;
- }
-#endif
-
-
-
-TInt COutlineCacheItem::FindUser(TInt aSessionHandle, TInt *id)
- {
- TInt len = iUsers.Count();
- for (TInt i = 0; i < len; ++i)
- {
- if (aSessionHandle == iUsers[i]->iSessionHandle)
- {
- *id = i;
- return KErrNone;
- }
- }
- return KErrNotFound;
- }
-
-COutlineCacheItem::~COutlineCacheItem()
- {
- iUsers.ResetAndDestroy();
- }
-
-COutlineCacheItem::COutlineCacheItem(TInt aOffset, TInt aLength):
- iOffset(aOffset), iLength(aLength)
- {
- // a null constructor.
- }
-
-TInt COutlineCacheItem::DecRefCount(TInt aSessionHandle)
- {
- TInt id = 0;
- TInt ret = FindUser(aSessionHandle, &id);
- if (KErrNone == ret)
- {
- iUsers[id]->iRefCount--;
- if (0 == iUsers[id]->iRefCount)
- {
- delete iUsers[id];
- iUsers.Remove(id);
- }
- return iUsers.Count();
- }
- return KErrNotFound;
- }
-
-TInt COutlineCacheItem::IncRefCount(TInt aSessionHandle)
- {
- TInt id = 0;
- TInt ret = FindUser(aSessionHandle, &id);
- if (KErrNone == ret)
- {
- iUsers[id]->iRefCount++;
- }
- else
- {
- TCacheUserInfo *newUser = new TCacheUserInfo(aSessionHandle, 1);
- if (NULL != newUser)
- {
- TRAP(ret, iUsers.AppendL(newUser));
- }
- else
- {
- ret = KErrNoMemory;
- }
- //coverity[leaked_storage]
- // The 'newUser' is kept in iUsers. It will be deleted in DecRefCount().
- }
- return ret;
- }
-
-#ifdef _DEBUG
-TInt CUnhintedOutlineCache::GetCacheState(const char *func)
- {
- RDebug::Printf("%s called from %s: ", __func__, func);
- int numSessions = 0, totalRef = 0;
- THashMapIter<TUnhintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- COutlineCacheItem **data = it.CurrentValue();
- int len = (*data)->iUsers.Count();
- numSessions += len;
- for (int j = 0; j < len; ++j)
- {
- totalRef += (*data)->iUsers[j]->iRefCount;
- }
- it.NextValue();
- }
-
- TBuf<256> buf;
- buf.Append(_L("Unhinted outline cache: "));
- TInt numItems = iItemIdMap.Count();
- if (0 == numItems)
- {
- buf.Append(_L("empty. "));
- }
- else
- {
- buf.AppendFormat(_L("%d glyphs, %d sessions, total refcount %d"),
- numItems, numSessions, totalRef);
- }
-
- RDebug::RawPrint(buf);
-
- return 0;
- }
-#endif
-
-CUnhintedOutlineCache::CUnhintedOutlineCache(RHeap *aHeap, TFontTableGlyphOutlineCacheMemMonitor &aMon):
- iCacheMemMon(aMon), iHeap(aHeap),
- iItemIdMap(THashFunction32<TUnhintedOutlineId>(CUnhintedOutlineCache::IdHash),
- TIdentityRelation<TUnhintedOutlineId>(CUnhintedOutlineCache::IdIdentity))
- {
-
- }
-
-CUnhintedOutlineCache::~CUnhintedOutlineCache()
- {
- THashMapIter<TUnhintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- const TUnhintedOutlineId *outlineId = it.CurrentKey();
- COutlineCacheItem **data = it.CurrentValue();
-
- // loop body here!
- iHeap->Free(OffsetToPointer((*data)->iOffset, iHeap->Base()));
- delete (*data);
- iItemIdMap.Remove(*outlineId);
- // end loop body
-
- it.NextValue();
- }
- return;
- }
-
-
-TInt CUnhintedOutlineCache::CleanupCacheOnOpenFontFileRemoval(COpenFontFile *aFontFile)
- {
- TUid fileUid = aFontFile->Uid();
-
- THashMapIter<TUnhintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- const TUnhintedOutlineId *outlineId = it.CurrentKey();
- COutlineCacheItem **data = it.CurrentValue();
-
- // loop body here!
- if (outlineId->iFileUid == fileUid)
- {
- iHeap->Free(OffsetToPointer((*data)->iOffset, iHeap->Base()));
- iCacheMemMon.Dec((*data)->iLength);
- delete (*data);
- iItemIdMap.Remove(*outlineId);
- }
- // end loop body
-
- it.NextValue();
- }
- return KErrNone;
- }
-
-TInt CUnhintedOutlineCache::CleanupCacheOnFbsSessionTermination(TInt aSessionHandle)
- {
- THashMapIter<TUnhintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- const TUnhintedOutlineId *outlineId = it.CurrentKey();
- COutlineCacheItem **data = it.CurrentValue();
-
- // loop body here!
- TInt id = 0;
- TInt ret = (*data)->FindUser(aSessionHandle, &id);
- if (KErrNone == ret)
- {
- delete (*data)->iUsers[id];
- (*data)->iUsers.Remove(id);
- if (0 == (*data)->iUsers.Count())
- {
- iHeap->Free(OffsetToPointer((*data)->iOffset, iHeap->Base()));
- iCacheMemMon.Dec((*data)->iLength);
- delete (*data);
- iItemIdMap.Remove(*outlineId);
- }
- }
- // end loop body
-
- it.NextValue();
- }
- return KErrNone;
- }
-
-
-TInt CUnhintedOutlineCache::CacheUnhintedOutline(const TUnhintedOutlineId &aOutlineId,
- TAny* const aData, const TInt aLength, TAny *&aOutline, TInt &aLen)
- {
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- if ((TUint32)iCacheMemMon.GetMemUsage() >= KFontTable_GlyphOutline_CacheMaxMem)
- {
- RDebug::Printf("Table/Glyph cache full. Unable to add new item.");
- return KErrNoMemory;
- }
-
- aLen = KErrGeneral;
- TInt ret1= KErrNone;
-
- // make a copy of the outline data on the shared heap.
- TAny *sharedCopy = iHeap->Alloc(aLength);
- if (NULL == sharedCopy)
- {
- return KErrNoMemory;
- }
-
- Mem::Copy(sharedCopy, aData, aLength);
-
- COutlineCacheItem *newItem = NULL;
- TInt offset = PointerToOffset(sharedCopy, iHeap->Base());
- TRAP(ret1, newItem = new(ELeave) COutlineCacheItem(offset, aLength));
- if (KErrNone != ret1)
- {
- iHeap->Free(sharedCopy);
- sharedCopy = NULL;
- }
- else
- {
- TRAP(ret1, iItemIdMap.InsertL(aOutlineId, newItem));
- if (KErrNone != ret1)
- {
- delete newItem;
- iHeap->Free(sharedCopy);
- sharedCopy = NULL;
- }
- else
- {
- iCacheMemMon.Inc(aLength);
- aLen = aLength;
- }
- }
- aOutline = sharedCopy;
- return ret1;
- }
-
-TInt CUnhintedOutlineCache::IncRefCount(const TUnhintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- COutlineCacheItem **ret = iItemIdMap.Find(aOutlineId);
- if (NULL != ret)
- {
- (*ret)->IncRefCount(aSessionHandle);
- }
- return (NULL==ret?KErrNotFound:KErrNone);
- }
-
-TInt CUnhintedOutlineCache::DecRefCount(const TUnhintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- COutlineCacheItem **ret = iItemIdMap.Find(aOutlineId);
- if (NULL != ret)
- {
- TInt numUsers = (*ret)->DecRefCount(aSessionHandle);
- if (0 == numUsers)
- {
- // There is no outstanding reference to the cache item.
- iHeap->Free(OffsetToPointer((*ret)->iOffset, iHeap->Base()));
- iCacheMemMon.Dec((*ret)->iLength);
- delete (*ret);
- iItemIdMap.Remove(aOutlineId);
- }
- }
- return (NULL==ret?KErrNotFound:KErrNone);
- }
-
-TInt CUnhintedOutlineCache::Find(const TUnhintedOutlineId &aOutlineId, TAny *&aData,
- TInt &aLength)
- {
- COutlineCacheItem **ret = iItemIdMap.Find(aOutlineId);
- TInt ret2 = KErrNone;
- if (NULL != ret)
- {
- aData = OffsetToPointer((*ret)->iOffset, iHeap->Base());
- aLength = (*ret)->iLength;
- }
- else
- {
- ret2 = KErrNotFound;
- }
- return ret2;
- }
-
-
-TUint32 CUnhintedOutlineCache::IdHash(const TUnhintedOutlineId &outlineId)
- {
- // The hash value:
- // bits 0-15: glyph id;
- // bits 16-23: lower 8 bit of font file uid
- // bits 24-27: lower 4 bit of the face index
- // bit 28: 'isGlyphId'
- TUint32 ret = 0;
- ret |= (outlineId.iId & KOutlineGlyphIdHashMask);
- ret |= (KOutlineFileUidHashMask & (outlineId.iFileUid.iUid << 16));
- ret |= (KOutlineFaceIndexHashMask & (outlineId.iFaceIndex << 24));
- ret = (ret % 701);
- return ret;
- }
-
-TBool CUnhintedOutlineCache::IdIdentity(const TUnhintedOutlineId &id1, const TUnhintedOutlineId &id2)
- {
- return id1.iId == id2.iId && id1.iFaceIndex == id2.iFaceIndex &&
- id1.iFileUid == id2.iFileUid;
- }
-
-// hinted outline cache
-#ifdef _DEBUG
-TInt CHintedOutlineCache::GetCacheState(const char *func)
- {
- RDebug::Printf("%s called from %s: ", __func__, func);
- int numSessions = 0, totalRef = 0;
- THashMapIter<THintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- COutlineCacheItem **data = it.CurrentValue();
- int len = (*data)->iUsers.Count();
- numSessions += len;
- for (int j = 0; j < len; ++j)
- {
- totalRef += (*data)->iUsers[j]->iRefCount;
- }
- it.NextValue();
- }
-
- TBuf<256> buf;
- buf.Append(_L("Hinted outline cache: "));
- TInt numItems = iItemIdMap.Count();
- if (0 == numItems)
- {
- buf.Append(_L("empty. "));
- }
- else
- {
- buf.AppendFormat(_L("%d glyphs, %d sessions, total refcount %d"),
- numItems, numSessions, totalRef);
- }
-
- RDebug::RawPrint(buf);
-
- return 0;
- }
-#endif
-
-TInt CHintedOutlineCache::CleanupCacheOnOpenFontRemoval(COpenFont *aFont)
- {
- THashMapIter<THintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- const THintedOutlineId *outlineId = it.CurrentKey();
- COutlineCacheItem **data = it.CurrentValue();
-
- // loop body here!
- if (outlineId->iFont == aFont)
- {
- iCacheMemMon.Dec((*data)->iLength);
- iHeap->Free(OffsetToPointer((*data)->iOffset, iHeap->Base()));
- delete (*data);
- iItemIdMap.Remove(*outlineId);
- }
- // end loop body
-
- it.NextValue();
- }
- return KErrNone;
- }
-
-TInt CHintedOutlineCache::CleanupCacheOnFbsSessionTermination(TInt aSessionHandle)
- {
- THashMapIter<THintedOutlineId, COutlineCacheItem*> it(iItemIdMap);
- it.NextValue();
- while (it.CurrentValue())
- {
- const THintedOutlineId *outlineId = it.CurrentKey();
- COutlineCacheItem **data = it.CurrentValue();
-
- // loop body here!
- TInt id = 0;
- TInt ret = (*data)->FindUser(aSessionHandle, &id);
- if (KErrNone == ret)
- {
- delete (*data)->iUsers[id];
- (*data)->iUsers.Remove(id);
- if (0 == (*data)->iUsers.Count())
- {
- iCacheMemMon.Dec((*data)->iLength);
- iHeap->Free(OffsetToPointer((*data)->iOffset, iHeap->Base()));
- delete (*data);
- iItemIdMap.Remove(*outlineId);
- }
- }
- // end loop body
-
- it.NextValue();
- }
-
- return KErrNone;
- }
-
-
-CHintedOutlineCache::CHintedOutlineCache(RHeap *aHeap, TFontTableGlyphOutlineCacheMemMonitor &aMon):
- iCacheMemMon(aMon), iHeap(aHeap),
- iItemIdMap(THashFunction32<THintedOutlineId>(CHintedOutlineCache::IdHash),
- TIdentityRelation<THintedOutlineId>(CHintedOutlineCache::IdIdentity))
- {
- // a null constructor
- }
-
-TInt CHintedOutlineCache::CacheHintedOutline(const THintedOutlineId &aOutlineId,
- TAny* aData, TInt aLength, TAny *&aOutline, TInt &aLen)
- {
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- if ((TUint32)iCacheMemMon.GetMemUsage() >= KFontTable_GlyphOutline_CacheMaxMem)
- {
- RDebug::Printf("Table/Glyph cache full. Unable to add new item.");
- return KErrNoMemory;
- }
-
- aLen = KErrGeneral;
- TInt ret = KErrNone;
- // make a copy of the outline data on the shared heap.
- TAny *sharedCopy = iHeap->Alloc(aLength);
- if (NULL == sharedCopy)
- {
- return KErrNoMemory;
- }
-
- Mem::Copy(sharedCopy, aData, aLength);
-
- COutlineCacheItem *newItem = NULL;
- TInt offset = PointerToOffset(sharedCopy, iHeap->Base());
- TRAP(ret, newItem = new(ELeave) COutlineCacheItem(offset, aLength));
- if (KErrNone != ret)
- {
- iHeap->Free(sharedCopy);
- sharedCopy = NULL;
- }
- else
- {
- TRAP(ret, iItemIdMap.InsertL(aOutlineId, newItem));
- if (KErrNone != ret)
- {
- delete newItem;
- iHeap->Free(sharedCopy);
- sharedCopy = NULL;
- }
- else
- {
- iCacheMemMon.Inc(aLength);
- aLen = aLength;
- }
- }
- aOutline = sharedCopy;
- return ret;
- }
-
-TInt CHintedOutlineCache::IncRefCount(const THintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- COutlineCacheItem **data = iItemIdMap.Find(aOutlineId);
- if (NULL != data)
- {
- (*data)->IncRefCount(aSessionHandle);
- }
- return (NULL==data?KErrNotFound:KErrNone);
- }
-
-TInt CHintedOutlineCache::DecRefCount(const THintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
-#ifdef _DEBUG
- GetCacheState(__func__);
-#endif
- COutlineCacheItem **data = iItemIdMap.Find(aOutlineId);
- if (NULL != data)
- {
- TInt numUsers = (*data)->DecRefCount(aSessionHandle);
- if (0 == numUsers)
- {
- // There is no outstanding reference to the cache item.
- iCacheMemMon.Dec((*data)->iLength);
- iHeap->Free(OffsetToPointer((*data)->iOffset, iHeap->Base()));
- delete (*data);
- iItemIdMap.Remove(aOutlineId);
- }
- }
- return (NULL==data?KErrNotFound:KErrNone);
- }
-
-TInt CHintedOutlineCache::Find(const THintedOutlineId &aOutlineId,
- TAny *&aData, TInt &aLength)
- {
- COutlineCacheItem **ret = iItemIdMap.Find(aOutlineId);
- TInt ret2 = KErrNone;
- if (NULL != ret)
- {
- aData = OffsetToPointer((*ret)->iOffset, iHeap->Base());
- aLength = (*ret)->iLength;
- }
- else
- {
- ret2 = KErrNotFound;
- }
- return ret2;
- }
-
-
-TUint32 CHintedOutlineCache::IdHash(const THintedOutlineId &outlineId)
- {
- // The hash value:
- // bits 0-15: the outline id
- // bits 16-27: the lower 12 bits of the font pointer
- // bit 28: 'isGlyphId'
-
- TUint32 ret = 0;
- ret |= (KOutlineGlyphIdHashMask & outlineId.iId);
- ret |= (KOutlineFontPtrHashMask & (((TUint32)outlineId.iFont) << 16));
- ret = ret % 701;
- return ret;
- }
-
-TBool CHintedOutlineCache::IdIdentity(const THintedOutlineId &id1, const THintedOutlineId &id2)
- {
- return id1.iId == id2.iId && id1.iFont == id2.iFont;
- }
-// hinted cache
-
-
CFontStore::CFontStore(RHeap* aHeap):
iKPixelWidthInTwips(KDefaultPixelWidthInTwips),
iKPixelHeightInTwips(KDefaultPixelHeightInTwips),
@@ -2261,12 +1218,6 @@
if (twipSize.iHeight > 0 && pixelSize.iHeight > 0)
iKPixelHeightInTwips = twipSize.iHeight * 1000 / pixelSize.iHeight;
-
- iCacheMemMon = new(ELeave) TFontTableGlyphOutlineCacheMemMonitor;
- iUnhintedOutlineCache = new(ELeave) CUnhintedOutlineCache(iHeap, *iCacheMemMon);
- iHintedOutlineCache = new(ELeave) CHintedOutlineCache(iHeap, *iCacheMemMon);
- iFontTableCache = new(ELeave) CFontTableCache(iHeap, *iCacheMemMon);
-
}
/** Creates a new CFontStore object.
@@ -2311,11 +1262,6 @@
delete iHandleArray;
}
iFs.Close();
-
- delete iFontTableCache;
- delete iUnhintedOutlineCache;
- delete iHintedOutlineCache;
- delete iCacheMemMon;
}
@@ -2795,11 +1741,6 @@
if((*iFontAccess)[i].iAccessCount)
return;
}
- if (iFontTableCache && iFontTableCache->HasOutstandingRefCount())
- {
- // disallow font file removal if any font tables are still cached
- return;
- }
iTypefaceList.ResetAndDestroy();
count = iFontBitmapList.Count();
@@ -2834,14 +1775,6 @@
}
}
} // Safe to proceed with removing file
- // also check if there are outstanding references to any
- // table in that file.
- if (iFontTableCache && iFontTableCache->HasOutstandingRefCountWithUid(aFileUid))
- {
- return; // outstanding reference to font table found.
- }
-
- // Safe to proceed with removing file
if (iOpenFontFileList[i]->DecRefCount())
{ // unload the font file
RemoveTypefacesFromSupportList(iOpenFontFileList[i]);
@@ -4901,147 +3834,6 @@
return EFalse;
}
-TInt CFontStore::CacheFontTable(TUid aFileUid, TUint32 aTag,
- TAny *&aContent, TInt aLength)
- {
- return iFontTableCache->Append(aFileUid, aTag, aContent, aLength);
- }
-
-TInt CFontStore::FindFontTableInCache(TUid aFileUid, TUint32 aTag,
- TAny *&aContent, TInt &aLength)
- {
- TInt id;
- return iFontTableCache->Find(aFileUid, aTag, aContent, aLength, &id);
- }
-
-TInt CFontStore::IncreaseUnhintedOutlineRefCount(const TUnhintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
- return iUnhintedOutlineCache->IncRefCount(aOutlineId, aSessionHandle);
- }
-
-TInt CFontStore::IncreaseHintedOutlineRefCount(const THintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
- return iHintedOutlineCache->IncRefCount(aOutlineId, aSessionHandle);
- }
-
-TInt CFontStore::IncFontTableRefCount(TUid aFileUid, TUint32 aTag,
- TInt aSessionHandle)
- {
- return iFontTableCache->IncRefCount(aFileUid, aTag, aSessionHandle);
- }
-
-TInt CFontStore::DecFontTableRefCount(TUid aFileUid, TUint32 aTag,
- TInt aSessionHandle)
- {
- return iFontTableCache->DecRefCount(aFileUid, aTag, aSessionHandle);
- }
-
-TInt CFontStore::CacheUnhintedOutline(const TUnhintedOutlineId &aOutlineId, TAny * aData,
- TInt aLength, TAny *&aOutline, TInt &aLen)
- {
- return iUnhintedOutlineCache->CacheUnhintedOutline(aOutlineId, aData, aLength,
- aOutline, aLen);
- }
-
-TInt CFontStore::CacheHintedOutline(const THintedOutlineId &aOutlineId,
- TAny * aData, TInt aLength, TAny *&aOutline, TInt &aLen)
- {
- return iHintedOutlineCache->CacheHintedOutline(aOutlineId, aData, aLength,
- aOutline, aLen);
- }
-
-TInt CFontStore::ReleaseUnhintedOutline(const TUnhintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
- return iUnhintedOutlineCache->DecRefCount(aOutlineId, aSessionHandle);
- }
-
-TInt CFontStore::ReleaseHintedOutline(const THintedOutlineId &aOutlineId,
- TInt aSessionHandle)
- {
- return iHintedOutlineCache->DecRefCount(aOutlineId, aSessionHandle);
- }
-
-TInt CFontStore::ReleaseFontTable(TUid aFileUid, TUint32 aTag,
- TInt aSessionHandle)
- {
- return iFontTableCache->DecRefCount(aFileUid, aTag, aSessionHandle);
- }
-
-TInt CFontStore::FindUnhintedOutlineInCache(const TUnhintedOutlineId &aOutlineId, TAny *&aData,
- TInt &aLength)
- {
- return iUnhintedOutlineCache->Find(aOutlineId, aData, aLength);
- }
-
-TInt CFontStore::FindHintedOutlineInCache(const THintedOutlineId &aOutlineId,
- TAny *&aData, TInt &aLength)
- {
- return iHintedOutlineCache->Find(aOutlineId, aData, aLength);
- }
-
-void CFontStore::CleanupCacheOnOpenFontRemoval(COpenFont *aFont)
- {
- iHintedOutlineCache->CleanupCacheOnOpenFontRemoval(aFont);
- //iUnhintedOutlineCache.OnOpenFontRemoval(aFont);
- }
-
-void CFontStore::CleanupCacheOnOpenFontFileRemoval(COpenFontFile *aFontFile)
- {
- iUnhintedOutlineCache->CleanupCacheOnOpenFontFileRemoval(aFontFile);
- iFontTableCache->CleanupCacheOnOpenFontFileRemoval(aFontFile);
- }
-
-/** Clean up font table and glyph outline caches when an FBS session is terminated.
- * All the reference counts related to that session are cleared.
-@param aSession: Input. A pointer to the terminating session.
-@return always returns KErrNone.
-@internalTechnology
-*/
-EXPORT_C
-void CFontStore::CleanupCacheOnFbsSessionTermination(TInt aSessionHandle)
- {
- iHintedOutlineCache->CleanupCacheOnFbsSessionTermination(aSessionHandle);
- iUnhintedOutlineCache->CleanupCacheOnFbsSessionTermination(aSessionHandle);
- iFontTableCache->CleanupCacheOnFbsSessionTermination(aSessionHandle);
- }
-
-
-void TFontTableGlyphOutlineCacheMemMonitor::Inc(TInt aBytes)
- {
- iBytes += aBytes;
- }
-
-void TFontTableGlyphOutlineCacheMemMonitor::Dec(TInt aBytes)
- {
- iBytes -= aBytes;
- }
-
-TInt TFontTableGlyphOutlineCacheMemMonitor::GetMemUsage()
- {
- return iBytes;
- }
-
-TFontTableGlyphOutlineCacheMemMonitor::TFontTableGlyphOutlineCacheMemMonitor():
- iBytes(0)
- {
- // null constructor
- }
-
-TUnhintedOutlineId::TUnhintedOutlineId(TUid aFileUid, TInt aFaceIndex, TUint aId):
-iFileUid(aFileUid), iFaceIndex(aFaceIndex), iId(aId)
- {
- // a null constructor;
- }
-
-THintedOutlineId::THintedOutlineId(COpenFont *aFont, TUint aId):
-iFont(aFont), iId(aId)
- {
- // a null constructor;
- }
-
#ifdef _DEBUG
/**
Returns a timestamp for use by FinishTimingL().
--- a/fontservices/fontstore/src/OPENFONT.CPP Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/src/OPENFONT.CPP Fri Mar 12 15:51:09 2010 +0200
@@ -520,8 +520,6 @@
{
//Delete the shaper
delete iShaper;
-
- File()->GetFontStore()->CleanupCacheOnOpenFontRemoval(this);
COpenFontGlyphCache* glyphCache = GetGlyphCache();
if (glyphCache != NULL)
@@ -822,54 +820,6 @@
delete iShaper;
}
-TInt COpenFont::GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength)
- {
- // get the extension API for GetTrueTypeTable() if available
- TAny* ext = NULL;
- ExtendedInterface(KUidOpenFontTrueTypeExtension, ext);
- MOpenFontTrueTypeExtension* extensionInterface =
- reinterpret_cast<MOpenFontTrueTypeExtension*>(ext);
-
- TInt ret = KErrNone;
- if (extensionInterface == NULL)
- {
- ret = KErrNotSupported;
- }
- else
- {
- TUint32 tag = aTag;
- TInt len = 0;
- aTableContent = extensionInterface->GetTrueTypeTable(ret, tag, &len);
- if (KErrNone == ret)
- {
- aLength = len;
- }
- }
- return ret;
- }
-
-TInt COpenFont::GetGlyphOutline(TUint aCode,
- TBool aHinted, TAny*& aOutline, TInt &aLength)
- {
- // get the extension API for GetTrueTypeTable() if available
- TAny* ext = NULL;
- ExtendedInterface(KUidOpenFontGlyphOutlineExtension, ext);
- MOpenFontGlyphOutlineExtension *extensionInterface =
- reinterpret_cast<MOpenFontGlyphOutlineExtension*>(ext);
-
- TInt ret = KErrNone;
- if (extensionInterface == NULL)
- {
- ret = KErrNotSupported;
- }
- else
- {
- ret = extensionInterface->GetGlyphOutline(aCode, ETrue,
- aHinted, aOutline, aLength);
- }
- return ret;
- }
-
/** Given the passed pointer aAny, return an offset from it to the "this" pointer
of this COpenFont object.
@param aAny A pointer to an object that exists on the shared heap, i.e. the same heap
@@ -1698,11 +1648,6 @@
*/
EXPORT_C COpenFontFile::~COpenFontFile()
{
- CFontStore *fs = GetFontStore();
- if (fs != NULL)
- {
- fs->CleanupCacheOnOpenFontFileRemoval(this);
- }
delete iData;
}
--- a/fontservices/fontstore/src/patchableconstants.cpp Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/src/patchableconstants.cpp Fri Mar 12 15:51:09 2010 +0200
@@ -25,13 +25,6 @@
*/
EXPORT_C extern const TInt8 KLinkedFontDrive = 0x63; //c in ASCII
-/**
-@internalTechnology
-
-The maximum size of memory used by the font table cache and the glyph outline cache.
- */
-EXPORT_C extern const TUint32 KFontTable_GlyphOutline_CacheMaxMem = 4 * 0x100000; // 4 Mega bytes.
-
#if (__ARMCC_VERSION <= 310000)
#include "FNTSTORE.H"
#endif
--- a/fontservices/fontstore/tfs/TFntStoreServer.cpp Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/tfs/TFntStoreServer.cpp Fri Mar 12 15:51:09 2010 +0200
@@ -43,7 +43,6 @@
#include "t_linkedfontscomparison.h"
#include "t_linkedfontscapability.h"
#include "T_LinkedFontUpdateTests.h"
-#include "T_CACHE.H"
#include "T_FontSessionCache.h"
CTFntStoreServer* CTFntStoreServer::NewL()
@@ -203,10 +202,6 @@
{
return new CTLinkedFontsUpdateStage2Step();
}
- else if (aStepName == KTCacheStep)
- {
- return new CTCacheStep();
- }
else if (aStepName == KTFontSessionCacheStep)
{
return new CTFontSessionCacheStep();
--- a/fontservices/fontstore/tfs/scripts/fntstoretest_T_All.script Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/tfs/scripts/fntstoretest_T_All.script Fri Mar 12 15:51:09 2010 +0200
@@ -20,7 +20,6 @@
//
LOAD_SUITE TFntStoreServer
RUN_TEST_STEP 300 TFntStoreServer TFnt
-RUN_TEST_STEP 300 TFntStoreServer TCache
RUN_TEST_STEP 100 TFntStoreServer TFntMem
RUN_TEST_STEP 100 TFntStoreServer TFontBitmap
RUN_TEST_STEP 100 TFntStoreServer TFsOpen
--- a/fontservices/fontstore/tfs/scripts/fntstoretest_run.bat Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/fontstore/tfs/scripts/fntstoretest_run.bat Fri Mar 12 15:51:09 2010 +0200
@@ -30,7 +30,6 @@
testexecute.exe z:\fntstoretest\fntstoretest_t_cachedeletion.script
testexecute.exe z:\fntstoretest\fntstoretest_t_setdefaulttypefacename.script
testexecute.exe z:\fntstoretest\fntstoretest_t_linkedfonts.script
-testexecute.exe z:\fntstoretest\fntstoretest_t_cache.script
testexecute.exe z:\fntstoretest\fntstoretest_t_fontsessioncache.script
@echo off
--- a/fontservices/freetypefontrasteriser/src/FTRAST2.CPP Sat Feb 20 00:37:46 2010 +0200
+++ b/fontservices/freetypefontrasteriser/src/FTRAST2.CPP Fri Mar 12 15:51:09 2010 +0200
@@ -159,8 +159,6 @@
COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
TBool HasUnicodeCharacterL(TInt aFaceIndex, TInt aCode) const;
TAny* GetTrueTypeTable(TInt& aError, TInt aFaceIndex, TUint32 aTag, TInt* aLength);
- TInt GetGlyphOutline(TInt aFaceIndex, TUint aCode,
- TBool aIsGlyphId, TBool, TAny*& aOutline, TInt &aLength);
private:
static void SetGlyphMetrics(FT_GlyphSlot aGlyphSlot, TOpenFontGlyphData* aGlyphData);
@@ -184,7 +182,7 @@
};
NONSHARABLE_CLASS(CFreeTypeFont) : public COpenFont, public MOpenFontShapingExtension,
- public MOpenFontTrueTypeExtension, public MOpenFontGlyphOutlineExtension
+ public MOpenFontTrueTypeExtension
{
public:
static CFreeTypeFont* NewL(
@@ -218,8 +216,6 @@
TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength);
TInt ReleaseTrueTypeTable(TAny* aTable);
TBool HasTrueTypeTable(TUint32 aTag);
- TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
- TBool aHinted, TAny*& aOutline, TInt &aLength);
inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW;
inline TAny* operator new(TUint aSize) __NO_THROW;
@@ -1070,8 +1066,6 @@
aParam = static_cast<MOpenFontShapingExtension*>(this);
else if (aUid == KUidOpenFontTrueTypeExtension)
aParam = static_cast<MOpenFontTrueTypeExtension*>(this);
- else if (aUid == KUidOpenFontGlyphOutlineExtension)
- aParam = static_cast<MOpenFontGlyphOutlineExtension*>(this);
else
COpenFont::ExtendedInterface(aUid, aParam);
}
@@ -1175,18 +1169,7 @@
}
-TInt CFreeTypeFont::GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
- TBool aHinted, TAny*& aOutline, TInt& aLength)
- {
- CFreeTypeFontFile* file = (CFreeTypeFontFile*)File();
- if (!file)
- {
- return KErrNotFound;
- }
- aHinted = EFalse; // to avoid 'unused' warning.
-
- return file->GetGlyphOutline(FaceIndex(), aCode, aIsGlyphId, aHinted, aOutline, aLength);
- }
+
TAny* CFreeTypeFont::GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength)
{
@@ -1301,483 +1284,6 @@
iContext->TranslateAntiAliasedGlyphBitmap(aFace->Face()->glyph,aGlyphData);
}
-enum vg_commands {
- VG_CMD_NONE = 0,
- VG_CMD_MOVETO,
- VG_CMD_LINETO,
- VG_CMD_CONICTO,
- VG_CMD_CUBICTO,
- VG_CMD_CLOSE
-};
-
-
-enum contour_states
- {
- CONTOUR_STATE_NOT_STARTED = 0,
- CONTOUR_STATE_START,
- CONTOUR_STATE_CONIC,
- CONTOUR_STATE_CUBIC1,
- CONTOUR_STATE_CUBIC2,
- CONTOUR_STATE_MAX
- };
-
-static const TInt StateTransitions[CONTOUR_STATE_MAX][3] =
- {
- {CONTOUR_STATE_START, -1, -1},
- {CONTOUR_STATE_START, CONTOUR_STATE_CONIC, CONTOUR_STATE_CUBIC1},
- {CONTOUR_STATE_START, -1, -1},
- {-1, -1, CONTOUR_STATE_CUBIC2},
- {CONTOUR_STATE_START, -1, -1},
- };
-
-static const TInt OutputCommands[CONTOUR_STATE_MAX][3] =
- {
- {VG_CMD_MOVETO, -1, -1},
- {VG_CMD_LINETO, VG_CMD_NONE, VG_CMD_NONE},
- {VG_CMD_CONICTO, -1, -1},
- {-1, -1, VG_CMD_NONE},
- {VG_CMD_CUBICTO, -1, -1},
- };
-
-
-class MVGCommandProcessor
- {
-public:
- virtual TInt ProcessCommand(TInt8 cmd, FT_Vector &start, FT_Vector &end) = 0;
- };
-
-class COutlineStringBuilder: public MVGCommandProcessor, public CBase
- {
-private:
- TUint8 *iBuffer;
- TUint8 *iCur;
- TInt iLen;
-
-
-public:
- COutlineStringBuilder():iBuffer(0), iLen(2000)
- {
- iBuffer = (TUint8 *)User::Alloc(iLen);
- iCur = iBuffer;
- }
-
- ~COutlineStringBuilder()
- {
- // ownership of the buffer is transferred to the caller.
- }
-
-
- TUint8 *GetBuffer(TInt &aLen)
- {
- aLen = iCur - iBuffer;
- *iCur = '\0';
- return iBuffer;
- }
-
- TInt AppendChar(char ch)
- {
- *(iCur++) = ch;
- return 0;
- }
-
- TInt AppendFTPos(FT_Pos n)
- {
- int divisor = 1;
- FT_Pos tmp = (n > 0) ? n : (-n);
- while (tmp/divisor >= 10) {
- divisor *= 10;
- }
-
- if (n < 0)
- {
- AppendChar('-');
- }
-
- for ( ; divisor >= 1; divisor /= 10)
- {
- AppendChar('0' + tmp/divisor);
- tmp = tmp % divisor;
- }
-
- return 0;
- }
-
- TInt AppendCoord(FT_Pos x, FT_Pos y)
- {
- AppendFTPos(x);
- AppendChar(',');
- AppendFTPos(y);
- AppendChar(' ');
- return 0;
- }
-
- TInt
- ProcessCommand(TInt8 cmd, FT_Vector &start, FT_Vector &end)
- {
- FT_Vector *st = &start;
-
- if (iCur + 64 > iBuffer + iLen)
- {
- TUint distance = iCur - iBuffer;
- iLen += 1000;
- TUint8 *newBuffer = (TUint8 *)User::ReAlloc(iBuffer, iLen);
- iBuffer = newBuffer;
- iCur = iBuffer + distance;
- }
-
- if (VG_CMD_MOVETO == cmd)
- {
- AppendChar('M');
- AppendCoord(start.x, start.y);
- }
- else if (VG_CMD_LINETO == cmd)
- {
- AppendChar('L');
- AppendCoord(end.x, end.y);
- }
- else if (VG_CMD_CONICTO == cmd)
- {
- AppendChar('Q');
- AppendCoord((st+1)->x, (st+1)->y);
- AppendCoord(end.x, end.y);
- }
- else if (VG_CMD_CUBICTO == cmd)
- {
- AppendChar('Q');
- AppendCoord((st+1)->x, (st+1)->y);
- AppendCoord((st+2)->x, (st+2)->y);
- AppendCoord(end.x, end.y);
- }
- else if (VG_CMD_CLOSE == cmd)
- {
- AppendChar('Z');
- AppendChar(' ');
- }
-
- return KErrNone;
- }
- };
-
-
-class COutlineConvDirector: public CBase {
-private:
- MVGCommandProcessor *iProcessor;
- const FT_Outline *iOutline;
- FT_Outline iNewOutline;
-
-
-private:
- char
- GetNextPointType(char aTag)
- {
- char ret = FT_CURVE_TAG(aTag);
- if (FT_CURVE_TAG_ON == ret)
- {
- ret = 0;
- }
- else if (FT_CURVE_TAG_CONIC == ret)
- {
- ret = 1;
- }
- else if (FT_CURVE_TAG_CUBIC == ret)
- {
- ret = 2;
- }
- else
- {
- __ASSERT_DEBUG(0, User::Panic(_L("IncorrectState"), -1));
- }
- return ret;
- }
-
- TInt SwapPoints(const TInt i1, const TInt i2)
- {
- FT_Vector tmpVector = iOutline->points[i1];
- char tmpTags = iOutline->tags[i1];
- iOutline->points[i1] = iOutline->points[i2];
- iOutline->tags[i1] = iOutline->tags[i2];
- iOutline->points[i2] = tmpVector;
- iOutline->tags[i2] = tmpTags;
- return 0;
- }
-
- TInt MoveFirstOnPointToBeginning(const TInt aStartIndex, const TInt aEndIndex)
- {
- /* Contours of three or more points are valid, and single points
- * (reference points, technically not contours) are also valid as
- * special cases in TrueType.
- */
- char curTag = FT_CURVE_TAG(iOutline->tags[aStartIndex]);
-
- // so a contour having only one point which is 'off' is invalid!
- __ASSERT_DEBUG(!(aEndIndex - aStartIndex == 0 && FT_CURVE_TAG_ON != curTag),
- User::Panic(_L("Contour consisting of 1 'off' point."), -1));
-
- /* Contours consisting of two points are not a valid configuration. */
- __ASSERT_DEBUG(aEndIndex - aStartIndex != 1,
- User::Panic(_L("Contour consisting of two points."), -1));
-
- if (FT_CURVE_TAG_ON == curTag)
- {
- return KErrNone;
- }
- TInt firstOnIndex = -1;
- TInt i = 0;
- for (i = 1+aStartIndex; i < aEndIndex; ++i)
- {
- if (FT_CURVE_TAG_ON == FT_CURVE_TAG(iOutline->tags[i]))
- {
- firstOnIndex = i;
- break;
- }
- }
- __ASSERT_DEBUG(-1 != firstOnIndex,
- User::Panic(_L("Contour containing no 'on' point."), -1));
-
- for (i = firstOnIndex-1; i >= aStartIndex; --i)
- {
- for (TInt j = i; j < aEndIndex; ++j)
- {
- SwapPoints(j, j+1);
- }
- }
-
- return KErrNone;
- }
-
- TInt
- ConvertContour(const TInt aStartIndex, const TInt aEndIndex)
- {
- /* Contours consisting of two
- * points are not a valid configuration.
- */
- __ASSERT_DEBUG(aEndIndex - aStartIndex != 1,
- User::Panic(_L("Contour consisting of two points."), -1));
-
- TInt state = CONTOUR_STATE_NOT_STARTED, newState = -1;
- TInt cmdStart = aStartIndex, cmdCur = 0, command = -1;
-
- char ptype = GetNextPointType(iNewOutline.tags[cmdStart]);
- __ASSERT_DEBUG(0 == ptype, User::Panic(_L("IncorrectState"), -1));
- state = CONTOUR_STATE_START;
- iProcessor->ProcessCommand(VG_CMD_MOVETO,
- iNewOutline.points[aStartIndex], iNewOutline.points[aStartIndex]);
-
-
- for (cmdCur = cmdStart + 1; cmdCur <= aEndIndex; ++cmdCur)
- {
- ptype = GetNextPointType(iNewOutline.tags[cmdCur]);
- newState = StateTransitions[state][ptype];
- __ASSERT_DEBUG(-1 != newState, User::Panic(_L("IncorrectState"), -1));
- command = OutputCommands[state][ptype];
- __ASSERT_DEBUG(-1 != command, User::Panic(_L("IncorrectState"), -1));
-
- if (VG_CMD_NONE != command)
- {
- iProcessor->ProcessCommand(command,
- iNewOutline.points[cmdStart], iNewOutline.points[cmdCur]);
- cmdStart = cmdCur;
- }
- state = newState;
- }
-
- if (CONTOUR_STATE_CONIC == state)
- {
- iProcessor->ProcessCommand(VG_CMD_CONICTO, iNewOutline.points[cmdStart],
- iNewOutline.points[aStartIndex]);
- }
- else if (CONTOUR_STATE_CUBIC2 == state)
- {
- iProcessor->ProcessCommand(VG_CMD_CUBICTO, iNewOutline.points[cmdStart],
- iNewOutline.points[aStartIndex]);
- }
- iProcessor->ProcessCommand(VG_CMD_CLOSE,
- iNewOutline.points[aStartIndex], iNewOutline.points[aStartIndex]);
-
- return KErrNone;
- }
-
-
- TInt Preprocess()
- {
- /* two successive conic "off" points forces the rasterizer to
- * create (during the scan-line conversion process exclusively) a
- * virtual "on" point amidst them, at their exact middle.
- */
- char prevTag = FT_CURVE_TAG(iOutline->tags[0]), currentTag = 0;
- TInt numNewPoints = 0;
- TInt contourIndex = 0;
-
- iNewOutline.contours = 0;
- iNewOutline.n_contours = iOutline->n_contours;
- iNewOutline.contours = (short *)
- User::Alloc(iNewOutline.n_contours * sizeof(short));
-
- if (0 == iOutline->contours[0])
- {
- iNewOutline.contours[0] = iOutline->contours[0]; // == 0
- ++contourIndex;
- }
- for (TInt i = 1; i < iOutline->n_points; ++i)
- {
- currentTag = FT_CURVE_TAG(iOutline->tags[i]);
- if (FT_CURVE_TAG_CONIC == prevTag && prevTag == currentTag)
- {
- numNewPoints++;
- }
- prevTag = currentTag;
- if (i == iOutline->contours[contourIndex])
- {
- iNewOutline.contours[contourIndex] =
- iOutline->contours[contourIndex] + numNewPoints;
- ++contourIndex;
- }
- }
-
-
- iNewOutline.n_points = iOutline->n_points + numNewPoints;
- iNewOutline.flags = iOutline->flags;
-
- iNewOutline.points = 0;
- iNewOutline.tags = 0;
-
- iNewOutline.points = (FT_Vector *)
- User::Alloc(iNewOutline.n_points * sizeof(FT_Vector));
-
- if (iNewOutline.contours)
- {
- iNewOutline.tags = (char *)
- User::Alloc(iNewOutline.n_points * sizeof(char));
- }
-
- // copy the 'points' and 'tags' array, inserting new points
- // when necessary.
- TInt oldIndex = 0, newIndex = 0;
- for ( ; oldIndex < iOutline->n_points; ++oldIndex)
- {
- char oldTag = FT_CURVE_TAG(iOutline->tags[oldIndex]);
- iNewOutline.points[newIndex] = iOutline->points[oldIndex];
- iNewOutline.tags[newIndex] = iOutline->tags[oldIndex];
-
- if (FT_CURVE_TAG_CONIC == oldTag &&
- oldIndex + 1 < iOutline->n_points)
- {
- char nextTag = FT_CURVE_TAG(iOutline->tags[oldIndex+1]);
- // insert a new 'on' point when there are two consecutive
- // 'conic off' points.
- if (oldTag == nextTag)
- {
- newIndex++;
- FT_Vector *cur = &(iOutline->points[oldIndex]);
- FT_Vector *next = &(iOutline->points[oldIndex + 1]);
- iNewOutline.points[newIndex].x = (cur->x + next->x)/2;
- iNewOutline.points[newIndex].y = (cur->y + next->y)/2;
- iNewOutline.tags[newIndex] = FT_CURVE_TAG_ON;
- }
- }
- newIndex++;
- }
-
- return 0;
- }
-
-public:
- COutlineConvDirector():iProcessor(0), iOutline(0)
- {
- // a null constructor
- iNewOutline.contours = 0;
- iNewOutline.tags = 0;
- iNewOutline.points = 0;
- }
-
- ~COutlineConvDirector()
- {
- User::Free(iNewOutline.contours);
- User::Free(iNewOutline.points);
- User::Free(iNewOutline.tags);
- }
-
- TInt
- ConvertOutline(const FT_Outline &aOutline, MVGCommandProcessor *aProcessor)
- {
- if (0 != aOutline.n_contours)
- {
- iProcessor = aProcessor;
- iOutline = &aOutline;
-
- MoveFirstOnPointToBeginning(0, iOutline->contours[0]);
- TInt i = 0;
- for (i = 1; i < iOutline->n_contours; ++i)
- {
- MoveFirstOnPointToBeginning(iOutline->contours[i-1]+1, iOutline->contours[i]);
- }
-
- Preprocess();
-
- ConvertContour(0, iNewOutline.contours[0]);
- for (i = 1; i < iNewOutline.n_contours; ++i)
- {
- ConvertContour(iNewOutline.contours[i-1]+1, iNewOutline.contours[i]);
- }
- }
- else
- {
- RDebug::Printf("Zero contour in outline: missing glyph.");
- FT_Vector dummyVector;
- aProcessor->ProcessCommand(VG_CMD_CLOSE, dummyVector, dummyVector);
- }
- return KErrNone;
- }
-};
-
-
-TInt CFreeTypeFontFile::GetGlyphOutline(TInt aFaceIndex, TUint aCode,
- TBool aIsGlyphId, TBool, TAny*& aOutline, TInt &aLength)
- {
- // The 4th param 'aHinted' is ignored in this reference implementation.
- // Need to add it back and implement accordingly if freetype is used in
- // production code.
- CFaceListItem *faceList = LoadFaceL(aFaceIndex);
- FT_Face face = faceList->Face();
- TUint code = aCode;
- if (!aIsGlyphId)
- {
- code = FT_Get_Char_Index(face, aCode);
- if (0 == code)
- {
- return KErrNotFound;
- }
- }
-
- TInt ret = FT_Load_Glyph(face, code,
- FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM);
-
- if (0 != ret)
- {
- return KErrUnknown;
- }
-
- COutlineStringBuilder strBuilder;
- if (0 != strBuilder.GetBuffer(aLength))
- {
- FT_Outline &outline = face->glyph->outline;
-
- COutlineConvDirector d;
- d.ConvertOutline(outline, &strBuilder);
- }
- else
- {
- return KErrNoMemory;
- }
-
- TUint8 *buf = strBuilder.GetBuffer(aLength);
- RDebug::Printf("length of buffer is %d\n", aLength);
- RDebug::Printf("Outline for glyph %d: \n", aCode);
- RDebug::Printf("%s", buf);
- aOutline = (TAny*)buf;
-
- return KErrNone;
- }
TAny* CFreeTypeFontFile::GetTrueTypeTable(TInt& aError, TInt aFaceIndex,
TUint32 aTag, TInt* aLength)
{
--- a/textrendering/textformatting/tagma/TMSOURCE.CPP Sat Feb 20 00:37:46 2010 +0200
+++ b/textrendering/textformatting/tagma/TMSOURCE.CPP Fri Mar 12 15:51:09 2010 +0200
@@ -251,6 +251,9 @@
EXPORT_C void MTmCustom::SetPenColor(CGraphicsContext& aGc,TLogicalRgb aColor) const
{
MTmCustomExtension c;
+ TUint index = aColor.SystemColorIndex();
+ if (index)
+ aColor = SystemColor(index,aColor) & 0xFFFFFF;
c.SetPenColor(aGc,aColor);
}
--- a/textrendering/textformatting/tbox/LAYEMU.CPP Sat Feb 20 00:37:46 2010 +0200
+++ b/textrendering/textformatting/tbox/LAYEMU.CPP Fri Mar 12 15:51:09 2010 +0200
@@ -4012,7 +4012,9 @@
if (aDy > 0) // text moves down; iBandTop decreases
{
if (aTopNoLimitBorder)
- iBandTop = desired_bandtop;
+ {
+ iBandTop = Max(0 - iText->LayoutHeight(),desired_bandtop);
+ }
else
iBandTop = Max(0,desired_bandtop);//Disallow text scrolled beyond top border
@@ -4056,6 +4058,19 @@
if (!AddFormattingAtEndL(param, height_increase,paragraphs_increase))
break;
}
+
+ // Shift the whole band upwards if we're at the very end of the text
+ // and there's no more text to format. This prevents a situation were
+ // iText->LayoutHeight() < BandHeightInPixels.
+ if ( aBottomNoLimitBorder && iText->LayoutHeight() - iBandTop < visible_height )
+ {
+ if ( iText->EndChar() > iText->Source()->DocumentLength() )
+ {
+ iBandTop = desired_bandtop;
+ return pixels_scrolled;
+ }
+ }
+
}
// Scroll blank space off the display if desired.