vcl/opengl/salbmp.cxx | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
New commits: commit e98939c292297dd4569d8ebad0a8245d7e6f4bb6 Author: Tomaž Vajngerl <tomaz.vajng...@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 (cherry picked from commit e3771338eee211dbac7cad961a4a81342f2a56c9) -Werror,-Wpessimizing-move (cherry picked from commit 975a2bccd9ba4d651dfe76e58b8a23fb10775c04) Change-Id: Ie95c36fe3705e2645a59cac117d99d7b85388ce1 Reviewed-on: https://gerrit.libreoffice.org/18013 Reviewed-by: Tor Lillqvist <t...@collabora.com> Tested-by: Tor Lillqvist <t...@collabora.com> diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 30bbdb2..527a198 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::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 16))); + sTextureAtlases.push_back(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 24))); + sTextureAtlases.push_back(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 32))); + sTextureAtlases.push_back(std::unique_ptr<FixedTextureAtlasManager>(new FixedTextureAtlasManager(8, 8, 48))); + sTextureAtlases.push_back(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 )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits