diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-11 12:27:45 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-16 14:16:36 +0200 |
commit | 4823b6d4e989943c31e20027564ab4eca43f6f8d (patch) | |
tree | ca6e875555eb977fdb57c5461524d9476dcdfea4 /vcl/opengl | |
parent | 0eb9f13d401eb473338c7da2e4cfd0e366996aee (diff) |
opengl: optimize search for a free slot in texture atlas
Change-Id: Ic853457871b914f9c1beb2f648bf7d9d18dce957
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/FixedTextureAtlas.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx index f6e400597342..8a3e927b4698 100644 --- a/vcl/opengl/FixedTextureAtlas.cxx +++ b/vcl/opengl/FixedTextureAtlas.cxx @@ -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(); |