xref: /haiku/src/servers/app/font/FontCache.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2  * Copyright 2007, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 
9 #ifndef FONT_CACHE_H
10 #define FONT_CACHE_H
11 
12 #include "FontCacheEntry.h"
13 #include "HashMap.h"
14 #include "HashString.h"
15 #include "MultiLocker.h"
16 #include "ServerFont.h"
17 
18 
19 class FontCache : public MultiLocker {
20  public:
21 								FontCache();
22 	virtual						~FontCache();
23 
24 	// global instance
25 	static	FontCache*			Default();
26 
27 			FontCacheEntry*		FontCacheEntryFor(const ServerFont& font);
28 			void				Recycle(FontCacheEntry* entry);
29 
30  private:
31 			void				_ConstrainEntryCount();
32 
33 	static	FontCache			sDefaultInstance;
34 
35 	typedef HashMap<HashString, FontCacheEntry*> FontMap;
36 
37 			FontMap				fFontCacheEntries;
38 };
39 
40 #endif // FONT_CACHE_H
41