| 514 | } |
| 515 | |
| 516 | std::shared_ptr<LoadedTexture> TextureCache::LoadTextureFromFileDeferred( |
| 517 | const std::filesystem::path& path, |
| 518 | bool sRGB) |
| 519 | { |
| 520 | std::shared_ptr<TextureData> texture; |
| 521 | |
| 522 | if (FindTextureInCache(path, texture)) |
| 523 | return texture; |
| 524 | |
| 525 | texture->forceSRGB = sRGB; |
| 526 | texture->path = path.generic_string(); |
| 527 | |
| 528 | auto fileData = ReadTextureFile(path); |
| 529 | if (fileData) |
| 530 | { |
| 531 | if (FillTextureData(fileData, texture, path.extension().generic_string(), "")) |
| 532 | { |
| 533 | TextureLoaded(texture); |
| 534 | |
| 535 | std::lock_guard<std::mutex> guard(m_TexturesToFinalizeMutex); |
| 536 | |
| 537 | m_TexturesToFinalize.push(texture); |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | ++m_TexturesLoaded; |
| 542 | |
| 543 | return texture; |
| 544 | } |
| 545 | |
| 546 | std::shared_ptr<LoadedTexture> TextureCache::LoadTextureFromFileAsync( |
| 547 | const std::filesystem::path& path, |