--- a/fbs/fontandbitmapserver/sfbs/FBSTOP.CPP Tue Jun 22 15:21:29 2010 +0300
+++ b/fbs/fontandbitmapserver/sfbs/FBSTOP.CPP Fri Jul 16 11:45:55 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
@@ -18,7 +18,6 @@
#include <fntstore.h>
#include <bitmap.h>
#include <ecom/ecom.h>
-#include "FbsMessage.H"
#include <graphics/bitmapuid.h>
#include "SERVER.H"
#include "BackGroundCompression.h"
@@ -27,6 +26,8 @@
#include <graphics/openfontconstants.h>
#include <graphics/openfontrasterizer.h>
#include <graphics/gdi/glyphsample.h>
+#include "glyphatlas.h"
+#include "FbsMessage.H"
// Local utility functions
void ListImplementationsWithRetry(TUid& aInterfaceUid, RImplInfoPtrArray &aImplementationArray, TBool aRomOnly);
@@ -61,6 +62,7 @@
#endif
iFontNameAlias.ResetAndDestroy();
iBitmapObjectIndex.Reset();
+ delete iGlyphAtlas;
REComSession::FinalClose();
}
@@ -140,9 +142,15 @@
iMBMCache=new (ELeave) CFbTopStreamIdCache(30,30,5);
LoadOpenFontLibraries();
-
iFontStore->LoadFontsAtStartupL();
LoadShaperFactories();
+ TRAP_IGNORE(iGlyphAtlas = CGlyphAtlas::NewL(KFbServGlyphAtlasCacheLimit);)
+#ifdef _DEBUG
+ if (!iGlyphAtlas)
+ {
+ RDebug::Printf("FBSERV failed to initialize Glyph Atlas");
+ }
+#endif
// start a new thread for background compression after all the other objects have been created
iBackgroundCompression = CFbsBackgroundCompression::NewL(*this);
@@ -307,8 +315,8 @@
{
return ret;
}
-
- return CreateFontObjectFromFont(aFontObjPtr, font);
+
+ return GetFontObjectFromFont(aFontObjPtr, font);
}
/**
@@ -349,9 +357,27 @@
return ret;
}
-TInt CFbTop::CreateFontObjectFromFont(CFontObject*& aFontObjPtr, CFont* aFont)
+TInt CFbTop::GetFontObjectFromFont(CFontObject*& aFontObjPtr, CFont* aFont)
{
- CFontObject* fontObjPtr = new CFontObject(iFontStore);
+ // First, check if a CFontObject exists for this CFont.
+ // If so, increment its reference count and return it.
+ for (TInt ii = iFontCon->Count() - 1; ii >= 0; --ii)
+ {
+ CFontObject* fontObjPtr = reinterpret_cast<CFontObject*>((*iFontCon)[ii]);
+ if (fontObjPtr->iAddressPointer == reinterpret_cast<CBitmapFont*>(aFont))
+ {
+ aFontObjPtr = fontObjPtr;
+ // The CFontObject instance keeps the reference count of the CBitmapFont,
+ // not the font store. There is only one CFontObject instance
+ // per CBitmapFont, so to keep the reference count at 1 in the fontstore
+ // call ReleaseFont().
+ iFontStore->ReleaseFont(aFont);
+ return fontObjPtr->Open();
+ }
+ }
+
+ // Existing FontObject not found, so create new one.
+ CFontObject* fontObjPtr = new CFontObject(iFontStore, iGlyphAtlas);
if (!fontObjPtr)
{
iFontStore->ReleaseFont(aFont);
@@ -389,7 +415,7 @@
{
return ret;
}
- return CreateFontObjectFromFont(aFontObjPtr, font);
+ return GetFontObjectFromFont(aFontObjPtr, font);
}
@@ -561,18 +587,6 @@
return(EFalse);
}
-TBool CFbTop::ValidBitmapFont(TInt aHandle)
- {
- TInt limit=iFontCon->Count();
- for(TInt count=0;count<limit;count++)
- {
- CFontObject* fontObjPtr = reinterpret_cast<CFontObject*>((*iFontCon)[count]);
- if(aHandle==(TInt)(fontObjPtr->iAddressPointer))
- return(ETrue);
- }
- return(EFalse);
- }
-
CFontStore* CFbTop::FontStore() const
{
return(iFontStore);
@@ -724,3 +738,8 @@
{
return iFontCon->UniqueID();
}
+
+CGlyphAtlas* CFbTop::GlyphAtlas() const
+ {
+ return iGlyphAtlas;
+ }