summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-06-09 10:18:31 +0900
committerTor Lillqvist <tml@collabora.com>2016-06-09 08:22:55 +0000
commit3217029eaf355ee059dc4d371cf1e65c346405dd (patch)
tree5c5ef3890c1c3b3ec85ba4dd67536a8c96eff8d1
parent75e8a542f6515a364ea178fe26d6105a4e10cdcc (diff)
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 <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--vcl/opengl/FixedTextureAtlas.cxx23
1 files 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 <o3tl/make_unique.hxx>
+
struct FixedTexture
{
ImplOpenGLTexture* mpTexture;
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)
{
@@ -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<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;
- std::unique_ptr<FixedTexture> pFixedTexture(
- new FixedTexture(new ImplOpenGLTexture(nTextureWidth, nTextureHeight, true),
- mWidthFactor * mHeightFactor));
-
- maFixedTextures.push_back(std::move(pFixedTexture));
+ maFixedTextures.push_back(o3tl::make_unique<FixedTexture>(nTextureWidth, nTextureHeight, mWidthFactor * mHeightFactor));
}
OpenGLTexture FixedTextureAtlasManager::Reserve(int nWidth, int nHeight)