mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Fix rendering performance on macOS
This commit is contained in:
parent
24b30caf94
commit
3e4af381c9
3 changed files with 42 additions and 2 deletions
|
@ -2,6 +2,8 @@
|
|||
#define slic3r_Utils_hpp_
|
||||
|
||||
#include <locale>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
#include "libslic3r.h"
|
||||
|
@ -148,6 +150,37 @@ template<class T> size_t next_highest_power_of_2(T v,
|
|||
|
||||
extern std::string xml_escape(std::string text);
|
||||
|
||||
|
||||
class ScopeGuard
|
||||
{
|
||||
public:
|
||||
typedef std::function<void()> Closure;
|
||||
private:
|
||||
bool committed;
|
||||
Closure closure;
|
||||
|
||||
public:
|
||||
ScopeGuard() {}
|
||||
ScopeGuard(Closure closure) : closure(std::move(closure)) {}
|
||||
ScopeGuard(const ScopeGuard&) = delete;
|
||||
ScopeGuard(ScopeGuard &&other) : closure(std::move(other.closure)) {}
|
||||
|
||||
~ScopeGuard()
|
||||
{
|
||||
if (closure) { closure(); }
|
||||
}
|
||||
|
||||
ScopeGuard& operator=(const ScopeGuard&) = delete;
|
||||
ScopeGuard& operator=(ScopeGuard &&other)
|
||||
{
|
||||
closure = std::move(other.closure);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void reset() { closure = Closure(); }
|
||||
};
|
||||
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_Utils_hpp_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue