diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-08-19 12:31:25 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-08-26 18:35:29 +0900 |
commit | e3771338eee211dbac7cad961a4a81342f2a56c9 (patch) | |
tree | 406aa7ed7550c754407e1ee44c0df8c025d910a9 | |
parent | 167bc621ef825ed5b961502fe9324a675ee34e42 (diff) |
tdf#92019 Use texture atlas for 16, 24, 32, 48, 64 px width images
Change-Id: Ie95c36fe3705e2645a59cac117d99d7b85388ce1
-rw-r--r-- | vcl/opengl/salbmp.cxx | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index b5e515418ac8..2e45d73ae96b 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 ) |