Glide Plugin GLES2 port from mupen64plus-ae, but with special FrameSkip code
[mupen64plus-pandora.git] / source / gles2glide64 / src / GlideHQ / TxTexCache.cpp
CommitLineData
98e75f2d 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#ifdef __MSC__
25#pragma warning(disable: 4786)
26#endif
27
28#include "TxTexCache.h"
29#include "TxDbg.h"
30#include <zlib.h>
31#include <string>
32#include <boost/filesystem.hpp>
33
34TxTexCache::~TxTexCache()
35{
36#ifdef DUMP_CACHE
37 if (_options & DUMP_TEXCACHE) {
38 /* dump cache to disk */
39 std::wstring filename = _ident + L"_MEMORYCACHE.dat";
40 boost::filesystem::wpath cachepath(_cachepath);
41 cachepath /= boost::filesystem::wpath(L"glidehq");
42 int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE);
43
44 TxCache::save(cachepath.wstring().c_str(), filename.c_str(), config);
45 }
46#endif
47}
48
49TxTexCache::TxTexCache(int options, int cachesize, const wchar_t *datapath, const wchar_t *cachepath,
50 const wchar_t *ident, dispInfoFuncExt callback
51 ) : TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, datapath, cachepath, ident, callback)
52{
53 /* assert local options */
54 if (_cachepath.empty() || _ident.empty() || !_cacheSize)
55 _options &= ~DUMP_TEXCACHE;
56
57#ifdef DUMP_CACHE
58 if (_options & DUMP_TEXCACHE) {
59 /* find it on disk */
60 std::wstring filename = _ident + L"_MEMORYCACHE.dat";
61 boost::filesystem::wpath cachepath(_cachepath);
62 cachepath /= boost::filesystem::wpath(L"glidehq");
63 int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE);
64
65 TxCache::load(cachepath.wstring().c_str(), filename.c_str(), config);
66 }
67#endif
68}
69
70boolean
71TxTexCache::add(uint64 checksum, GHQTexInfo *info)
72{
73 if (_cacheSize <= 0) return 0;
74
75 return TxCache::add(checksum, info);
76}