mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-10 17:21:10 +00:00
fix: Home start shows Prepare or a blank window, and Prepare opens slowly (#15878)
This commit is contained in:
+126
-124
@@ -799,67 +799,8 @@ void PartPlate::render_logo(bool bottom, bool render_cali)
|
||||
{
|
||||
if (!m_partplate_list->render_bedtype_logo) {
|
||||
// render third-party printer texture logo
|
||||
if (m_partplate_list->m_logo_texture_filename.empty()) {
|
||||
m_partplate_list->m_logo_texture.reset();
|
||||
if (!m_partplate_list->load_logo_texture())
|
||||
return;
|
||||
}
|
||||
|
||||
//GLTexture* temp_texture = const_cast<GLTexture*>(&m_temp_texture);
|
||||
|
||||
if (m_partplate_list->m_logo_texture.get_id() == 0 || m_partplate_list->m_logo_texture.get_source() != m_partplate_list->m_logo_texture_filename) {
|
||||
m_partplate_list->m_logo_texture.reset();
|
||||
|
||||
if (boost::algorithm::iends_with(m_partplate_list->m_logo_texture_filename, ".svg")) {
|
||||
/*// use higher resolution images if graphic card and opengl version allow
|
||||
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
|
||||
if (temp_texture->get_id() == 0 || temp_texture->get_source() != m_texture_filename) {
|
||||
// generate a temporary lower resolution texture to show while no main texture levels have been compressed
|
||||
if (!temp_texture->load_from_svg_file(m_texture_filename, false, false, false, max_tex_size / 8)) {
|
||||
render_default(bottom, false);
|
||||
return;
|
||||
}
|
||||
canvas.request_extra_frame();
|
||||
}*/
|
||||
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
|
||||
GLint logo_tex_size = (max_tex_size < 2048) ? max_tex_size : 2048;
|
||||
if (!m_partplate_list->m_logo_texture.load_from_svg_file(m_partplate_list->m_logo_texture_filename, true, true, true, logo_tex_size)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % m_partplate_list->m_logo_texture_filename;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (boost::algorithm::iends_with(m_partplate_list->m_logo_texture_filename, ".png")) {
|
||||
// generate a temporary lower resolution texture to show while no main texture levels have been compressed
|
||||
/* if (temp_texture->get_id() == 0 || temp_texture->get_source() != m_logo_texture_filename) {
|
||||
if (!temp_texture->load_from_file(m_logo_texture_filename, false, GLTexture::None, false)) {
|
||||
render_default(bottom, false);
|
||||
return;
|
||||
}
|
||||
canvas.request_extra_frame();
|
||||
}*/
|
||||
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
if (!m_partplate_list->m_logo_texture.load_from_file(m_partplate_list->m_logo_texture_filename, true, GLTexture::MultiThreaded, true)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % m_partplate_list->m_logo_texture_filename;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": can not load logo texture from %1%, unsupported format") % m_partplate_list->m_logo_texture_filename;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (m_partplate_list->m_logo_texture.unsent_compressed_data_available()) {
|
||||
// sends to gpu the already available compressed levels of the main texture
|
||||
m_partplate_list->m_logo_texture.send_compressed_data_to_gpu();
|
||||
|
||||
// the temporary texture is not needed anymore, reset it
|
||||
//if (temp_texture->get_id() != 0)
|
||||
// temp_texture->reset();
|
||||
|
||||
//canvas.request_extra_frame();
|
||||
}
|
||||
|
||||
if (m_logo_triangles.is_initialized())
|
||||
render_logo_texture(m_partplate_list->m_logo_texture, m_logo_triangles, bottom);
|
||||
@@ -4232,6 +4173,7 @@ Vec2d PartPlateList::compute_shape_position(int index, int cols)
|
||||
//generate icon textures
|
||||
void PartPlateList::generate_icon_textures()
|
||||
{
|
||||
m_icon_textures_dark = m_is_dark;
|
||||
// use higher resolution images if graphic card and opengl version allow
|
||||
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size(), icon_size = max_tex_size / 8;
|
||||
std::string path = resources_dir() + "/images/";
|
||||
@@ -4447,6 +4389,9 @@ void PartPlateList::release_icon_textures()
|
||||
PartPlateList::is_load_bedtype_textures = false;
|
||||
PartPlateList::is_load_extruder_only_area_textures = false;
|
||||
PartPlateList::is_load_cali_texture = false;
|
||||
m_next_bedtype_texture = 0;
|
||||
m_next_extruder_only_area_texture = 0;
|
||||
m_next_cali_texture = 0;
|
||||
for (int i = 0; i < btCount; i++) {
|
||||
for (auto& part: bed_texture_info[i].parts) {
|
||||
if (part.texture) {
|
||||
@@ -6002,12 +5947,7 @@ void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& pr
|
||||
plate_hover_action = hover_id % PartPlate::GRABBER_COUNT;
|
||||
}
|
||||
|
||||
static bool last_dark_mode_status = m_is_dark;
|
||||
if (m_is_dark != last_dark_mode_status) {
|
||||
last_dark_mode_status = m_is_dark;
|
||||
generate_icon_textures();
|
||||
} else if(m_del_texture.get_id() == 0)
|
||||
generate_icon_textures();
|
||||
load_icon_textures();
|
||||
for (it = m_plate_list.begin(); it != m_plate_list.end(); it++) {
|
||||
int current_index = (*it)->get_index();
|
||||
if (only_current && (current_index != m_current_plate))
|
||||
@@ -6149,6 +6089,8 @@ bool PartPlateList::set_shapes(const Pointfs &shape,
|
||||
}
|
||||
is_load_bedtype_textures = false; //reload textures
|
||||
is_load_extruder_only_area_textures = false; // reload textures
|
||||
m_next_bedtype_texture = 0;
|
||||
m_next_extruder_only_area_texture = 0;
|
||||
calc_bounding_boxes();
|
||||
|
||||
update_logo_texture_filename(texture_filename);
|
||||
@@ -7089,53 +7031,120 @@ bool PartPlateList::init_extruder_only_area_info()
|
||||
return true;
|
||||
}
|
||||
|
||||
void PartPlateList::load_bedtype_textures()
|
||||
static GLint logo_texture_size()
|
||||
{
|
||||
if (PartPlateList::is_load_bedtype_textures) return;
|
||||
|
||||
init_bed_type_info();
|
||||
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
|
||||
GLint logo_tex_size = (max_tex_size < 2048) ? max_tex_size : 2048;
|
||||
for (int i = 0; i < (unsigned int)btCount; ++i) {
|
||||
for (int j = 0; j < bed_texture_info[i].parts.size(); j++) {
|
||||
std::string filename = resources_dir() + "/images/" + bed_texture_info[i].parts[j].filename;
|
||||
if (boost::filesystem::exists(filename)) {
|
||||
PartPlateList::bed_texture_info[i].parts[j].texture = new GLTexture();
|
||||
if (!PartPlateList::bed_texture_info[i].parts[j].texture->load_from_svg_file(filename, true, true, true, logo_tex_size)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % filename;
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
PartPlateList::is_load_bedtype_textures = true;
|
||||
return std::min<GLint>(OpenGLManager::get_gl_info().get_max_tex_size(), 2048);
|
||||
}
|
||||
|
||||
void PartPlateList::load_extruder_only_area_textures() {
|
||||
if (PartPlateList::is_load_extruder_only_area_textures) return;
|
||||
// Loads the texture of the next untried part across the parts of `infos`, in order, advancing
|
||||
// `next`; false once every part has been tried.
|
||||
static bool load_next_part_texture(PartPlateList::BedTextureInfo* infos, size_t count, size_t& next, bool compress_and_filter)
|
||||
{
|
||||
size_t k = next;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (k >= infos[i].parts.size()) {
|
||||
k -= infos[i].parts.size();
|
||||
continue;
|
||||
}
|
||||
++next;
|
||||
PartPlateList::BedTextureInfo::TexturePart& part = infos[i].parts[k];
|
||||
const std::string filename = resources_dir() + "/images/" + part.filename;
|
||||
if (boost::filesystem::exists(filename)) {
|
||||
part.texture = new GLTexture();
|
||||
if (!part.texture->load_from_svg_file(filename, true, compress_and_filter, compress_and_filter, logo_texture_size()))
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load texture from %1% failed!") % filename;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load texture from %1% failed!") % filename;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ok = init_extruder_only_area_info();
|
||||
if (!ok) {
|
||||
void PartPlateList::load_bedtype_textures()
|
||||
{
|
||||
while (load_next_bedtype_texture()) {}
|
||||
}
|
||||
|
||||
bool PartPlateList::load_next_bedtype_texture()
|
||||
{
|
||||
if (PartPlateList::is_load_bedtype_textures)
|
||||
return false;
|
||||
if (m_next_bedtype_texture == 0)
|
||||
init_bed_type_info();
|
||||
if (load_next_part_texture(bed_texture_info, btCount, m_next_bedtype_texture, true))
|
||||
return true;
|
||||
PartPlateList::is_load_bedtype_textures = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PartPlateList::load_logo_texture()
|
||||
{
|
||||
if (m_logo_texture_filename.empty()) {
|
||||
m_logo_texture.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_logo_texture.get_id() != 0 && m_logo_texture.get_source() == m_logo_texture_filename) {
|
||||
if (m_logo_texture.unsent_compressed_data_available())
|
||||
// sends to gpu the already available compressed levels of the main texture
|
||||
m_logo_texture.send_compressed_data_to_gpu();
|
||||
return true;
|
||||
}
|
||||
|
||||
m_logo_texture.reset();
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
if (boost::algorithm::iends_with(m_logo_texture_filename, ".svg")) {
|
||||
if (!m_logo_texture.load_from_svg_file(m_logo_texture_filename, true, true, true, logo_texture_size())) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % m_logo_texture_filename;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (boost::algorithm::iends_with(m_logo_texture_filename, ".png")) {
|
||||
if (!m_logo_texture.load_from_file(m_logo_texture_filename, true, GLTexture::MultiThreaded, true)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % m_logo_texture_filename;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": can not load logo texture from %1%, unsupported format") % m_logo_texture_filename;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PartPlateList::load_icon_textures()
|
||||
{
|
||||
if (!icon_textures_loaded())
|
||||
generate_icon_textures();
|
||||
}
|
||||
|
||||
bool PartPlateList::load_next_plate_texture()
|
||||
{
|
||||
if (!render_bedtype_logo) {
|
||||
load_logo_texture();
|
||||
return false;
|
||||
}
|
||||
return load_next_bedtype_texture() || load_next_cali_texture() || load_next_extruder_only_area_texture();
|
||||
}
|
||||
|
||||
void PartPlateList::load_extruder_only_area_textures()
|
||||
{
|
||||
while (load_next_extruder_only_area_texture()) {}
|
||||
}
|
||||
|
||||
bool PartPlateList::load_next_extruder_only_area_texture()
|
||||
{
|
||||
if (PartPlateList::is_load_extruder_only_area_textures)
|
||||
return false;
|
||||
if (m_next_extruder_only_area_texture == 0 && !init_extruder_only_area_info()) {
|
||||
PartPlateList::is_load_extruder_only_area_textures = true;
|
||||
return;
|
||||
}
|
||||
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
|
||||
GLint logo_tex_size = (max_tex_size < 2048) ? max_tex_size : 2048;
|
||||
for (int i = 0; i < (unsigned int) ExtruderOnlyAreaType::btAreaCount; ++i) {
|
||||
for (int j = 0; j < extruder_only_area_info[i].parts.size(); j++) {
|
||||
std::string filename = resources_dir() + "/images/" + extruder_only_area_info[i].parts[j].filename;
|
||||
if (boost::filesystem::exists(filename)) {
|
||||
PartPlateList::extruder_only_area_info[i].parts[j].texture = new GLTexture();
|
||||
if (!PartPlateList::extruder_only_area_info[i].parts[j].texture->load_from_svg_file(filename, true, false, false, logo_tex_size)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % filename;
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % filename;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (load_next_part_texture(extruder_only_area_info, (size_t) ExtruderOnlyAreaType::btAreaCount, m_next_extruder_only_area_texture, false))
|
||||
return true;
|
||||
PartPlateList::is_load_extruder_only_area_textures = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void PartPlateList::init_cali_texture_info()
|
||||
@@ -7150,26 +7159,19 @@ void PartPlateList::init_cali_texture_info()
|
||||
|
||||
void PartPlateList::load_cali_textures()
|
||||
{
|
||||
if (PartPlateList::is_load_cali_texture) return;
|
||||
while (load_next_cali_texture()) {}
|
||||
}
|
||||
|
||||
init_cali_texture_info();
|
||||
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
|
||||
GLint logo_tex_size = (max_tex_size < 2048) ? max_tex_size : 2048;
|
||||
for (int i = 0; i < (unsigned int)btCount; ++i) {
|
||||
for (int j = 0; j < cali_texture_info.parts.size(); j++) {
|
||||
std::string filename = resources_dir() + "/images/" + cali_texture_info.parts[j].filename;
|
||||
if (boost::filesystem::exists(filename)) {
|
||||
PartPlateList::cali_texture_info.parts[j].texture = new GLTexture();
|
||||
if (!PartPlateList::cali_texture_info.parts[j].texture->load_from_svg_file(filename, true, true, true, logo_tex_size)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load cali texture from %1% failed!") % filename;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load cali texture from %1% failed!") % filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool PartPlateList::load_next_cali_texture()
|
||||
{
|
||||
if (PartPlateList::is_load_cali_texture)
|
||||
return false;
|
||||
if (m_next_cali_texture == 0)
|
||||
init_cali_texture_info();
|
||||
if (load_next_part_texture(&cali_texture_info, 1, m_next_cali_texture, true))
|
||||
return true;
|
||||
PartPlateList::is_load_cali_texture = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void PartPlateList::on_extruder_count_changed(int extruder_count)
|
||||
|
||||
Reference in New Issue
Block a user