summaryrefslogtreecommitdiff
path: root/vcl/opengl/FixedTextureAtlas.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/opengl/FixedTextureAtlas.cxx')
-rw-r--r--vcl/opengl/FixedTextureAtlas.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx
index 420121d91475..7a980c9251e4 100644
--- a/vcl/opengl/FixedTextureAtlas.cxx
+++ b/vcl/opengl/FixedTextureAtlas.cxx
@@ -25,8 +25,8 @@ struct FixedTexture
int mnFreeSlots;
std::vector<bool> maAllocatedSlots;
- FixedTexture(ImplOpenGLTexture* pTexture, int nNumberOfSlots)
- : mpTexture(pTexture)
+ FixedTexture(int nTextureWidth, int nTextureHeight, int nNumberOfSlots)
+ : mpTexture(new ImplOpenGLTexture(nTextureWidth, nTextureHeight, true))
, mnFreeSlots(nNumberOfSlots)
, maAllocatedSlots(nNumberOfSlots, false)
{
@@ -39,6 +39,12 @@ struct FixedTexture
mpTexture->InitializeSlotMechanism(nNumberOfSlots);
}
+ ~FixedTexture()
+ {
+ mpTexture->ResetSlotDeallocateCallback();
+ mpTexture->DecreaseRefCount(-1);
+ }
+
void allocateSlot(int nSlot)
{
maAllocatedSlots[nSlot] = true;
@@ -74,20 +80,13 @@ FixedTextureAtlasManager::FixedTextureAtlasManager(int nWidthFactor, int nHeight
FixedTextureAtlasManager::~FixedTextureAtlasManager()
{
- for (std::unique_ptr<FixedTexture>& pFixedTexture : maFixedTextures)
- {
- // Free texture early in VCL shutdown while we have a context.
- delete pFixedTexture->mpTexture;
- }
}
void FixedTextureAtlasManager::CreateNewTexture()
{
int nTextureWidth = mWidthFactor * mSubTextureSize;
int nTextureHeight = mHeightFactor * mSubTextureSize;
- maFixedTextures.push_back(o3tl::make_unique<FixedTexture>(new ImplOpenGLTexture(nTextureWidth, nTextureHeight, true),
- mWidthFactor * mHeightFactor));
-
+ maFixedTextures.push_back(o3tl::make_unique<FixedTexture>(nTextureWidth, nTextureHeight, mWidthFactor * mHeightFactor));
}
OpenGLTexture FixedTextureAtlasManager::Reserve(int nWidth, int nHeight)