[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - vcl/opengl

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Sep 16 06:03:52 PDT 2015


 vcl/opengl/FixedTextureAtlas.cxx |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 50902f4d3bca92aefe0a3b663c3d175b60ecb25f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Sep 11 12:27:45 2015 +0200

    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 at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx
index c8ca508..7a9b54e 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();


More information about the Libreoffice-commits mailing list