optimize stroke drawing

This commit is contained in:
2018-12-07 00:45:14 +01:00
parent 4980105d51
commit bbdad5a857
7 changed files with 131 additions and 69 deletions

View File

@@ -603,10 +603,42 @@ void App::init_menu_about()
}
if (auto b = popup->find<NodeButtonCustom>("about-crash"))
{
b->on_click = [this](Node*) {
LOG("crashing");
App::I.crash_test();
};
}
if (auto b = popup->find<NodeButtonCustom>("about-perf"))
{
b->on_click = [this](Node*) {
LOG("perf");
auto start = std::chrono::high_resolution_clock::now();
Canvas::I->stroke_start({ 0, 0, 0 }, 0.9f, Canvas::I->m_current_brush);
for (int i = 0; i < 100; i++)
{
Canvas::I->stroke_update({ 100, 100, 0 }, 0.9f);
Canvas::I->stroke_update({ 200, 200, 0 }, 0.9f);
Canvas::I->stroke_update({ 200, 100, 0 }, 0.9f);
Canvas::I->stroke_update({ 100, 200, 0 }, 0.9f);
Canvas::I->stroke_update({ 300, 300, 0 }, 0.9f);
Canvas::I->stroke_update({ 200, 500, 0 }, 0.9f);
Canvas::I->stroke_update({ 500, 500, 0 }, 0.9f);
Canvas::I->stroke_update({ 400, 400, 0 }, 0.9f);
Canvas::I->stroke_update({ 0, 200, 0 }, 0.9f);
Canvas::I->stroke_update({ 200, 0, 0 }, 0.9f);
Canvas::I->stroke_draw();
}
Canvas::I->stroke_end();
auto diff = std::chrono::high_resolution_clock::now() - start;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(diff).count();
LOG("%lld ms", ms);
static char str[256];
sprintf(str, "Time %lld ms", ms);
App::I.message_box("Performance test", str);
};
}
};
}
}