Glide Plugin GLES2 port from mupen64plus-ae, but with special FrameSkip code
[mupen64plus-pandora.git] / source / gles2glide64 / src / GlideHQ / TxCache.h
1 /*
2  * Texture Filtering
3  * Version:  1.0
4  *
5  * Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
6  * Email koolsmoky(at)users.sourceforge.net
7  * Web   http://www.3dfxzone.it/koolsmoky
8  *
9  * this is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * this is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with GNU Make; see the file COPYING.  If not, write to
21  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #ifndef __TXCACHE_H__
25 #define __TXCACHE_H__
26
27 #include "TxInternal.h"
28 #include "TxUtil.h"
29 #include <list>
30 #include <map>
31 #include <string>
32
33 class TxCache
34 {
35 private:
36   std::list<uint64> _cachelist;
37   uint8 *_gzdest0;
38   uint8 *_gzdest1;
39   uint32 _gzdestLen;
40 protected:
41   int _options;
42   std::wstring _ident;
43   std::wstring _datapath;
44   std::wstring _cachepath;
45   dispInfoFuncExt _callback;
46   TxUtil *_txUtil;
47   struct TXCACHE {
48     int size;
49     GHQTexInfo info;
50     std::list<uint64>::iterator it;
51   };
52   int _totalSize;
53   int _cacheSize;
54   std::map<uint64, TXCACHE*> _cache;
55   boolean save(const wchar_t *path, const wchar_t *filename, const int config);
56   boolean load(const wchar_t *path, const wchar_t *filename, const int config);
57   boolean del(uint64 checksum); /* checksum hi:palette low:texture */
58   boolean is_cached(uint64 checksum); /* checksum hi:palette low:texture */
59   void clear();
60 public:
61   ~TxCache();
62   TxCache(int options, int cachesize, const wchar_t *datapath,
63               const wchar_t *cachepath, const wchar_t *ident,
64               dispInfoFuncExt callback);
65   boolean add(uint64 checksum, /* checksum hi:palette low:texture */
66               GHQTexInfo *info, int dataSize = 0);
67   boolean get(uint64 checksum, /* checksum hi:palette low:texture */
68               GHQTexInfo *info);
69 };
70
71 #endif /* __TXCACHE_H__ */