Kaydet (Commit) 4823b6d4 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

opengl: optimize search for a free slot in texture atlas

Change-Id: Ic853457871b914f9c1beb2f648bf7d9d18dce957
üst 0eb9f13d
......@@ -36,15 +36,18 @@ OpenGLTexture FixedTextureAtlasManager::InsertBuffer(int nWidth, int nHeight, in
{
ImplOpenGLTexture* pTexture = nullptr;
for (size_t i = 0; i < mpTextures.size(); i++)
auto funFreeSlot = [] (std::unique_ptr<ImplOpenGLTexture>& mpTexture)
{
if (mpTextures[i]->mnFreeSlots > 0)
{
pTexture = mpTextures[i].get();
}
}
return mpTexture->mnFreeSlots > 0;
};
auto aIterator = std::find_if(mpTextures.begin(), mpTextures.end(), funFreeSlot);
if (!pTexture)
if (aIterator != mpTextures.end())
{
pTexture = (*aIterator).get();
}
else
{
CreateNewTexture();
pTexture = mpTextures.back().get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment