mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 16:59:04 +08:00
Refactoring into GLTexture::Compressor
This commit is contained in:
parent
f913bbf8ef
commit
299739eeda
@ -26,11 +26,14 @@ namespace Slic3r {
|
|||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
void GLTexture::Compressor::reset()
|
void GLTexture::Compressor::reset()
|
||||||
|
{
|
||||||
|
if (m_is_compressing)
|
||||||
{
|
{
|
||||||
// force compression completion, if any
|
// force compression completion, if any
|
||||||
m_abort_compressing = true;
|
m_abort_compressing = true;
|
||||||
// wait for compression completion, if any
|
// wait for compression completion, if any
|
||||||
while (m_is_compressing) {}
|
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…
x
Reference in New Issue
Block a user