[Libreoffice-commits] core.git: vcl/opengl

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Aug 26 02:37:15 PDT 2015


 vcl/opengl/salbmp.cxx |   37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

New commits:
commit e3771338eee211dbac7cad961a4a81342f2a56c9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Aug 19 12:31:25 2015 +0900

    tdf#92019 Use texture atlas for 16, 24, 32, 48, 64 px width images
    
    Change-Id: Ie95c36fe3705e2645a59cac117d99d7b85388ce1

diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index b5e5154..2e45d73 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -31,11 +31,20 @@
 #include "opengl/program.hxx"
 #include "opengl/salbmp.hxx"
 
+#include "opengl/FixedTextureAtlas.hxx"
+
+namespace
+{
+
 static bool isValidBitCount( sal_uInt16 nBitCount )
 {
     return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || (nBitCount == 16) || (nBitCount == 24) || (nBitCount == 32);
 }
 
+static std::vector<std::unique_ptr<FixedTextureAtlasManager>> sTextureAtlases;
+
+}
+
 OpenGLSalBitmap::OpenGLSalBitmap()
 : mpContext(NULL)
 , mbDirtyTexture(true)
@@ -314,6 +323,31 @@ ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalet
     return 0;
 }
 
+void lclInstantiateTexture(OpenGLTexture& rTexture, const int nWidth, const int nHeight,
+                           const GLenum nFormat, const GLenum nType, sal_uInt8* pData)
+{
+    if (nWidth == nHeight)
+    {
+        if (sTextureAtlases.empty())
+        {
+            sTextureAtlases.push_back(std::move(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 16))));
+            sTextureAtlases.push_back(std::move(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 24))));
+            sTextureAtlases.push_back(std::move(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 32))));
+            sTextureAtlases.push_back(std::move(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 48))));
+            sTextureAtlases.push_back(std::move(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 64))));
+        }
+        for (size_t i = 0; i < sTextureAtlases.size(); i++)
+        {
+            if (nWidth == sTextureAtlases[i]->GetSubtextureSize())
+            {
+                rTexture = sTextureAtlases[i]->InsertBuffer(nWidth, nHeight, nFormat, nType, pData);
+                return;
+            }
+        }
+    }
+    rTexture = OpenGLTexture (nWidth, nHeight, nFormat, nType, pData);
+}
+
 }
 
 Size OpenGLSalBitmap::GetSize() const
@@ -410,7 +444,8 @@ GLuint OpenGLSalBitmap::CreateTexture()
 
     makeCurrent();
 
-    maTexture = OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData );
+    lclInstantiateTexture(maTexture, mnBufWidth, mnBufHeight, nFormat, nType, pData);
+
     SAL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
 
     if( bAllocated )


More information about the Libreoffice-commits mailing list