Skip to content

Commit

Permalink
Log time for loading fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jony01 committed Oct 13, 2022
1 parent ce71144 commit fe90a88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <wx/fontenum.h>

#include <GL/glew.h>
#include <chrono> // measure enumeration of fonts

// uncomment for easier debug
//#define ALLOW_DEBUG_MODE
Expand Down Expand Up @@ -1294,7 +1295,18 @@ void GLGizmoEmboss::init_face_names() {
wxFontEncoding encoding = wxFontEncoding::wxFONTENCODING_SYSTEM;
MyFontEnumerator fontEnumerator(encoding);
bool fixed_width_only = false;
fontEnumerator.EnumerateFacenames(encoding, fixed_width_only);

{ using namespace std::chrono;
steady_clock::time_point enumerate_start = steady_clock::now();
ScopeGuard sg([&enumerate_start]() {
steady_clock::time_point enumerate_end = steady_clock::now();
long long enumerate_duration = duration_cast<milliseconds>(enumerate_end - enumerate_start).count();
BOOST_LOG_TRIVIAL(info) << "OS Fonts Enumeration " << enumerate_duration << "ms";
});

fontEnumerator.EnumerateFacenames(encoding, fixed_width_only);
}// End Time measures

m_face_names.encoding = encoding;
std::vector<wxString> &names = fontEnumerator.m_facenames;
std::sort(names.begin(), names.end());
Expand Down
15 changes: 15 additions & 0 deletions src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "wx/fontenum.h"

#include <boost/log/trivial.hpp>

using namespace Slic3r;
using namespace Slic3r::GUI;

Expand Down Expand Up @@ -96,6 +98,11 @@ void CreateFontImageJob::process(Ctl &ctl)
r->encode(encoder);
}

// ability to request new frame after finish rendering
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"

void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &)
{
if (m_input.count_opened_font_files)
Expand All @@ -118,4 +125,12 @@ void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &)
// bind default texture
GLuint no_texture_id = 0;
glsafe(::glBindTexture(target, no_texture_id));

// show rendered texture
//wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0);

BOOST_LOG_TRIVIAL(info)
<< "Generate Preview font('" << m_input.font_name << "' id:" << m_input.index << ") "
<< "with text: '" << m_input.text << "' "
<< "texture_size " << m_input.size.x() << " x " << m_input.size.y();
}
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Jobs/PlaterWorker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PlaterWorker: public Worker {
<< std::fixed // do not use scientific notations
<< "Job '" << typeid(*m_job).name() << "' "
<< "spend " << m_process_duration + finalize_duration << "ms "
<< "(process " << m_process_duration << "ms + finalize " << finalize_duration << "ms)" << std::endl;
<< "(process " << m_process_duration << "ms + finalize " << finalize_duration << "ms)";

if (eptr) try {
std::rethrow_exception(eptr);
Expand Down

0 comments on commit fe90a88

Please sign in to comment.