mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 13:22:23 +08:00

Window mode now has extra settings for setting the position and size Fixed audio not muting when --silent was used Signed-off-by: Alexis Maiquez <almamu@almamu.com>
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#include "CTextureCache.h"
|
|
|
|
#include "WallpaperEngine/Assets/CAssetLoadException.h"
|
|
|
|
using namespace WallpaperEngine::Render;
|
|
using namespace WallpaperEngine::Assets;
|
|
|
|
CTextureCache::CTextureCache (CRenderContext& context) :
|
|
m_context (context)
|
|
{
|
|
}
|
|
|
|
CTextureCache::~CTextureCache ()
|
|
= default;
|
|
|
|
const ITexture* CTextureCache::resolve (const std::string& filename)
|
|
{
|
|
auto found = this->m_textureCache.find (filename);
|
|
|
|
if (found != this->m_textureCache.end ())
|
|
return (*found).second;
|
|
|
|
// search for the texture in all the different containers just in case
|
|
for (auto it : this->m_context.getApp ().getProjects ())
|
|
{
|
|
const ITexture* texture = it.second->getContainer ()->readTexture (filename);
|
|
|
|
this->store (filename, texture);
|
|
|
|
return texture;
|
|
}
|
|
|
|
if (this->m_context.getApp ().getDefaultProject () != nullptr)
|
|
{
|
|
const ITexture* texture = this->m_context.getApp ().getDefaultProject ()->getContainer ()->readTexture (filename);
|
|
|
|
this->store (filename, texture);
|
|
|
|
return texture;
|
|
}
|
|
|
|
throw CAssetLoadException (filename, "Cannot find file");
|
|
}
|
|
|
|
void CTextureCache::store (std::string name, const ITexture* texture)
|
|
{
|
|
this->m_textureCache.insert_or_assign (name, texture);
|
|
} |