void setMark(const LString &mark) { m_bReady = true; m_mark = mark; m_nCbufLen = m_mark.length(); m_cbuf.set_capacity(m_nCbufLen); m_nMatch = 0; }
void ShowFrameDurationPlot() { Vec2i windowSize = mainApp->getWindow()->getSize(); size_t maxSamples = size_t(windowSize.x); if(maxSamples != frameDurationPlotValues.capacity()) { frameDurationPlotValues.set_capacity(maxSamples); } if(maxSamples != frameDurationPlotVertices.size()) { frameDurationPlotVertices.resize(maxSamples); } GRenderer->ResetTexture(0); frameDurationPlotValues.push_front(toMs(g_platformTime.lastFrameDuration())); float avg = std::accumulate(frameDurationPlotValues.begin(), frameDurationPlotValues.end(), 0.f) / frameDurationPlotValues.size(); float worst = *std::max_element(frameDurationPlotValues.begin(), frameDurationPlotValues.end()); const float OFFSET_Y = 80.f; const float SCALE_Y = 4.0f; for(size_t i = 0; i < frameDurationPlotValues.size(); ++i) { float time = frameDurationPlotValues[i]; frameDurationPlotVertices[i].color = Color::white.toRGB(); frameDurationPlotVertices[i].p.x = i; frameDurationPlotVertices[i].p.y = OFFSET_Y + (time * SCALE_Y); frameDurationPlotVertices[i].p.z = 1.0f; frameDurationPlotVertices[i].w = 1.0f; } EERIEDRAWPRIM(Renderer::LineStrip, &frameDurationPlotVertices[0], frameDurationPlotValues.size()); Color avgColor = Color::blue * 0.5f + Color::white * 0.5f; float avgPos = OFFSET_Y + (avg * SCALE_Y); drawLine(Vec2f(0, avgPos), Vec2f(windowSize.x, avgPos), 1.0f, Color::blue); Color worstColor = Color::red * 0.5f + Color::white * 0.5f; float worstPos = OFFSET_Y + (worst * SCALE_Y); drawLine(Vec2f(0, worstPos), Vec2f(windowSize.x, worstPos), 1.0f, Color::red); Font * font = hFontDebug; float lineOffset = font->getLineHeight() + 2; std::string labels[3] = { "Average: ", "Worst: ", "Current: " }; Color colors[3] = { avgColor, worstColor, Color::white }; float values[3] = { avg, worst, frameDurationPlotValues[0] }; std::string texts[3]; float widths[3]; static float labelWidth = 0.f; static float valueWidth = 0.f; for(size_t i = 0; i < 3; i++) { // Format value std::ostringstream oss; oss << std::fixed << std::setprecision(2) << values[i] << " ms ("<< 1.f / (values[i] * 0.001f) << " FPS)"; texts[i] = oss.str(); // Calculate widths (could be done more efficiently for monospace fonts...) labelWidth = std::max(labelWidth, float(font->getTextSize(labels[i]).width())); widths[i] = font->getTextSize(texts[i]).width(); valueWidth = std::max(valueWidth, widths[i]); } float x = 10; float y = 10; float xend = x + labelWidth + 10 + valueWidth; for(size_t i = 0; i < 3; i++) { font->draw(Vec2i(x, y), labels[i], Color::gray(0.8f)); font->draw(Vec2i(xend - widths[i], y), texts[i], colors[i]); y += lineOffset; } }