diff options
-rw-r--r-- | vcl/inc/opengl/win/gdiimpl.hxx | 14 | ||||
-rw-r--r-- | vcl/inc/win/saldata.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 9 | ||||
-rw-r--r-- | vcl/opengl/win/gdiimpl.cxx | 18 | ||||
-rw-r--r-- | vcl/win/app/salinst.cxx | 1 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 9 |
6 files changed, 40 insertions, 15 deletions
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx index 374d6ff42682..d3435e2550de 100644 --- a/vcl/inc/opengl/win/gdiimpl.hxx +++ b/vcl/inc/opengl/win/gdiimpl.hxx @@ -13,7 +13,9 @@ #include <vcl/dllapi.h> #include "openglgdiimpl.hxx" +#include "svdata.hxx" #include "win/salgdi.h" +#include <o3tl/lru_map.hxx> #include <vcl/opengl/OpenGLContext.hxx> #include "ControlCacheKey.hxx" @@ -47,6 +49,18 @@ public: }; +typedef std::pair<ControlCacheKey, std::unique_ptr<TextureCombo>> ControlCachePair; +typedef o3tl::lru_map<ControlCacheKey, std::unique_ptr<TextureCombo>, ControlCacheHashFunction> ControlCacheType; + +class TheTextureCache { + ControlCacheType cache; + + TheTextureCache(); + +public: + static ControlCacheType & get(); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx index 0e13cef9970a..c38cc56a71bf 100644 --- a/vcl/inc/win/saldata.hxx +++ b/vcl/inc/win/saldata.hxx @@ -37,9 +37,11 @@ class WinSalFrame; class WinSalVirtualDevice; class WinSalPrinter; namespace vcl { class Font; } +struct GlobalGlyphCache; struct HDCCache; struct TempFontItem; class TextOutRenderer; +class TheTextureCache; #define MAX_STOCKPEN 4 #define MAX_STOCKBRUSH 4 @@ -122,6 +124,8 @@ public: // must be deleted before exit(), so delete it in DeInitSalData() std::unique_ptr<TextOutRenderer> m_pTextOutRenderer; + std::unique_ptr<GlobalGlyphCache> m_pGlobalGlyphCache; + std::unique_ptr<TheTextureCache> m_pTextureCache; }; inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; } diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index 19b5e0f9d9f8..456d371b52b8 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -72,28 +72,29 @@ struct GlobalGlyphCache PackedTextureAtlasManager maPackedTextureAtlas; std::unordered_set<GlyphCache*> maGlyphCaches; + + static GlobalGlyphCache * get(); }; class GlyphCache { private: - static std::unique_ptr<GlobalGlyphCache> gGlobalGlyphCache; std::unordered_map<int, OpenGLGlyphDrawElement> maOpenGLTextureCache; public: GlyphCache() { - gGlobalGlyphCache.get()->maGlyphCaches.insert(this); + GlobalGlyphCache::get()->maGlyphCaches.insert(this); } ~GlyphCache() { - gGlobalGlyphCache.get()->maGlyphCaches.erase(this); + GlobalGlyphCache::get()->maGlyphCaches.erase(this); } static bool ReserveTextureSpace(OpenGLGlyphDrawElement& rElement, int nWidth, int nHeight) { - GlobalGlyphCache* pGlobalGlyphCache = gGlobalGlyphCache.get(); + GlobalGlyphCache* pGlobalGlyphCache = GlobalGlyphCache::get(); rElement.maTexture = pGlobalGlyphCache->maPackedTextureAtlas.Reserve(nWidth, nHeight); if (!rElement.maTexture) return false; diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index 5a5516db63de..ec2ca14ed816 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -11,7 +11,6 @@ #include <comphelper/windowserrorstring.hxx> #include <opengl/zone.hxx> -#include <o3tl/lru_map.hxx> #include <win/wincomp.hxx> #include <win/saldata.hxx> #include <win/salframe.h> @@ -729,14 +728,14 @@ void WinOpenGLSalGraphicsImpl::Init() OpenGLSalGraphicsImpl::Init(); } -namespace -{ - -typedef std::pair<ControlCacheKey, std::unique_ptr<TextureCombo>> ControlCachePair; -typedef o3tl::lru_map<ControlCacheKey, std::unique_ptr<TextureCombo>, ControlCacheHashFunction> ControlCacheType; - -ControlCacheType gTextureCache(200); +TheTextureCache::TheTextureCache(): cache(200) {} +ControlCacheType & TheTextureCache::get() { + SalData * data = GetSalData(); + if (!data->m_pTextureCache) { + data->m_pTextureCache.reset(new TheTextureCache); + } + return data->m_pTextureCache->cache; } bool WinOpenGLSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey& rControlCacheKey, int nX, int nY) @@ -746,6 +745,7 @@ bool WinOpenGLSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey& rCo if (!gbCacheEnabled) return false; + auto & gTextureCache = TheTextureCache::get(); ControlCacheType::const_iterator iterator = gTextureCache.find(rControlCacheKey); if (iterator == gTextureCache.end()) @@ -805,7 +805,7 @@ bool WinOpenGLSalGraphicsImpl::RenderAndCacheNativeControl(OpenGLCompatibleDC& r return true; ControlCachePair pair(aControlCacheKey, std::move(pCombo)); - gTextureCache.insert(std::move(pair)); + TheTextureCache::get().insert(std::move(pair)); return bResult; } diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index c5cab1fd2d82..556199843869 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -31,6 +31,7 @@ #include <vcl/timer.hxx> #include "opengl/salbmp.hxx" +#include "opengl/win/gdiimpl.hxx" #include "win/wincomp.hxx" #include "win/salids.hrc" #include "win/saldata.hxx" diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index c457e62a2296..8bea277c8dde 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -44,8 +44,13 @@ #include <shlwapi.h> #include <winver.h> -// static initialization -std::unique_ptr<GlobalGlyphCache> GlyphCache::gGlobalGlyphCache(new GlobalGlyphCache); +GlobalGlyphCache * GlobalGlyphCache::get() { + SalData * data = GetSalData(); + if (!data->m_pGlobalGlyphCache) { + data->m_pGlobalGlyphCache.reset(new GlobalGlyphCache); + } + return data->m_pGlobalGlyphCache.get(); +} bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics) { |