mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Merge remote-tracking branch 'origin/dev_native' into tm_sla_supports_backend
This commit is contained in:
		
						commit
						100386c699
					
				
					 3 changed files with 61 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
#include <boost/nowide/cenv.hpp>
 | 
			
		||||
#include <boost/nowide/fstream.hpp>
 | 
			
		||||
#include <boost/property_tree/ini_parser.hpp>
 | 
			
		||||
#include <boost/format.hpp>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
namespace Slic3r {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,9 @@
 | 
			
		|||
#define slic3r_Utils_hpp_
 | 
			
		||||
 | 
			
		||||
#include <locale>
 | 
			
		||||
#include <utility>
 | 
			
		||||
#include <functional>
 | 
			
		||||
#include <type_traits>
 | 
			
		||||
 | 
			
		||||
#include "libslic3r.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -124,24 +127,60 @@ inline uint64_t next_highest_power_of_2(uint64_t v)
 | 
			
		|||
    return ++ v;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef __clang__
 | 
			
		||||
// On clang, the size_t is a type of its own, so we need to overload for size_t.
 | 
			
		||||
// On MSC, the size_t type aliases to uint64_t / uint32_t, so the following code
 | 
			
		||||
// gives a duplicate symbol error.
 | 
			
		||||
inline size_t next_highest_power_of_2(size_t v)
 | 
			
		||||
{ 
 | 
			
		||||
#if SSIZE_MAX == 9223372036854775807
 | 
			
		||||
    static_assert(sizeof(size_t) == sizeof(uint64_t), "sizeof(size_t) == sizeof(uint64_t)");
 | 
			
		||||
// On some implementations (such as some versions of clang), the size_t is a type of its own, so we need to overload for size_t.
 | 
			
		||||
// Typically, though, the size_t type aliases to uint64_t / uint32_t.
 | 
			
		||||
// We distinguish that here and provide implementation for size_t if and only if it is a distinct type
 | 
			
		||||
template<class T> size_t next_highest_power_of_2(T v,
 | 
			
		||||
    typename std::enable_if<std::is_same<T, size_t>::value, T>::type = 0,     // T is size_t
 | 
			
		||||
    typename std::enable_if<!std::is_same<T, uint64_t>::value, T>::type = 0,  // T is not uint64_t
 | 
			
		||||
    typename std::enable_if<!std::is_same<T, uint32_t>::value, T>::type = 0,  // T is not uint32_t
 | 
			
		||||
    typename std::enable_if<sizeof(T) == 8, T>::type = 0)                     // T is 64 bits
 | 
			
		||||
{
 | 
			
		||||
    return next_highest_power_of_2(uint64_t(v));
 | 
			
		||||
#else
 | 
			
		||||
    static_assert(sizeof(size_t) == sizeof(uint32_t), "sizeof(size_t) == sizeof(uint32_t)");
 | 
			
		||||
    return next_highest_power_of_2(uint32_t(v));
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
template<class T> size_t next_highest_power_of_2(T v,
 | 
			
		||||
    typename std::enable_if<std::is_same<T, size_t>::value, T>::type = 0,     // T is size_t
 | 
			
		||||
    typename std::enable_if<!std::is_same<T, uint64_t>::value, T>::type = 0,  // T is not uint64_t
 | 
			
		||||
    typename std::enable_if<!std::is_same<T, uint32_t>::value, T>::type = 0,  // T is not uint32_t
 | 
			
		||||
    typename std::enable_if<sizeof(T) == 4, T>::type = 0)                     // T is 32 bits
 | 
			
		||||
{
 | 
			
		||||
    return next_highest_power_of_2(uint32_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_
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4768,8 +4768,14 @@ void GLCanvas3D::_refresh_if_shown_on_screen()
 | 
			
		|||
    {
 | 
			
		||||
        const Size& cnv_size = get_canvas_size();
 | 
			
		||||
        _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
 | 
			
		||||
        if (m_canvas != nullptr)
 | 
			
		||||
            m_canvas->Refresh();
 | 
			
		||||
 | 
			
		||||
        // Because of performance problems on macOS, where PaintEvents are not delivered
 | 
			
		||||
        // frequently enough, we call render() here directly when we can.
 | 
			
		||||
        // We can't do that when m_force_zoom_to_bed_enabled == true, because then render()
 | 
			
		||||
        // ends up calling back here via _force_zoom_to_bed(), causing a stack overflow.
 | 
			
		||||
        if (m_canvas != nullptr) {
 | 
			
		||||
            m_force_zoom_to_bed_enabled ? m_canvas->Refresh() : render();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue