2019-08-06 21:54:07 +05:30
|
|
|
// Copyright 2019 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-08-06 18:13:24 +05:30
|
|
|
#pragma once
|
|
|
|
|
2019-08-17 08:04:22 +05:30
|
|
|
#include <string>
|
2019-08-06 18:13:24 +05:30
|
|
|
#include <unordered_map>
|
2019-08-14 10:34:50 +05:30
|
|
|
#include <unordered_set>
|
2019-08-06 18:13:24 +05:30
|
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2020-04-21 08:20:16 +05:30
|
|
|
namespace Frontend {
|
|
|
|
class ImageInterface;
|
|
|
|
} // namespace Frontend
|
|
|
|
|
2019-08-06 18:13:24 +05:30
|
|
|
namespace Core {
|
|
|
|
struct CustomTexInfo {
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
std::vector<u8> tex;
|
|
|
|
};
|
|
|
|
|
2019-08-17 08:04:22 +05:30
|
|
|
// This is to avoid parsing the filename multiple times
|
|
|
|
struct CustomTexPathInfo {
|
|
|
|
std::string path;
|
|
|
|
u64 hash;
|
|
|
|
};
|
|
|
|
|
2019-08-06 18:13:24 +05:30
|
|
|
// TODO: think of a better name for this class...
|
|
|
|
class CustomTexCache {
|
|
|
|
public:
|
2019-08-14 20:13:24 +05:30
|
|
|
explicit CustomTexCache();
|
2019-08-06 21:54:07 +05:30
|
|
|
~CustomTexCache();
|
|
|
|
|
|
|
|
bool IsTextureDumped(u64 hash) const;
|
|
|
|
void SetTextureDumped(u64 hash);
|
2019-08-06 18:13:24 +05:30
|
|
|
|
2019-08-06 21:54:07 +05:30
|
|
|
bool IsTextureCached(u64 hash) const;
|
2019-08-14 10:34:50 +05:30
|
|
|
const CustomTexInfo& LookupTexture(u64 hash) const;
|
2019-08-06 21:54:07 +05:30
|
|
|
void CacheTexture(u64 hash, const std::vector<u8>& tex, u32 width, u32 height);
|
2019-08-06 18:13:24 +05:30
|
|
|
|
2019-08-17 08:04:22 +05:30
|
|
|
void AddTexturePath(u64 hash, const std::string& path);
|
2020-04-21 08:20:16 +05:30
|
|
|
void FindCustomTextures(u64 program_id);
|
|
|
|
void PreloadTextures(Frontend::ImageInterface& image_interface);
|
2019-08-17 08:04:22 +05:30
|
|
|
bool CustomTextureExists(u64 hash) const;
|
|
|
|
const CustomTexPathInfo& LookupTexturePathInfo(u64 hash) const;
|
|
|
|
bool IsTexturePathMapEmpty() const;
|
|
|
|
|
2019-08-06 18:13:24 +05:30
|
|
|
private:
|
2019-08-14 10:34:50 +05:30
|
|
|
std::unordered_set<u64> dumped_textures;
|
2019-08-06 18:13:24 +05:30
|
|
|
std::unordered_map<u64, CustomTexInfo> custom_textures;
|
2019-08-17 08:04:22 +05:30
|
|
|
std::unordered_map<u64, CustomTexPathInfo> custom_texture_paths;
|
2019-08-06 18:13:24 +05:30
|
|
|
};
|
2019-10-12 20:55:27 +05:30
|
|
|
} // namespace Core
|