summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-09-11 12:27:45 +0200
committerAndras Timar <andras.timar@collabora.com>2015-09-19 21:32:20 +0200
commit400344b5c5030fac0c1cd9ce128d5b710436a1e0 (patch)
tree9532b5d4e6601f147b4f38b564a8dfe5df5b219a
parente440a97672d1d4f768fda9bbdbcf15ae4ad11660 (diff)
opengl: optimize search for a free slot in texture atlas
Change-Id: Ic853457871b914f9c1beb2f648bf7d9d18dce957 (cherry picked from commit 4823b6d4e989943c31e20027564ab4eca43f6f8d) Reviewed-on: https://gerrit.libreoffice.org/18624 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/opengl/FixedTextureAtlas.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx
index c8ca50846b9d..7a9b54e072e0 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();