2018-12-30 17:42:55 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 flyinghead
|
|
|
|
|
|
|
|
This file is part of reicast.
|
|
|
|
|
|
|
|
reicast is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
reicast is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with reicast. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-10-04 10:22:18 +00:00
|
|
|
#pragma once
|
2018-12-30 17:42:55 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <set>
|
2019-10-04 10:22:18 +00:00
|
|
|
#include "TexCache.h"
|
2018-12-30 17:42:55 +00:00
|
|
|
|
|
|
|
class CustomTexture {
|
|
|
|
public:
|
2019-02-06 17:50:56 +00:00
|
|
|
CustomTexture()
|
|
|
|
:
|
|
|
|
#ifndef TARGET_NO_THREADS
|
2019-04-27 12:08:43 +00:00
|
|
|
loader_thread(loader_thread_func, this)
|
2019-02-06 17:50:56 +00:00
|
|
|
#endif
|
2019-04-27 12:08:43 +00:00
|
|
|
{}
|
2018-12-30 17:42:55 +00:00
|
|
|
~CustomTexture() { Terminate(); }
|
|
|
|
u8* LoadCustomTexture(u32 hash, int& width, int& height);
|
2019-10-04 10:22:18 +00:00
|
|
|
void LoadCustomTextureAsync(BaseTextureCacheData *texture_data);
|
|
|
|
void DumpTexture(u32 hash, int w, int h, TextureType textype, void *temp_tex_buffer);
|
2020-03-13 17:01:33 +00:00
|
|
|
void Terminate();
|
2018-12-30 17:42:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool Init();
|
|
|
|
void LoaderThread();
|
2019-01-02 08:33:19 +00:00
|
|
|
std::string GetGameId();
|
2018-12-30 17:42:55 +00:00
|
|
|
|
|
|
|
static void *loader_thread_func(void *param) { ((CustomTexture *)param)->LoaderThread(); return NULL; }
|
|
|
|
|
2020-03-13 17:01:33 +00:00
|
|
|
bool initialized = false;
|
|
|
|
bool custom_textures_available = false;
|
2018-12-30 17:42:55 +00:00
|
|
|
std::string textures_path;
|
|
|
|
std::set<u32> unknown_hashes;
|
2019-02-06 17:50:56 +00:00
|
|
|
#ifndef TARGET_NO_THREADS
|
2018-12-30 17:42:55 +00:00
|
|
|
cThread loader_thread;
|
2019-02-06 17:50:56 +00:00
|
|
|
#endif
|
2018-12-30 17:42:55 +00:00
|
|
|
cResetEvent wakeup_thread;
|
2019-10-04 10:22:18 +00:00
|
|
|
std::vector<BaseTextureCacheData *> work_queue;
|
2018-12-30 17:42:55 +00:00
|
|
|
cMutex work_queue_mutex;
|
|
|
|
};
|
2020-03-13 17:01:33 +00:00
|
|
|
|
|
|
|
extern CustomTexture custom_texture;
|