[Libreoffice-commits] core.git: solenv/clang-format vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/qt5 vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 6 10:06:55 UTC 2018


 solenv/clang-format/blacklist               |    3 
 vcl/Library_vcl.mk                          |    2 
 vcl/Library_vclplug_gen.mk                  |    1 
 vcl/headless/svpgdi.cxx                     |    8 ++
 vcl/headless/svpglyphcache.cxx              |   62 ----------------
 vcl/inc/qt5/Qt5Data.hxx                     |    1 
 vcl/inc/unx/gendata.hxx                     |   73 +++++++++++++------
 vcl/inc/unx/glyphcache.hxx                  |    2 
 vcl/inc/unx/x11/xrender_peer.hxx            |    6 -
 vcl/qt5/Qt5Data.cxx                         |    1 
 vcl/unx/generic/app/gendata.cxx             |   29 +++++--
 vcl/unx/generic/app/saldisp.cxx             |   25 ++++++
 vcl/unx/generic/fontmanager/fontmanager.cxx |   20 -----
 vcl/unx/generic/gdi/gcach_xpeer.cxx         |  104 ----------------------------
 vcl/unx/generic/gdi/gdiimpl.cxx             |    2 
 vcl/unx/generic/gdi/salgdi.cxx              |    2 
 vcl/unx/generic/gdi/salgdi2.cxx             |    2 
 vcl/unx/generic/gdi/x11cairotextrender.cxx  |    4 -
 vcl/unx/generic/gdi/xrender_peer.cxx        |    2 
 vcl/unx/generic/glyphs/glyphcache.cxx       |    9 +-
 20 files changed, 119 insertions(+), 239 deletions(-)

New commits:
commit 8fdb37119f6db7f7fa5af1644e15347f17e5968e
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Oct 5 10:25:43 2018 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat Oct 6 12:06:30 2018 +0200

    Add GlyphCache instance to GenericUnixSalData
    
    This gets rid of some statics and drops some duplicate code:
    - the X11 based GlyphCache => gone
    - the svp version of the GlyphCache => gone
    - the "normal" GlyphCache
    - the PrintFontManager
    
    And while at it move the implementation into its own file
    gendata.cxx.
    
    Change-Id: I9063139c9482f5f37285505f389cf5f32c02426b
    Reviewed-on: https://gerrit.libreoffice.org/61454
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 30f9befd1586..22ca1d639ca1 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17641,7 +17641,6 @@ vcl/inc/unx/desktops.hxx
 vcl/inc/unx/fc_fontoptions.hxx
 vcl/inc/unx/fontmanager.hxx
 vcl/inc/unx/freetype_glyphcache.hxx
-vcl/inc/unx/gendata.hxx
 vcl/inc/unx/gendisp.hxx
 vcl/inc/unx/geninst.h
 vcl/inc/unx/genprn.h
@@ -17691,6 +17690,7 @@ vcl/inc/unx/wmadaptor.hxx
 vcl/inc/unx/x11/x11gdiimpl.h
 vcl/inc/unx/x11/x11sys.hxx
 vcl/inc/unx/x11/xlimits.hxx
+vcl/inc/unx/x11/xrender_peer.hxx
 vcl/inc/unx/x11_cursors/ase_curs.h
 vcl/inc/unx/x11_cursors/ase_mask.h
 vcl/inc/unx/x11_cursors/asn_curs.h
@@ -18319,7 +18319,6 @@ vcl/unx/generic/gdi/salvd.cxx
 vcl/unx/generic/gdi/x11cairotextrender.cxx
 vcl/unx/generic/gdi/x11cairotextrender.hxx
 vcl/unx/generic/gdi/xrender_peer.cxx
-vcl/unx/generic/gdi/xrender_peer.hxx
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx
 vcl/unx/generic/glyphs/glyphcache.cxx
 vcl/unx/generic/print/bitmap_gfx.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index e75ff64b2b34..ca04103ac8cc 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -454,7 +454,7 @@ vcl_headless_code= \
 vcl_headless_freetype_code=\
     vcl/headless/svpprn \
     vcl/headless/svptext \
