[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
kenneth at webkit.org
kenneth at webkit.org
Fri Feb 26 22:14:54 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit bb8ec702e29306f464e374c99883cc0c2b4b39e0
Author: kenneth at webkit.org <kenneth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Feb 8 22:58:50 2010 +0000
[Qt] Backport No'am Rosenthal's frame rate measurement
Reviewed by Ariya Hidayat.
* QtLauncher/main.cpp:
(LauncherWindow::LauncherWindow):
(LauncherApplication::handleUserOptions):
* QtLauncher/webview.cpp:
(WebViewGraphicsBased::WebViewGraphicsBased):
(WebViewGraphicsBased::enableFrameRateMeasurement):
(WebViewGraphicsBased::updateFrameRate):
(WebViewGraphicsBased::paintEvent):
* QtLauncher/webview.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 6bdcbab..224b567 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,21 @@
2010-02-08 Kenneth Rohde Christiansen <kenneth at webkit.org>
+ Reviewed by Ariya Hidayat.
+
+ [Qt] Backport No'am Rosenthal's frame rate measurement
+
+ * QtLauncher/main.cpp:
+ (LauncherWindow::LauncherWindow):
+ (LauncherApplication::handleUserOptions):
+ * QtLauncher/webview.cpp:
+ (WebViewGraphicsBased::WebViewGraphicsBased):
+ (WebViewGraphicsBased::enableFrameRateMeasurement):
+ (WebViewGraphicsBased::updateFrameRate):
+ (WebViewGraphicsBased::paintEvent):
+ * QtLauncher/webview.h:
+
+2010-02-08 Kenneth Rohde Christiansen <kenneth at webkit.org>
+
Reviewed by Tor Arne Vestbø.
[Qt] Make overridePreference complain when it does not
diff --git a/WebKitTools/QtLauncher/main.cpp b/WebKitTools/QtLauncher/main.cpp
index b38efad..c8e6a66 100644
--- a/WebKitTools/QtLauncher/main.cpp
+++ b/WebKitTools/QtLauncher/main.cpp
@@ -74,6 +74,7 @@ void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
static bool gUseGraphicsView = false;
static bool gUseCompositing = false;
static bool gCacheWebView = false;
+static bool gShowFrameRate = false;
static QGraphicsView::ViewportUpdateMode gViewportUpdateMode = QGraphicsView::MinimalViewportUpdate;
@@ -156,6 +157,8 @@ LauncherWindow::LauncherWindow(QString url)
view->setPage(page());
view->setViewportUpdateMode(gViewportUpdateMode);
view->setItemCacheMode(gCacheWebView ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache);
+ if (gShowFrameRate)
+ view->enableFrameRateMeasurement();
page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, gUseCompositing);
m_view = view;
}
@@ -620,6 +623,7 @@ void LauncherApplication::handleUserOptions()
<< "[-compositing]"
<< QString("[-viewport-update-mode %1]").arg(formatKeys(updateModes)).toLatin1().data()
<< "[-cache-webview]"
+ << "[-show-fps]"
<< "[-r list]"
<< "URLs";
appQuit(0);
@@ -633,6 +637,11 @@ void LauncherApplication::handleUserOptions()
gUseCompositing = true;
}
+ if (args.contains("-show-fps")) {
+ requiresGraphicsView("-show-fps");
+ gShowFrameRate = true;
+ }
+
if (args.contains("-cache-webview")) {
requiresGraphicsView("-cache-webview");
gCacheWebView = true;
diff --git a/WebKitTools/QtLauncher/webview.cpp b/WebKitTools/QtLauncher/webview.cpp
index 5201165..3af5209 100644
--- a/WebKitTools/QtLauncher/webview.cpp
+++ b/WebKitTools/QtLauncher/webview.cpp
@@ -38,6 +38,9 @@
WebViewGraphicsBased::WebViewGraphicsBased(QWidget* parent)
: QGraphicsView(parent)
, m_item(new GraphicsWebView)
+ , m_numPaintsTotal(0)
+ , m_numPaintsSinceLastMeasure(0)
+ , m_measureFps(false)
{
setScene(new QGraphicsScene);
scene()->addItem(m_item);
@@ -54,6 +57,41 @@ void WebViewGraphicsBased::resizeEvent(QResizeEvent* event)
m_item->setGeometry(rect);
}
+void WebViewGraphicsBased::enableFrameRateMeasurement()
+{
+ m_measureFps = true;
+ m_lastConsultTime = m_startTime = QTime::currentTime();
+ QTimer* updateTimer = new QTimer(this);
+ updateTimer->setInterval(1000);
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateFrameRate()));
+ updateTimer->start();
+}
+
+void WebViewGraphicsBased::updateFrameRate()
+{
+ QTime now = QTime::currentTime();
+
+ int interval = m_lastConsultTime.msecsTo(now);
+ int total = m_startTime.msecsTo(now);
+
+ int average = total ? m_numPaintsTotal * 1000 / total : 0;
+ int current = interval ? m_numPaintsSinceLastMeasure * 1000 / interval : 0;
+
+ qDebug("[FPS] average: %d, current: %d", average, current);
+
+ m_lastConsultTime = now;
+ m_numPaintsSinceLastMeasure = 0;
+}
+
+void WebViewGraphicsBased::paintEvent(QPaintEvent* event)
+{
+ QGraphicsView::paintEvent(event);
+ if (!m_measureFps)
+ return;
+ m_numPaintsSinceLastMeasure++;
+ m_numPaintsTotal++;
+}
+
static QMenu* createContextMenu(QWebPage* page, QPoint position)
{
QMenu* menu = page->createStandardContextMenu();
diff --git a/WebKitTools/QtLauncher/webview.h b/WebKitTools/QtLauncher/webview.h
index 6d26664..83bd801 100644
--- a/WebKitTools/QtLauncher/webview.h
+++ b/WebKitTools/QtLauncher/webview.h
@@ -38,6 +38,7 @@
#include <qgraphicswebview.h>
#include <QGraphicsView>
#include <QGraphicsWidget>
+#include <QTime>
class WebViewTraditional : public QWebView {
Q_OBJECT
@@ -72,8 +73,19 @@ public:
void setPage(QWebPage* page) { m_item->setPage(page); }
void setItemCacheMode(QGraphicsItem::CacheMode mode) { m_item->setCacheMode(mode); }
+ void enableFrameRateMeasurement();
+ virtual void paintEvent(QPaintEvent* event);
+
+public slots:
+ void updateFrameRate();
+
private:
GraphicsWebView* m_item;
+ int m_numPaintsTotal;
+ int m_numPaintsSinceLastMeasure;
+ QTime m_startTime;
+ QTime m_lastConsultTime;
+ bool m_measureFps;
};
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list