diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-04-04 19:27:12 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-04-08 19:10:11 +0900 |
commit | 40e9ed91bd8bbfecfc3832d73a81741d0aa97d3a (patch) | |
tree | f1405816290ab26dd928b1fa1a699c76ec977ce0 /vcl/opengl/FixedTextureAtlas.cxx | |
parent | 96a098c0e8a009b77a26061dac3318da71d34ee4 (diff) |
opengl: texture atlas impl. to efficiently packs textures
Change-Id: I66b3eddadb172da26aa1a62f2a795895769db93b
Diffstat (limited to 'vcl/opengl/FixedTextureAtlas.cxx')
-rw-r--r-- | vcl/opengl/FixedTextureAtlas.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx index 80c1cfe496c7..1ed83111d293 100644 --- a/vcl/opengl/FixedTextureAtlas.cxx +++ b/vcl/opengl/FixedTextureAtlas.cxx @@ -42,7 +42,7 @@ void FixedTextureAtlasManager::CreateNewTexture() mpTextures.back()->InitializeSlots(mWidthFactor * mHeightFactor); } -OpenGLTexture FixedTextureAtlasManager::InsertBuffer(int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData) +OpenGLTexture FixedTextureAtlasManager::Reserve(int nWidth, int nHeight) { ImplOpenGLTexture* pTexture = nullptr; @@ -71,14 +71,18 @@ OpenGLTexture FixedTextureAtlasManager::InsertBuffer(int nWidth, int nHeight, in Rectangle aRectangle(Point(nX, nY), Size(nWidth, nHeight)); - // If available, copy the image data to the texture - if (pData) - { - if (!pTexture->InsertBuffer(nX, nY, nWidth, nHeight, nFormat, nType, pData)) - return OpenGLTexture(); - } - return OpenGLTexture(pTexture, aRectangle, nSlot); } +OpenGLTexture FixedTextureAtlasManager::InsertBuffer(int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData) +{ + OpenGLTexture aTexture = Reserve(nWidth, nHeight); + if (pData == nullptr) + return aTexture; + + aTexture.CopyData(nWidth, nHeight, nFormat, nType, pData); + + return aTexture; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |