[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/opengl

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Jun 9 08:23:17 UTC 2016


 vcl/opengl/FixedTextureAtlas.cxx |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 3217029eaf355ee059dc4d371cf1e65c346405dd
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jun 9 10:18:31 2016 +0900

    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 at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/vcl/opengl/FixedTextureAtlas.cxx b/vcl/opengl/FixedTextureAtlas.cxx
index 87c5bb1..7a980c9 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)


More information about the Libreoffice-commits mailing list