Refactoring into GLTexture::Compressor

This commit is contained in:
Enrico Turri 2019-08-01 11:01:18 +02:00
parent f913bbf8ef
commit 299739eeda
2 changed files with 11 additions and 6 deletions

View File

@ -27,10 +27,13 @@ namespace GUI {
void GLTexture::Compressor::reset()
{
// force compression completion, if any
m_abort_compressing = true;
// wait for compression completion, if any
while (m_is_compressing) {}
if (m_is_compressing)
{
// force compression completion, if any
m_abort_compressing = true;
// wait for compression completion, if any
while (m_is_compressing) {}
}
m_levels.clear();
}
@ -42,8 +45,6 @@ void GLTexture::Compressor::add_level(unsigned int w, unsigned int h, const std:
void GLTexture::Compressor::start_compressing()
{
m_is_compressing = true;
m_abort_compressing = false;
std::thread t(&GLTexture::Compressor::compress, this);
t.detach();
}
@ -97,6 +98,9 @@ void GLTexture::Compressor::compress()
{
// reference: https://github.com/Cyan4973/RygsDXTc
m_is_compressing = true;
m_abort_compressing = false;
for (Level& level : m_levels)
{
if (m_abort_compressing)

View File

@ -32,6 +32,7 @@ namespace GUI {
public:
explicit Compressor(GLTexture& texture) : m_texture(texture), m_is_compressing(false), m_abort_compressing(false) {}
~Compressor() { reset(); }
void reset();