mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Refactoring into GLTexture::Compressor
This commit is contained in:
parent
f913bbf8ef
commit
299739eeda
2 changed files with 11 additions and 6 deletions
|
@ -27,10 +27,13 @@ namespace GUI {
|
||||||
|
|
||||||
void GLTexture::Compressor::reset()
|
void GLTexture::Compressor::reset()
|
||||||
{
|
{
|
||||||
// force compression completion, if any
|
if (m_is_compressing)
|
||||||
m_abort_compressing = true;
|
{
|
||||||
// wait for compression completion, if any
|
// force compression completion, if any
|
||||||
while (m_is_compressing) {}
|
m_abort_compressing = true;
|
||||||
|
// wait for compression completion, if any
|
||||||
|
while (m_is_compressing) {}
|
||||||
|
}
|
||||||
|
|
||||||
m_levels.clear();
|
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()
|
void GLTexture::Compressor::start_compressing()
|
||||||
{
|
{
|
||||||
m_is_compressing = true;
|
|
||||||
m_abort_compressing = false;
|
|
||||||
std::thread t(&GLTexture::Compressor::compress, this);
|
std::thread t(&GLTexture::Compressor::compress, this);
|
||||||
t.detach();
|
t.detach();
|
||||||
}
|
}
|
||||||
|
@ -97,6 +98,9 @@ void GLTexture::Compressor::compress()
|
||||||
{
|
{
|
||||||
// reference: https://github.com/Cyan4973/RygsDXTc
|
// reference: https://github.com/Cyan4973/RygsDXTc
|
||||||
|
|
||||||
|
m_is_compressing = true;
|
||||||
|
m_abort_compressing = false;
|
||||||
|
|
||||||
for (Level& level : m_levels)
|
for (Level& level : m_levels)
|
||||||
{
|
{
|
||||||
if (m_abort_compressing)
|
if (m_abort_compressing)
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace GUI {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Compressor(GLTexture& texture) : m_texture(texture), m_is_compressing(false), m_abort_compressing(false) {}
|
explicit Compressor(GLTexture& texture) : m_texture(texture), m_is_compressing(false), m_abort_compressing(false) {}
|
||||||
|
~Compressor() { reset(); }
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue