summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-04-21 16:38:22 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-04-22 09:53:57 +0200
commitd0241ea85b6836d2ffa3c00d5e01e7b5ff9b3c15 (patch)
tree21dc322537a2107bf821eed64bb031f5422edebd /vcl/inc
parent93b500ee7c1cbb141bb77b94054f3bee9c3b510a (diff)
Don't keep gGlobalGlyphCache, gTextureCache around until exit
Those static variables had been introduced with 56c5a0ba7781a325123852737970fa7f0179ff7f "tdf#94682 limit the number of textures for the glyph texture atlas" and dea885f80a80c6a5839ee5dbf8521487186a9522 "opengl: cache native widget textures also for Windows", but at least the clang-cl build crashed on exit from soffice.bin with > Exception thrown at 0x00007FFF3906AA84 (opengl32.dll) in soffice.bin: 0xC0000005: Access violation reading location 0x0000000000000898. > opengl32.dll!glGetString() Unknown > epoxy.dll!epoxy_glGetString_dispatch_table_rewrite_ptr(unsigned int name) Line 46456 C > epoxy.dll!epoxy_glGetString_dispatch_table_thunk(unsigned int name) Line 46456 C > epoxy.dll!epoxy_is_desktop_gl() Line 299 C > epoxy.dll!gl_provider_resolver(const char * name, const gl_provider * providers, const unsigned short * entrypoints) Line 7323 C > epoxy.dll!epoxy_glDeleteTextures_resolver() Line 14646 C > epoxy.dll!epoxy_glDeleteTextures_dispatch_table_rewrite_ptr(int n, const unsigned int * textures) Line 45813 C > epoxy.dll!epoxy_glDeleteTextures_dispatch_table_thunk(int n, const unsigned int * textures) Line 45813 C > vcllo.dll!TextureState::unbindAndDelete(unsigned int nTexture) Line 59 C++ > vcllo.dll!ImplOpenGLTexture::~ImplOpenGLTexture() Line 182 C++ > [External Code] > vcllo.dll!PackedTextureAtlasManager::~PackedTextureAtlasManager() Line 129 C++ > vcllo.dll!GlobalGlyphCache::~GlobalGlyphCache() Line 67 C++ > [External Code] > vcllo.dll!??__FgGlobalGlyphCache@GlyphCache@@0V?$unique_ptr@UGlobalGlyphCache@@U?$default_delete@UGlobalGlyphCache@@@std@@@std@@A@YAXXZ() Line 48 C++ > [External Code] resp. > Exception thrown at 0x00007FFF3A5AAA84 (opengl32.dll) in soffice.bin: 0xC0000005: Access violation reading location 0x0000000000000898. > opengl32.dll!glGetString() Unknown > epoxy.dll!epoxy_glGetString_dispatch_table_rewrite_ptr(unsigned int name) Line 46456 C > epoxy.dll!epoxy_glGetString_dispatch_table_thunk(unsigned int name) Line 46456 C > epoxy.dll!epoxy_is_desktop_gl() Line 299 C > epoxy.dll!gl_provider_resolver(const char * name, const gl_provider * providers, const unsigned short * entrypoints) Line 7323 C > epoxy.dll!epoxy_glDeleteTextures_resolver() Line 14646 C > epoxy.dll!epoxy_glDeleteTextures_dispatch_table_rewrite_ptr(int n, const unsigned int * textures) Line 45813 C > epoxy.dll!epoxy_glDeleteTextures_dispatch_table_thunk(int n, const unsigned int * textures) Line 45813 C > vcllo.dll!TextureState::unbindAndDelete(unsigned int nTexture) Line 59 C++ > vcllo.dll!ImplOpenGLTexture::~ImplOpenGLTexture() Line 182 C++ > [External Code] > vcllo.dll!OpenGLTexture::~OpenGLTexture() Line 313 C++ > [External Code] > vcllo.dll!TextureCombo::~TextureCombo() Line 51 C++ > [External Code] > vcllo.dll!std::pair<ControlCacheKey, std::unique_ptr<TextureCombo, std::default_delete<TextureCombo> > >::~pair() Line 145 C++ > [External Code] > vcllo.dll!o3tl::lru_map<ControlCacheKey, std::unique_ptr<TextureCombo, std::default_delete<TextureCombo> >, ControlCacheHashFunction>::~lru_map() Line 34 C++ > vcllo.dll!??__FgTextureCache@?A@@YAXXZ() Line 738 C++ > [External Code] Change-Id: I0198f657f5d59314c5f662c214504ed3e1523567 Reviewed-on: https://gerrit.libreoffice.org/36801 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/opengl/win/gdiimpl.hxx14
-rw-r--r--vcl/inc/win/saldata.hxx4
-rw-r--r--vcl/inc/win/winlayout.hxx9
3 files changed, 23 insertions, 4 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;