summaryrefslogtreecommitdiff
path: root/vcl/opengl/FixedTextureAtlas.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-04 19:27:12 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-08 19:10:11 +0900
commit40e9ed91bd8bbfecfc3832d73a81741d0aa97d3a (patch)
treef1405816290ab26dd928b1fa1a699c76ec977ce0 /vcl/opengl/FixedTextureAtlas.cxx
parent96a098c0e8a009b77a26061dac3318da71d34ee4 (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.cxx20
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: */