68 IconLoader(HMODULE pDll, ID3D11Device* pD11Device);
110 ID3D11ShaderResourceView* Texture;
112 Icon(UINT pWidth, UINT pHeight, ID3D11ShaderResourceView* pTexture) : Width(pWidth), Height(pHeight), Texture(pTexture) {}
123 QueueIcon(
IconLoaderKeyType pName,
IconLoader& pIconLoader, LoadWay pWay,
const auto& pResource) : mIconLoader(pIconLoader), mName(pName), mWay(pWay), mResource(pResource) {}
128 std::variant<std::filesystem::path, std::string, UINT> mResource;
132 std::vector<uint8_t> mPixelBuffer;
133 DXGI_FORMAT mDxgiFormat = DXGI_FORMAT_UNKNOWN;
138 void LoadFile(
const std::filesystem::path& pFilepath);
139#if ARCDPS_EXTENSION_CURL
140 void LoadUrl(
const std::string& pUrl);
141 void LoadGw2Dat(
const std::string& pId);
143 void LoadResource(UINT pId);
144 void LoadFrame(
const CComPtr<IWICBitmapFrameDecode>& pIDecodeFrame,
const CComPtr<IWICImagingFactory>& pIWICFactory);
146 static DXGI_FORMAT GetFormatDx11(WICPixelFormatGUID pPixelFormat);
152 ID3D11Device* mD11Device;
154 std::unordered_map<IconLoaderKeyType, Icon> mIcons;
155 std::unordered_map<IconLoaderKeyType, QueueIcon> mLoadQueue;
156 std::mutex mLoadQueueMutex;
157 std::queue<QueueIcon> mThreadQueue;
159 std::jthread mThread;
160 std::mutex mThreadMutex;
161 std::condition_variable_any mThreadVariable;
163 void runner(std::stop_token pToken);
164 void queueLoad(
const QueueIcon& pIcon);
165 void loadDone(
const IconLoader::QueueIcon& pIcon, ID3D11ShaderResourceView* pTexture);
203 if (
const auto& icon = mIcons.find(name); icon != mIcons.end()) {
204 return icon->second.Texture;
206 if (
const auto& icon = mLoadQueue.find(name); icon != mLoadQueue.end()) {
207 std::unique_lock lock(mLoadQueueMutex);
208 auto element = mLoadQueue.extract(name);
211 element.mapped().DeviceLoad();