From cd089979607566bc26259ff9edb079842aabdd4e Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Fri, 8 Apr 2016 17:08:04 +0900 Subject: 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 --- vcl/inc/opengl/FixedTextureAtlas.hxx | 3 ++- vcl/inc/opengl/texture.hxx | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'vcl/inc/opengl') 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 mpTextures; + std::vector> 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> mpSlotReferences; - int mnFreeSlots; + std::function 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 aCallback) + { + mFunctSlotDeallocateCallback = aCallback; + } + GLuint AddStencil(); }; -- cgit