TextureMapperFPSCounter.cpp [plain text]
#include "config.h"
#include "TextureMapperFPSCounter.h"
#include "TextureMapper.h"
#include <wtf/CurrentTime.h>
namespace WebCore {
TextureMapperFPSCounter::TextureMapperFPSCounter()
: m_isShowingFPS(false)
, m_fpsInterval(0)
, m_fpsTimestamp(0)
, m_lastFPS(0)
, m_frameCount(0)
{
String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
bool ok = false;
m_fpsInterval = showFPSEnvironment.toDouble(&ok);
if (ok && m_fpsInterval) {
m_isShowingFPS = true;
m_fpsTimestamp = monotonicallyIncreasingTime();
}
}
void TextureMapperFPSCounter::updateFPSAndDisplay(TextureMapper& textureMapper, const FloatPoint& location, const TransformationMatrix& matrix)
{
if (!m_isShowingFPS)
return;
m_frameCount++;
double delta = monotonicallyIncreasingTime() - m_fpsTimestamp;
if (delta >= m_fpsInterval) {
m_lastFPS = int(m_frameCount / delta);
m_frameCount = 0;
m_fpsTimestamp += delta;
}
textureMapper.drawNumber(m_lastFPS, Color::black, location, matrix);
}
}