From 299739eeda87841d2c1779e9edfc6dcb09118b7a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 1 Aug 2019 11:01:18 +0200 Subject: [PATCH] Refactoring into GLTexture::Compressor --- src/slic3r/GUI/GLTexture.cpp | 16 ++++++++++------ src/slic3r/GUI/GLTexture.hpp | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index f3421f1508..516f8b934f 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -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) diff --git a/src/slic3r/GUI/GLTexture.hpp b/src/slic3r/GUI/GLTexture.hpp index 7fc5b8fcf6..ec362944d4 100644 --- a/src/slic3r/GUI/GLTexture.hpp +++ b/src/slic3r/GUI/GLTexture.hpp @@ -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();