summaryrefslogtreecommitdiff
path: root/vcl/inc/opengl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-08 17:08:04 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-08 19:10:14 +0900
commitcd089979607566bc26259ff9edb079842aabdd4e (patch)
treebe8955067072c88769b865cc1b4441e81aee4c03 /vcl/inc/opengl
parentf65e77c965bb47d53c994d90b7fd0bf5009b343b (diff)
opengl: refactor GL texture slot mechanism to be more general
Slot mechanism in ImplOpenGLTexture was written to support needs for FixedTextureAtlas. This commit makes the slot mechanism more general so it can be used in other kinds of texture atlases like PackedTextureAtlas. The ImplOpenGLTexture still tracks slots, but it is not needed to define beforehand how many slots there are. The deallocation has been factored out, ImplOpenGLTexture instead calls a callback function that a slot with a specific "slot id" has been deallocated. Change-Id: I23950d325b803969f958d03ebf34805687c4e620
Diffstat (limited to 'vcl/inc/opengl')
-rw-r--r--vcl/inc/opengl/FixedTextureAtlas.hxx3
-rw-r--r--vcl/inc/opengl/texture.hxx11
2 files changed, 10 insertions, 4 deletions
diff --git a/vcl/inc/opengl/FixedTextureAtlas.hxx b/vcl/inc/opengl/FixedTextureAtlas.hxx
index 8d104a788c83..bf9ee043fed0 100644
--- a/vcl/inc/opengl/FixedTextureAtlas.hxx
+++ b/vcl/inc/opengl/FixedTextureAtlas.hxx
@@ -13,10 +13,11 @@
#include "opengl/texture.hxx"
+struct FixedTexture;
class VCL_PLUGIN_PUBLIC FixedTextureAtlasManager
{
- std::vector<ImplOpenGLTexture *> mpTextures;
+ std::vector<std::unique_ptr<FixedTexture>> maFixedTextures;
int mWidthFactor;
int mHeightFactor;
diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx
index f54604a88340..5bbf26c63a75 100644
--- a/vcl/inc/opengl/texture.hxx
+++ b/vcl/inc/opengl/texture.hxx
@@ -40,7 +40,7 @@ public:
GLuint mnOptStencil;
std::unique_ptr<std::vector<int>> mpSlotReferences;
- int mnFreeSlots;
+ std::function<void(int)> mFunctSlotDeallocateCallback;
ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate );
ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, void const * pData );
@@ -58,8 +58,13 @@ public:
return mnRefCount == 1;
}
- bool InitializeSlots(int nSlotSize);
- int FindFreeSlot();
+ bool InitializeSlotMechanism(int nInitialSlotSize = 0);
+
+ void SetSlotDeallocateCallback(std::function<void(int)> aCallback)
+ {
+ mFunctSlotDeallocateCallback = aCallback;
+ }
+
GLuint AddStencil();
};