mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-18 11:42:36 +00:00
HiresTextures: Make Load return a unique_ptr
This commit is contained in:
parent
6a9e4511b5
commit
1d01fbd217
@ -167,11 +167,11 @@ void HiresTexture::Prefetch()
|
|||||||
// But bad luck, SOIL isn't, so TODO: remove SOIL usage here and use libpng directly
|
// But bad luck, SOIL isn't, so TODO: remove SOIL usage here and use libpng directly
|
||||||
// Also TODO: remove s_textureCacheAquireMutex afterwards. It won't be needed as the main mutex will be locked rarely
|
// Also TODO: remove s_textureCacheAquireMutex afterwards. It won't be needed as the main mutex will be locked rarely
|
||||||
//lk.unlock();
|
//lk.unlock();
|
||||||
HiresTexture* t = Load(base_filename, 0, 0);
|
std::unique_ptr<HiresTexture> texture = Load(base_filename, 0, 0);
|
||||||
//lk.lock();
|
//lk.lock();
|
||||||
if (t)
|
if (texture)
|
||||||
{
|
{
|
||||||
std::shared_ptr<HiresTexture> ptr(t);
|
std::shared_ptr<HiresTexture> ptr(std::move(texture));
|
||||||
iter = s_textureCache.insert(iter, std::make_pair(base_filename, ptr));
|
iter = s_textureCache.insert(iter, std::make_pair(base_filename, ptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,9 +366,9 @@ std::shared_ptr<HiresTexture> HiresTexture::Search(const u8* texture, size_t tex
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HiresTexture* HiresTexture::Load(const std::string& base_filename, u32 width, u32 height)
|
std::unique_ptr<HiresTexture> HiresTexture::Load(const std::string& base_filename, u32 width, u32 height)
|
||||||
{
|
{
|
||||||
HiresTexture* ret = nullptr;
|
std::unique_ptr<HiresTexture> ret;
|
||||||
for (int level = 0;; level++)
|
for (int level = 0;; level++)
|
||||||
{
|
{
|
||||||
std::string filename = base_filename;
|
std::string filename = base_filename;
|
||||||
@ -420,7 +420,7 @@ HiresTexture* HiresTexture::Load(const std::string& base_filename, u32 width, u3
|
|||||||
height >>= 1;
|
height >>= 1;
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = new HiresTexture();
|
ret = std::unique_ptr<HiresTexture>(new HiresTexture);
|
||||||
ret->m_levels.push_back(l);
|
ret->m_levels.push_back(l);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
std::vector<Level> m_levels;
|
std::vector<Level> m_levels;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HiresTexture* Load(const std::string& base_filename, u32 width, u32 height);
|
static std::unique_ptr<HiresTexture> Load(const std::string& base_filename, u32 width, u32 height);
|
||||||
static void Prefetch();
|
static void Prefetch();
|
||||||
|
|
||||||
HiresTexture() {}
|
HiresTexture() {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user