62 void Setup(HMODULE pDll, ID3D11Device* pD11Device);
103 ID3D11ShaderResourceView* Texture;
105 Icon(UINT pWidth, UINT pHeight, ID3D11ShaderResourceView* pTexture) : Width(pWidth), Height(pHeight), Texture(pTexture) {}
116 QueueIcon(
IconLoaderKeyType pName,
IconLoader& pIconLoader, LoadWay pWay,
const auto& pResource) : mIconLoader(pIconLoader), mName(pName), mWay(pWay), mResource(pResource) {}
121 std::variant<std::filesystem::path, std::string, UINT> mResource;
125 std::vector<uint8_t> mPixelBuffer;
126 DXGI_FORMAT mDxgiFormat = DXGI_FORMAT_UNKNOWN;
131 void LoadFile(
const std::filesystem::path& pFilepath);
132#if ARCDPS_EXTENSION_CURL
133 void LoadUrl(
const std::string& pUrl);
134 void LoadGw2Dat(
const std::string& pId);
136 void LoadResource(UINT pId);
137 void LoadFrame(
const CComPtr<IWICBitmapFrameDecode>& pIDecodeFrame,
const CComPtr<IWICImagingFactory>& pIWICFactory);
139 static DXGI_FORMAT GetFormatDx11(WICPixelFormatGUID pPixelFormat);
145 ID3D11Device* mD11Device;
147 std::unordered_map<IconLoaderKeyType, Icon> mIcons;
148 std::unordered_map<IconLoaderKeyType, QueueIcon> mLoadQueue;
149 std::mutex mLoadQueueMutex;
150 std::queue<QueueIcon> mThreadQueue;
152 std::jthread mThread;
153 std::mutex mThreadMutex;
154 std::condition_variable_any mThreadVariable;
156 void runner(std::stop_token pToken);
157 void queueLoad(
const QueueIcon& pIcon);
158 void loadDone(
const IconLoader::QueueIcon& pIcon, ID3D11ShaderResourceView* pTexture);
196 if (
const auto& icon = mIcons.find(name); icon != mIcons.end()) {
197 return icon->second.Texture;
199 if (
const auto& icon = mLoadQueue.find(name); icon != mLoadQueue.end()) {
200 std::unique_lock lock(mLoadQueueMutex);
201 auto element = mLoadQueue.extract(name);
204 element.mapped().DeviceLoad();