Debian Codegraph @

Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h

raw symbols SCIP
1 // Copyright 2023 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5 #include <chrono>
6 #include <filesystem>
7 #include <map>
8 #include <mutex>
9 #include <string>
10
11 #include "VideoCommon/Assets/CustomTextureData.h"
12 #include "VideoCommon/Assets/TextureAsset.h"
13 #include "VideoCommon/Assets/Types.h"
14 #include "VideoCommon/Assets/WatchableFilesystemAssetLibrary.h"
15
16 namespace VideoCommon
17 {
18 // This class implements 'CustomAssetLibrary' and loads any assets
19 // directly from the filesystem
20 class DirectFilesystemAssetLibrary final : public WatchableFilesystemAssetLibrary
21 {
22 public:
23 LoadInfo LoadTexture(const AssetID& asset_id, TextureAndSamplerData* data) override;
24 LoadInfo LoadTexture(const AssetID& asset_id, CustomTextureData* data) override;
25 LoadInfo LoadRasterSurfaceShader(const AssetID& asset_id, RasterSurfaceShaderData* data) override;
26 LoadInfo LoadMaterial(const AssetID& asset_id, MaterialData* data) override;
27 LoadInfo LoadMesh(const AssetID& asset_id, MeshData* data) override;
28
29 // Assigns the asset id to a map of files, how this map is read is dependent on the data
30 // For instance, a raw texture would expect the map to have a single entry and load that
31 // file as the asset. But a model file data might have its data spread across multiple files
32 void SetAssetIDMapData(const AssetID& asset_id, Assets::AssetMap asset_path_map);
33
34 private:
35 void PathModified(std::string_view path) override;
36
37 // Gets the asset map given an asset id
38 Assets::AssetMap GetAssetMapForID(const AssetID& asset_id) const;
39
40 mutable std::mutex m_asset_map_lock;
41 std::map<AssetID, Assets::AssetMap> m_asset_id_to_asset_map_path;
42
43 mutable std::mutex m_path_map_lock;
44 std::map<std::string, AssetID, std::less<>> m_path_to_asset_id;
45 };
46 } // namespace VideoCommon