equal
deleted
inserted
replaced
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
16 #include <hal.h> |
16 #include <hal.h> |
17 #include <gdi.h> |
17 #include <gdi.h> |
18 #include <fntstore.h> |
18 #include <fntstore.h> |
19 #include <bitmap.h> |
19 #include <bitmap.h> |
20 #include <ecom/ecom.h> |
20 #include <ecom/ecom.h> |
21 #include "fbsmessage.h" |
|
22 #include <graphics/bitmapuid.h> |
21 #include <graphics/bitmapuid.h> |
23 #include "SERVER.H" |
22 #include "SERVER.H" |
24 #include "BackGroundCompression.h" |
23 #include "BackGroundCompression.h" |
25 #include "BitwiseBitmap.inl" |
24 #include "BitwiseBitmap.inl" |
26 #include "bitmapconst.h" |
25 #include "bitmapconst.h" |
27 #include <graphics/openfontconstants.h> |
26 #include <graphics/openfontconstants.h> |
28 #include <graphics/openfontrasterizer.h> |
27 #include <graphics/openfontrasterizer.h> |
29 #include <graphics/gdi/glyphsample.h> |
28 #include <graphics/gdi/glyphsample.h> |
|
29 #include "glyphatlas.h" |
|
30 #include "FbsMessage.H" |
30 |
31 |
31 // Local utility functions |
32 // Local utility functions |
32 void ListImplementationsWithRetry(TUid& aInterfaceUid, RImplInfoPtrArray &aImplementationArray, TBool aRomOnly); |
33 void ListImplementationsWithRetry(TUid& aInterfaceUid, RImplInfoPtrArray &aImplementationArray, TBool aRomOnly); |
33 |
34 |
34 |
35 |
59 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP |
60 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP |
60 iDebugMutex.Close(); |
61 iDebugMutex.Close(); |
61 #endif |
62 #endif |
62 iFontNameAlias.ResetAndDestroy(); |
63 iFontNameAlias.ResetAndDestroy(); |
63 iBitmapObjectIndex.Reset(); |
64 iBitmapObjectIndex.Reset(); |
|
65 delete iGlyphAtlas; |
64 REComSession::FinalClose(); |
66 REComSession::FinalClose(); |
65 } |
67 } |
66 |
68 |
67 CFbTop* CFbTop::NewL() |
69 CFbTop* CFbTop::NewL() |
68 { |
70 { |
138 // The cache will also store maximum 5 mbm files. This number must be as low as possible |
140 // The cache will also store maximum 5 mbm files. This number must be as low as possible |
139 // while trying to minimize flushing of the cache due to mbm file switching. |
141 // while trying to minimize flushing of the cache due to mbm file switching. |
140 iMBMCache=new (ELeave) CFbTopStreamIdCache(30,30,5); |
142 iMBMCache=new (ELeave) CFbTopStreamIdCache(30,30,5); |
141 |
143 |
142 LoadOpenFontLibraries(); |
144 LoadOpenFontLibraries(); |
143 |
|
144 iFontStore->LoadFontsAtStartupL(); |
145 iFontStore->LoadFontsAtStartupL(); |
145 LoadShaperFactories(); |
146 LoadShaperFactories(); |
|
147 TRAP_IGNORE(iGlyphAtlas = CGlyphAtlas::NewL(KFbServGlyphAtlasCacheLimit);) |
|
148 #ifdef _DEBUG |
|
149 if (!iGlyphAtlas) |
|
150 { |
|
151 RDebug::Printf("FBSERV failed to initialize Glyph Atlas"); |
|
152 } |
|
153 #endif |
146 |
154 |
147 // start a new thread for background compression after all the other objects have been created |
155 // start a new thread for background compression after all the other objects have been created |
148 iBackgroundCompression = CFbsBackgroundCompression::NewL(*this); |
156 iBackgroundCompression = CFbsBackgroundCompression::NewL(*this); |
149 } |
157 } |
150 |
158 |
305 |
313 |
306 if (ret != KErrNone) |
314 if (ret != KErrNone) |
307 { |
315 { |
308 return ret; |
316 return ret; |
309 } |
317 } |
310 |
318 |
311 return CreateFontObjectFromFont(aFontObjPtr, font); |
319 return GetFontObjectFromFont(aFontObjPtr, font); |
312 } |
320 } |
313 |
321 |
314 /** |
322 /** |
315 Gets the nearest matching loaded font for a given font specification. |
323 Gets the nearest matching loaded font for a given font specification. |
316 |
324 |
347 } |
355 } |
348 } |
356 } |
349 return ret; |
357 return ret; |
350 } |
358 } |
351 |
359 |
352 TInt CFbTop::CreateFontObjectFromFont(CFontObject*& aFontObjPtr, CFont* aFont) |
360 TInt CFbTop::GetFontObjectFromFont(CFontObject*& aFontObjPtr, CFont* aFont) |
353 { |
361 { |
354 CFontObject* fontObjPtr = new CFontObject(iFontStore); |
362 // First, check if a CFontObject exists for this CFont. |
|
363 // If so, increment its reference count and return it. |
|
364 for (TInt ii = iFontCon->Count() - 1; ii >= 0; --ii) |
|
365 { |
|
366 CFontObject* fontObjPtr = reinterpret_cast<CFontObject*>((*iFontCon)[ii]); |
|
367 if (fontObjPtr->iAddressPointer == reinterpret_cast<CBitmapFont*>(aFont)) |
|
368 { |
|
369 aFontObjPtr = fontObjPtr; |
|
370 // The CFontObject instance keeps the reference count of the CBitmapFont, |
|
371 // not the font store. There is only one CFontObject instance |
|
372 // per CBitmapFont, so to keep the reference count at 1 in the fontstore |
|
373 // call ReleaseFont(). |
|
374 iFontStore->ReleaseFont(aFont); |
|
375 return fontObjPtr->Open(); |
|
376 } |
|
377 } |
|
378 |
|
379 // Existing FontObject not found, so create new one. |
|
380 CFontObject* fontObjPtr = new CFontObject(iFontStore, iGlyphAtlas); |
355 if (!fontObjPtr) |
381 if (!fontObjPtr) |
356 { |
382 { |
357 iFontStore->ReleaseFont(aFont); |
383 iFontStore->ReleaseFont(aFont); |
358 return KErrNoMemory; |
384 return KErrNoMemory; |
359 } |
385 } |
387 TInt ret=iFontStore->GetFontById((CFont*&)font,aUid,(TAlgStyle&)aAlgStyle); |
413 TInt ret=iFontStore->GetFontById((CFont*&)font,aUid,(TAlgStyle&)aAlgStyle); |
388 if (ret != KErrNone) |
414 if (ret != KErrNone) |
389 { |
415 { |
390 return ret; |
416 return ret; |
391 } |
417 } |
392 return CreateFontObjectFromFont(aFontObjPtr, font); |
418 return GetFontObjectFromFont(aFontObjPtr, font); |
393 } |
419 } |
394 |
420 |
395 |
421 |
396 /** Create a bitmap with the given size, display mode and UID. |
422 /** Create a bitmap with the given size, display mode and UID. |
397 |
423 |
559 if(aHandle==(TInt)((*iFontCon)[count])) |
585 if(aHandle==(TInt)((*iFontCon)[count])) |
560 return(ETrue); |
586 return(ETrue); |
561 return(EFalse); |
587 return(EFalse); |
562 } |
588 } |
563 |
589 |
564 TBool CFbTop::ValidBitmapFont(TInt aHandle) |
|
565 { |
|
566 TInt limit=iFontCon->Count(); |
|
567 for(TInt count=0;count<limit;count++) |
|
568 { |
|
569 CFontObject* fontObjPtr = reinterpret_cast<CFontObject*>((*iFontCon)[count]); |
|
570 if(aHandle==(TInt)(fontObjPtr->iAddressPointer)) |
|
571 return(ETrue); |
|
572 } |
|
573 return(EFalse); |
|
574 } |
|
575 |
|
576 CFontStore* CFbTop::FontStore() const |
590 CFontStore* CFbTop::FontStore() const |
577 { |
591 { |
578 return(iFontStore); |
592 return(iFontStore); |
579 } |
593 } |
580 |
594 |
722 |
736 |
723 TInt CFbTop::FontConUniqueID() const |
737 TInt CFbTop::FontConUniqueID() const |
724 { |
738 { |
725 return iFontCon->UniqueID(); |
739 return iFontCon->UniqueID(); |
726 } |
740 } |
|
741 |
|
742 CGlyphAtlas* CFbTop::GlyphAtlas() const |
|
743 { |
|
744 return iGlyphAtlas; |
|
745 } |