1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef SCI_GRAPHICS_CACHE_H
24 #define SCI_GRAPHICS_CACHE_H
25 
26 #include "common/hashmap.h"
27 
28 namespace Sci {
29 
30 class GfxFont;
31 class GfxView;
32 
33 typedef Common::HashMap<int, GfxFont *> FontCache;
34 typedef Common::HashMap<int, GfxView *> ViewCache;
35 
36 /**
37  * Cache class, handles caching of views/fonts
38  */
39 class GfxCache {
40 public:
41 	GfxCache(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palette);
42 	~GfxCache();
43 
44 	GfxFont *getFont(GuiResourceId fontId);
45 	GfxView *getView(GuiResourceId viewId);
46 
47 	int16 kernelViewGetCelWidth(GuiResourceId viewId, int16 loopNo, int16 celNo);
48 	int16 kernelViewGetCelHeight(GuiResourceId viewId, int16 loopNo, int16 celNo);
49 	int16 kernelViewGetLoopCount(GuiResourceId viewId);
50 	int16 kernelViewGetCelCount(GuiResourceId viewId, int16 loopNo);
51 
52 private:
53 	void purgeFontCache();
54 	void purgeViewCache();
55 
56 	ResourceManager *_resMan;
57 	GfxScreen *_screen;
58 	GfxPalette *_palette;
59 
60 	FontCache _cachedFonts;
61 	ViewCache _cachedViews;
62 };
63 
64 } // End of namespace Sci
65 
66 #endif
67