From 3217029eaf355ee059dc4d371cf1e65c346405dd Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 9 Jun 2016 10:18:31 +0900 Subject: tdf#100184 add missing changes to FixedTextureAtlas In 6efb6fa31270adc84b5884cd4a84e1a3296d535d the changes to FixedTextureAtlas are missing (mistake at rebase) but are present in master. Change-Id: Ie38955b19ed9e8c4aea83cbf2d08531c0f25117a Reviewed-on: https://gerrit.libreoffice.org/26080 Tested-by: Jenkins Reviewed-by: Tor Lillqvist --- vcl/opengl/FixedTextureAtlas.cxx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx index 87c5bb1ff2ac..7a980c9251e4 100644 --- a/vcl/opengl/FixedTextureAtlas.cxx +++ b/vcl/opengl/FixedTextureAtlas.cxx @@ -17,14 +17,16 @@ #include "opengl/FixedTextureAtlas.hxx" +#include + struct FixedTexture { ImplOpenGLTexture* mpTexture; int mnFreeSlots; std::vector 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) { @@ -37,6 +39,12 @@ struct FixedTexture mpTexture->InitializeSlotMechanism(nNumberOfSlots); } + ~FixedTexture() + { + mpTexture->ResetSlotDeallocateCallback(); + mpTexture->DecreaseRefCount(-1); + } + void allocateSlot(int nSlot) { maAllocatedSlots[nSlot] = true; @@ -72,22 +80,13 @@ FixedTextureAtlasManager::FixedTextureAtlasManager(int nWidthFactor, int nHeight FixedTextureAtlasManager::~FixedTextureAtlasManager() { - for (std::unique_ptr& 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; - std::unique_ptr pFixedTexture( - new FixedTexture(new ImplOpenGLTexture(nTextureWidth, nTextureHeight, true), - mWidthFactor * mHeightFactor)); - - maFixedTextures.push_back(std::move(pFixedTexture)); + maFixedTextures.push_back(o3tl::make_unique(nTextureWidth, nTextureHeight, mWidthFactor * mHeightFactor)); } OpenGLTexture FixedTextureAtlasManager::Reserve(int nWidth, int nHeight) -- cgit v1.2.3