Update contrib.
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 @internalComponent - Internal Symbian test code
21 #include "glyphatlastestwrapper.h"
24 Panic function required for glyphatlas.cpp to compile in the test project.
26 GLDEF_C void Panic(TFbsPanic aPanic)
28 _LIT(KFBSERVClientPanicCategory,"FBSCLI");
29 User::Panic(KFBSERVClientPanicCategory,aPanic);
34 Glyph Atlas test wrapper constructor.
36 CGlyphAtlasTestWrapper::CGlyphAtlasTestWrapper()
41 Two-phase constructor.
42 @leave A system wide error code if RSgDriver failed to open.
44 void CGlyphAtlasTestWrapper::ConstructL(TInt aMaxCacheSizeInBytes)
46 iAtlas = CGlyphAtlas::NewL(aMaxCacheSizeInBytes);
50 Factory constructor method. Creates a new glyph atlas test wrapper.
52 @param aMaxCacheSizeInBytes The size in bytes, to use as the upper limit
53 for the size of memory used by the glyph images in the atlas. If this
54 value is KGlyphAtlasNoCacheLimit, then there is no limit and the atlas
55 will use as much memory as is available in the system.
57 @return A pointer to the newly-constructed atlas test wrapper
59 @leave KErrNoMemory if there was insufficient memory to create the atlas,
60 or a system wide error code if its RSgDriver failed to open.
62 CGlyphAtlasTestWrapper* CGlyphAtlasTestWrapper::NewL(TInt aMaxCacheSizeInBytes)
64 CGlyphAtlasTestWrapper* self = CGlyphAtlasTestWrapper::NewLC( aMaxCacheSizeInBytes );
65 CleanupStack::Pop(); // self;
70 CGlyphAtlasTestWrapper* CGlyphAtlasTestWrapper::NewLC(TInt aMaxCacheSizeInBytes)
72 CGlyphAtlasTestWrapper* self = new (ELeave) CGlyphAtlasTestWrapper();
73 CleanupStack::PushL(self);
74 self->ConstructL(aMaxCacheSizeInBytes);
79 TInt CGlyphAtlasTestWrapper::GetGlyph(const CBitmapFont& aFont, TUint aGlyphCode, TGlyphImageInfo& aGlyphImageInfo)
81 return iAtlas->GetGlyph(aFont, aGlyphCode, aGlyphImageInfo);
84 TInt CGlyphAtlasTestWrapper::AddGlyph(const CBitmapFont& aFont, const CGlyphAtlas::TAddGlyphArgs& aArgs, TGlyphImageInfo& aGlyphImageInfo)
86 return iAtlas->AddGlyph(aFont, aArgs, aGlyphImageInfo);
89 void CGlyphAtlasTestWrapper::FontReleased(const CBitmapFont& aFont)
91 iAtlas->FontReleased(aFont);
95 Returns the current size of the glyph image memory used by the atlas in bytes.
97 TInt CGlyphAtlasTestWrapper::SizeInBytes() const
99 return iAtlas->iCacheSizeInBytes;
103 Tests whether the least recently used page contains the given glyph.
104 @param aGlyphCode The glyph code to match.
105 @return ETrue if the lru page contains the given glyph, EFalse if not.
107 TBool CGlyphAtlasTestWrapper::LruPageContainsGlyph(TUint aGlyphCode) const
109 CGlyphAtlasPage* page = iAtlas->iLruPageList.Last();
110 TInt numGlyphsInPage = page->GlyphCount();
111 TBool glyphFound = EFalse;
112 for (TInt ii = 0; ii < numGlyphsInPage && !glyphFound; ++ii)
114 glyphFound = (aGlyphCode == page->GlyphCodeAt(ii));
120 Returns the number of glyphs associated to the given font in the atlas.
122 TInt CGlyphAtlasTestWrapper::GlyphCountByFont(const CBitmapFont* aFont)
125 TDblQueIter<CGlyphAtlasPage> iter(iAtlas->iLruPageList);
126 CGlyphAtlasPage* page;
127 while((page=iter++) != NULL)
129 if (&page->FontEntry().Font() == aFont)
131 glyphCount += page->GlyphCount();
138 Returns the number of glyphs in the atlas.
140 TInt CGlyphAtlasTestWrapper::GlyphCount()
143 TDblQueIter<CGlyphAtlasPage> iter(iAtlas->iLruPageList);
144 CGlyphAtlasPage* page;
145 while((page=iter++) != NULL)
147 glyphCount += page->GlyphCount();
153 Returns the number of fonts in the atlas.
155 TInt CGlyphAtlasTestWrapper::FontCount() const
157 return iAtlas->iFontEntryArray.Count();
161 Glyph Atlas test wrapper destructor.
163 CGlyphAtlasTestWrapper::~CGlyphAtlasTestWrapper()