-    vcl/headless/svpglyphcache \
+    vcl/unx/generic/app/gendata \
     vcl/unx/generic/gdi/cairotextrender \
     vcl/unx/generic/glyphs/freetype_glyphcache \
     vcl/unx/generic/glyphs/glyphcache \
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 0e1c39c15766..328b259bf05a 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -92,7 +92,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/dtrans/X11_transferable \
     vcl/unx/generic/gdi/cairo_xlib_cairo \
     vcl/unx/generic/gdi/x11cairotextrender \
-    vcl/unx/generic/gdi/gcach_xpeer \
 	vcl/unx/generic/gdi/gdiimpl \
 	vcl/unx/generic/gdi/openglx11cairotextrender \
     vcl/unx/generic/gdi/salbmp \
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index e12c7a32c8bd..b1f622904b5f 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -38,6 +38,7 @@
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <basegfx/utils/systemdependentdata.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <unx/gendata.hxx>
 
 #if ENABLE_CAIRO_CANVAS
 #   if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0)
@@ -2109,4 +2110,11 @@ bool SvpSalGraphics::supportsOperation(OutDevSupportType eType) const
     return false;
 }
 
+GlyphCache& SvpSalGraphics::getPlatformGlyphCache()
+{
+    GenericUnixSalData* const pSalData(GetGenericUnixSalData());
+    assert(pSalData);
+    return *pSalData->GetGlyphCache();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpglyphcache.cxx b/vcl/headless/svpglyphcache.cxx
deleted file mode 100644
index c303cb86b164..000000000000
--- a/vcl/headless/svpglyphcache.cxx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <memory>
-#include <sal/types.h>
-
-#include <cassert>
-
-#include <rtl/instance.hxx>
-
-#include <unx/geninst.h>
-#include <unx/glyphcache.hxx>
-#include <headless/svpgdi.hxx>
-
-namespace
-{
-    struct GlyphCacheHolder
-    {
-    private:
-        std::unique_ptr<GlyphCache> m_pSvpGlyphCache;
-
-        GlyphCacheHolder(const GlyphCacheHolder&) = delete;
-        GlyphCacheHolder& operator=(const GlyphCacheHolder&) = delete;
-
-    public:
-        GlyphCacheHolder()
-            : m_pSvpGlyphCache( new GlyphCache )
-        {
-        }
-        GlyphCache& getGlyphCache()
-        {
-            return *m_pSvpGlyphCache;
-        }
-    };
-
-    struct theGlyphCacheHolder :
-        public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder>
-    {};
-}
-
-GlyphCache& SvpSalGraphics::getPlatformGlyphCache()
-{
-    return theGlyphCacheHolder::get().getGlyphCache();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Data.hxx b/vcl/inc/qt5/Qt5Data.hxx
index 3cda6037c5e9..6f64925cb2f5 100644
--- a/vcl/inc/qt5/Qt5Data.hxx
+++ b/vcl/inc/qt5/Qt5Data.hxx
@@ -32,7 +32,6 @@ class QCursor;
 class VCLPLUG_QT5_PUBLIC Qt5Data : public GenericUnixSalData
 {
     o3tl::enumarray<PointerStyle, std::unique_ptr<QCursor>> m_aCursors;
-    std::unique_ptr<GlyphCache> m_pGlyphCache;
 
 public:
     explicit Qt5Data(SalInstance* pInstance);
diff --git a/vcl/inc/unx/gendata.hxx b/vcl/inc/unx/gendata.hxx
index c2ac8b1b6fa4..12824fb8bc69 100644
--- a/vcl/inc/unx/gendata.hxx
+++ b/vcl/inc/unx/gendata.hxx
@@ -16,59 +16,86 @@
 
 #include <memory>
 
+class GlyphCache;
 class SalGenericDisplay;
-namespace psp { class PrintFontManager; }
+namespace psp
+{
+class PrintFontManager;
+}
 
-enum GenericUnixSalDataType { SAL_DATA_GTK, SAL_DATA_GTK3,
-                              SAL_DATA_KDE4, SAL_DATA_KDE5,
-                              SAL_DATA_UNX, SAL_DATA_SVP,
-                              SAL_DATA_ANDROID, SAL_DATA_IOS,
-                              SAL_DATA_HEADLESS, SAL_DATA_QT5 };
+enum GenericUnixSalDataType
+{
+    SAL_DATA_GTK,
+    SAL_DATA_GTK3,
+    SAL_DATA_KDE4,
+    SAL_DATA_KDE5,
+    SAL_DATA_UNX,
+    SAL_DATA_SVP,
+    SAL_DATA_ANDROID,
+    SAL_DATA_IOS,
+    SAL_DATA_HEADLESS,
+    SAL_DATA_QT5
+};
 
 class VCL_DLLPUBLIC GenericUnixSalData : public SalData
 {
- protected:
+private:
     GenericUnixSalDataType const m_eType;
-    SalGenericDisplay *m_pDisplay;
+    SalGenericDisplay* m_pDisplay;
     // cached hostname to avoid slow lookup
-    OUString      m_aHostname;
+    OUString m_aHostname;
     // for transient storage of unicode strings eg. 'u123' by input methods
-    OUString      m_aUnicodeEntry;
+    OUString m_aUnicodeEntry;
 
-    friend class psp::PrintFontManager;
+    std::unique_ptr<GlyphCache> m_pGlyphCache;
     std::unique_ptr<psp::PrintFontManager> m_pPrintFontManager;
 
- public:
-    GenericUnixSalData(GenericUnixSalDataType const t, SalInstance *const pInstance);
+    void InitGlyphCache();
+    void InitPrintFontManager();
+
+public:
+    GenericUnixSalData(GenericUnixSalDataType const t, SalInstance* const pInstance);
     virtual ~GenericUnixSalData() override;
     virtual void Dispose() {}
 
-    SalGenericDisplay *GetDisplay() const { return m_pDisplay; }
-    void               SetDisplay( SalGenericDisplay *pDisp ) { m_pDisplay = pDisp; }
+    SalGenericDisplay* GetDisplay() const { return m_pDisplay; }
+    void SetDisplay(SalGenericDisplay* pDisp) { m_pDisplay = pDisp; }
 
     const OUString& GetHostname()
     {
         if (m_aHostname.isEmpty())
-            osl_getLocalHostname( &m_aHostname.pData );
+            osl_getLocalHostname(&m_aHostname.pData);
         return m_aHostname;
     }
-    OUString &GetUnicodeCommand()
+
+    OUString& GetUnicodeCommand() { return m_aUnicodeEntry; }
+
+    GenericUnixSalDataType GetType() const { return m_eType; }
+
+    GlyphCache* GetGlyphCache()
     {
-        return m_aUnicodeEntry;
+        if (!m_pGlyphCache)
+            InitGlyphCache();
+        return m_pGlyphCache.get();
     }
-    GenericUnixSalDataType GetType() const
+
+    psp::PrintFontManager* GetPrintFontManager()
     {
-        return m_eType;
+        if (!m_pPrintFontManager)
+            InitPrintFontManager();
+        // PrintFontManager needs the GlyphCache
+        assert(m_pGlyphCache.get());
+        return m_pPrintFontManager.get();
     }
 
     // Mostly useful for remote protocol backends
     virtual void ErrorTrapPush() = 0;
-    virtual bool ErrorTrapPop( bool bIgnoreError = true ) = 0; // true on error
+    virtual bool ErrorTrapPop(bool bIgnoreError = true) = 0; // true on error
 };
 
-inline GenericUnixSalData * GetGenericUnixSalData()
+inline GenericUnixSalData* GetGenericUnixSalData()
 {
-    return static_cast<GenericUnixSalData *>(ImplGetSVData()->mpSalData);
+    return static_cast<GenericUnixSalData*>(ImplGetSVData()->mpSalData);
 }
 
 #endif
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 561029b67bbd..446acc2944af 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -50,7 +50,7 @@ class SvpGcpHelper;
 namespace basegfx { class B2DPolyPolygon; }
 namespace vcl { struct FontCapabilities; }
 
-class VCL_DLLPUBLIC GlyphCache
+class VCL_DLLPUBLIC GlyphCache final
 {
 public:
     explicit                GlyphCache();
diff --git a/vcl/unx/generic/gdi/xrender_peer.hxx b/vcl/inc/unx/x11/xrender_peer.hxx
similarity index 97%
rename from vcl/unx/generic/gdi/xrender_peer.hxx
rename to vcl/inc/unx/x11/xrender_peer.hxx
index afe793b248da..05312bfcb3e5 100644
--- a/vcl/unx/generic/gdi/xrender_peer.hxx
+++ b/vcl/inc/unx/x11/xrender_peer.hxx
@@ -17,8 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_UNX_GENERIC_GDI_XRENDER_PEER_HXX
-#define INCLUDED_VCL_UNX_GENERIC_GDI_XRENDER_PEER_HXX
+#ifndef INCLUDED_VCL_UNX_X11_XRENDER_PEER_HXX
+#define INCLUDED_VCL_UNX_X11_XRENDER_PEER_HXX
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -161,6 +161,6 @@ inline XRenderColor GetXRenderColor( Color rColor, double fTransparency )
     return aRetVal;
 }
 
-#endif // INCLUDED_VCL_UNX_GENERIC_GDI_XRENDER_PEER_HXX
+#endif // INCLUDED_VCL_UNX_X11_XRENDER_PEER_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Data.cxx b/vcl/qt5/Qt5Data.cxx
index 74ba881ea15a..1830dab0e523 100644
--- a/vcl/qt5/Qt5Data.cxx
+++ b/vcl/qt5/Qt5Data.cxx
@@ -153,7 +153,6 @@
 
 Qt5Data::Qt5Data(SalInstance* pInstance)
     : GenericUnixSalData(SAL_DATA_QT5, pInstance)
-    , m_pGlyphCache(new GlyphCache())
 {
     ImplSVData* pSVData = ImplGetSVData();
 
diff --git a/vcl/unx/generic/gdi/gcach_xpeer.hxx b/vcl/unx/generic/app/gendata.cxx
similarity index 62%
rename from vcl/unx/generic/gdi/gcach_xpeer.hxx
rename to vcl/unx/generic/app/gendata.cxx
index 9fe75b706433..2e376cc2e3f3 100644
--- a/vcl/unx/generic/gdi/gcach_xpeer.hxx
+++ b/vcl/unx/generic/app/gendata.cxx
@@ -17,20 +17,29 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_UNX_GENERIC_GDI_GCACH_XPEER_HXX
-#define INCLUDED_VCL_UNX_GENERIC_GDI_GCACH_XPEER_HXX
+#include <unx/gendata.hxx>
 
+#include <unx/fontmanager.hxx>
 #include <unx/glyphcache.hxx>
 
-class X11GlyphCache : public GlyphCache
+GenericUnixSalData::GenericUnixSalData(GenericUnixSalDataType const t, SalInstance* const pInstance)
+    : m_eType(t)
+    , m_pDisplay(nullptr)
+    , m_pGlyphCache(new GlyphCache)
 {
-public:
-    explicit X11GlyphCache();
-    virtual ~X11GlyphCache() override;
-    static X11GlyphCache& GetInstance();
-    static void  KillInstance();
-};
+    m_pInstance = pInstance;
+    SetSalData(this);
+}
 
-#endif // INCLUDED_VCL_UNX_GENERIC_GDI_GCACH_XPEER_HXX
+GenericUnixSalData::~GenericUnixSalData() {}
+
+void GenericUnixSalData::InitGlyphCache() { m_pGlyphCache.reset(new GlyphCache); }
+
+void GenericUnixSalData::InitPrintFontManager()
+{
+    GetGlyphCache();
+    m_pPrintFontManager.reset(new psp::PrintFontManager);
+    m_pPrintFontManager->initialize();
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index 469bb0012193..b3251495b323 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -67,6 +67,8 @@
 #include <unx/salobj.h>
 #include <unx/sm.hxx>
 #include <unx/wmadaptor.hxx>
+#include <unx/x11/xrender_peer.hxx>
+#include <unx/glyphcache.hxx>
 
 #include <vcl/opengl/OpenGLHelper.hxx>
 
@@ -322,7 +324,28 @@ void SalDisplay::doDestruct()
 
     m_pWMAdaptor.reset();
     X11SalBitmap::ImplDestroyCache();
-    X11SalGraphics::releaseGlyphPeer();
+
+    if (ImplGetSVData())
+    {
+        SalDisplay* pSalDisp = vcl_sal::getSalDisplay(pData);
+        Display* const pX11Disp = pSalDisp->GetDisplay();
+        int nMaxScreens = pSalDisp->GetXScreenCount();
+        XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
+
+        for (int i = 0; i < nMaxScreens; i++)
+        {
+            SalDisplay::RenderEntryMap& rMap = pSalDisp->GetRenderEntries(SalX11Screen(i));
+            for (auto const& elem : rMap)
+            {
+                if (elem.second.m_aPixmap)
+                    ::XFreePixmap(pX11Disp, elem.second.m_aPixmap);
+                if (elem.second.m_aPicture)
+                    rRenderPeer.FreePicture(elem.second.m_aPicture);
+            }
+            rMap.clear();
+        }
+    }
+    GlyphCache::GetInstance().ClearFontCache();
 
     if( IsDisplay() )
     {
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index abd2c6c30232..7ea19def9e67 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -111,30 +111,14 @@ PrintFontManager::PrintFont::PrintFont()
 {
 }
 
-GenericUnixSalData::GenericUnixSalData(GenericUnixSalDataType const t, SalInstance *const pInstance)
-    : m_eType(t), m_pDisplay(nullptr)
-{
-    m_pInstance = pInstance; SetSalData(this);
-}
-
-GenericUnixSalData::~GenericUnixSalData()
-{
-}
-
 /*
  *  one instance only
  */
 PrintFontManager& PrintFontManager::get()
 {
-    GenericUnixSalData *const pSalData(GetGenericUnixSalData());
+    GenericUnixSalData* const pSalData(GetGenericUnixSalData());
     assert(pSalData);
-
-    if (!pSalData->m_pPrintFontManager)
-    {
-        pSalData->m_pPrintFontManager.reset( new PrintFontManager );
-        pSalData->m_pPrintFontManager->initialize();
-    }
-    return *pSalData->m_pPrintFontManager;
+    return *pSalData->GetPrintFontManager();
 }
 
 /*
diff --git a/vcl/unx/generic/gdi/gcach_xpeer.cxx b/vcl/unx/generic/gdi/gcach_xpeer.cxx
deleted file mode 100644
index 863d0a77cf8a..000000000000
--- a/vcl/unx/generic/gdi/gcach_xpeer.cxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <rtl/ustring.hxx>
-#include <osl/module.h>
-#include <osl/thread.h>
-
-#include <unx/saldisp.hxx>
-#include <unx/salgdi.h>
-
-#include "gcach_xpeer.hxx"
-#include "xrender_peer.hxx"
-
-X11GlyphCache::~X11GlyphCache()
-{
-    if( !ImplGetSVData() )
-        return;
-
-    //Why do this here, move into dtor/shutdown of display?
-    SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData());
-    Display* const pX11Disp = pSalDisp->GetDisplay();
-    int nMaxScreens = pSalDisp->GetXScreenCount();
-    XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
-
-    for( int i = 0; i < nMaxScreens; i++ )
-    {
-        SalDisplay::RenderEntryMap& rMap = pSalDisp->GetRenderEntries( SalX11Screen (i) );
-        for (auto const& elem : rMap)
-        {
-            if( elem.second.m_aPixmap )
-                ::XFreePixmap( pX11Disp, elem.second.m_aPixmap );
-            if( elem.second.m_aPicture )
-                rRenderPeer.FreePicture( elem.second.m_aPicture );
-        }
-        rMap.clear();
-    }
-}
-
-X11GlyphCache::X11GlyphCache()
-{
-}
-
-namespace
-{
-    struct GlyphCacheHolder
-    {
-    private:
-        std::unique_ptr<X11GlyphCache> m_pX11GlyphCache;
-
-        GlyphCacheHolder(const GlyphCacheHolder&) = delete;
-        GlyphCacheHolder& operator=(const GlyphCacheHolder&) = delete;
-
-    public:
-        GlyphCacheHolder()
-            : m_pX11GlyphCache(new X11GlyphCache)
-        {
-        }
-        void release()
-        {
-            m_pX11GlyphCache.reset();
-        }
-        X11GlyphCache& getGlyphCache()
-        {
-            return *m_pX11GlyphCache;
-        }
-    };
-
-    struct theGlyphCacheHolder :
-        public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder>
-    {};
-}
-
-X11GlyphCache& X11GlyphCache::GetInstance()
-{
-    return theGlyphCacheHolder::get().getGlyphCache();
-}
-
-void X11GlyphCache::KillInstance()
-{
-    return theGlyphCacheHolder::get().release();
-}
-
-void X11SalGraphics::releaseGlyphPeer()
-{
-    X11GlyphCache::KillInstance();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 582c3c147efe..0bfe098e7ef4 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -36,7 +36,7 @@
 #include <unx/salvd.h>
 #include <unx/x11/xlimits.hxx>
 #include <salframe.hxx>
-#include "xrender_peer.hxx"
+#include <unx/x11/xrender_peer.hxx>
 
 #include <outdata.hxx>
 
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index fd82c3929c88..271ecc937850 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -62,7 +62,7 @@
 #include "openglx11cairotextrender.hxx"
 
 #include <unx/printergfx.hxx>
-#include "xrender_peer.hxx"
+#include <unx/x11/xrender_peer.hxx>
 #include "cairo_xlib_cairo.hxx"
 #include <cairo-xlib.h>
 
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 15b9b313e9d2..ef0a422f19b2 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -32,7 +32,7 @@
 #include <unx/salvd.h>
 #include <unx/x11/x11gdiimpl.h>
 #include <unx/x11/xlimits.hxx>
-#include "xrender_peer.hxx"
+#include <unx/x11/xrender_peer.hxx>
 #include <salframe.hxx>
 
 #include <unx/printergfx.hxx>
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx
index 8960bd1c6bb1..88d5b49a1823 100644
--- a/vcl/unx/generic/gdi/x11cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx
@@ -20,7 +20,7 @@
 #include "x11cairotextrender.hxx"
 #include <unx/saldisp.hxx>
 #include <unx/salvd.h>
-#include "gcach_xpeer.hxx"
+#include <unx/glyphcache.hxx>
 #include <X11/Xregion.h>
 #include <cairo.h>
 
@@ -31,7 +31,7 @@ X11CairoTextRender::X11CairoTextRender(X11SalGraphics& rParent)
 
 GlyphCache& X11CairoTextRender::getPlatformGlyphCache()
 {
-    return X11GlyphCache::GetInstance();
+    return GlyphCache::GetInstance();
 }
 
 cairo_t* X11CairoTextRender::getCairoContext()
diff --git a/vcl/unx/generic/gdi/xrender_peer.cxx b/vcl/unx/generic/gdi/xrender_peer.cxx
index 2e23499606f1..f8794beb3c39 100644
--- a/vcl/unx/generic/gdi/xrender_peer.cxx
+++ b/vcl/unx/generic/gdi/xrender_peer.cxx
@@ -21,7 +21,7 @@
 #include <unx/salunx.h>
 #include <unx/saldisp.hxx>
 
-#include "xrender_peer.hxx"
+#include <unx/x11/xrender_peer.hxx>
 
 XRenderPeer::XRenderPeer()
     : mpDisplay( vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetDisplay() )
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index e2a1358b3567..5bdcf9ac7491 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <unx/freetype_glyphcache.hxx>
+#include <unx/gendata.hxx>
 
 #include <vcl/svapp.hxx>
 #include <vcl/bitmap.hxx>
@@ -30,8 +31,6 @@
 #include <osl/file.hxx>
 #include <sal/log.hxx>
 
-static GlyphCache* pInstance = nullptr;
-
 GlyphCache::GlyphCache()
 :   mnBytesUsed(sizeof(GlyphCache)),
     mnLruIndex(0),
@@ -39,8 +38,6 @@ GlyphCache::GlyphCache()
     mpCurrentGCFont(nullptr)
     , m_nMaxFontId(0)
 {
-    pInstance = this;
-
     InitFreetype();
 }
 
@@ -159,7 +156,9 @@ bool GlyphCache::IFSD_Equal::operator()(const rtl::Reference<LogicalFontInstance
 
 GlyphCache& GlyphCache::GetInstance()
 {
-    return *pInstance;
+    GenericUnixSalData* const pSalData(GetGenericUnixSalData());
+    assert(pSalData);
+    return *pSalData->GetGlyphCache();
 }
 
 FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance)


More information about the Libreoffice-commits mailing list