From 38f9ef832cd583366eb0a2a730baefec40534922 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 4 Jan 2016 21:51:28 +0000 Subject: tdf#96894 - get ordering right for TextureAtlas cleanup on shutdown. Do it much earlier - while we have a valid OpenGLContext. Change-Id: Ie258283147d02984b6f507c0075d114ae7288051 Reviewed-on: https://gerrit.libreoffice.org/21089 Reviewed-by: Michael Meeks Tested-by: Michael Meeks --- vcl/opengl/salbmp.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'vcl/opengl') diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 75d4d21a9c18..31038c37ff0d 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -28,6 +28,7 @@ #include "svdata.hxx" #include "salgdi.hxx" #include "vcleventlisteners.hxx" +#include "vcl/lazydelete.hxx" #include "opengl/zone.hxx" #include "opengl/program.hxx" @@ -97,7 +98,8 @@ sal_uInt16 lclBytesPerRow(sal_uInt16 nBits, int nWidth) return 0; } -static std::vector> sTextureAtlases; +typedef std::vector > TextureAtlasVector; +static vcl::DeleteOnDeinit< TextureAtlasVector > gTextureAtlases(new TextureAtlasVector()); } @@ -381,6 +383,7 @@ void lclInstantiateTexture(OpenGLTexture& rTexture, const int nWidth, const int { if (nWidth == nHeight) { + TextureAtlasVector &sTextureAtlases = *gTextureAtlases.get(); if (sTextureAtlases.empty()) { sTextureAtlases.push_back(std::unique_ptr(new FixedTextureAtlasManager(8, 8, 16))); @@ -582,8 +585,10 @@ bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& { OUString FragShader("areaHashCRC64TFragmentShader"); - static const OpenGLTexture aCRCTableTexture(512, 1, GL_RGBA, GL_UNSIGNED_BYTE, - vcl_get_crc64_table()); + static vcl::DeleteOnDeinit gCRCTableTexture( + new OpenGLTexture(512, 1, GL_RGBA, GL_UNSIGNED_BYTE, + vcl_get_crc64_table())); + OpenGLTexture &rCRCTableTexture = *gCRCTableTexture.get(); // First Pass @@ -603,7 +608,7 @@ bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& pProgram->SetUniform1f( "xstep", 1.0 / mnWidth ); pProgram->SetUniform1f( "ystep", 1.0 / mnHeight ); - pProgram->SetTexture("crc_table", (OpenGLTexture&)(aCRCTableTexture)); + pProgram->SetTexture("crc_table", rCRCTableTexture); pProgram->SetTexture("sampler", rInputTexture); pProgram->DrawTexture(rInputTexture); pProgram->Clean(); @@ -631,7 +636,7 @@ bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& pProgram->SetUniform1f( "xstep", 1.0 / mnWidth ); pProgram->SetUniform1f( "ystep", 1.0 / mnHeight ); - pProgram->SetTexture("crc_table", (OpenGLTexture&)(aCRCTableTexture)); + pProgram->SetTexture("crc_table", rCRCTableTexture); pProgram->SetTexture("sampler", aFirstPassTexture); pProgram->DrawTexture(aFirstPassTexture); pProgram->Clean(); -- cgit