Changeset 56183 in webkit
- Timestamp:
- Mar 18, 2010 1:07:13 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r56181 r56183 1 2010-03-18 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 Add an overlay QGraphicsTextItem to QtLauncher so we can display FPS info 6 on the launcher and not on the terminal anymore. 7 8 [Qt] QtLauncher's FPS info should be displayed on an overlay text item 9 https://bugs.webkit.org/show_bug.cgi?id=36244 10 11 * QtLauncher/webview.cpp: 12 (WebViewGraphicsBased::WebViewGraphicsBased): 13 (WebViewGraphicsBased::setFrameRateMeasurementEnabled): 14 (WebViewGraphicsBased::updateFrameRate): 15 * QtLauncher/webview.h: 16 1 17 2010-03-18 Adam Barth <abarth@webkit.org> 2 18 -
trunk/WebKitTools/QtLauncher/webview.cpp
r55979 r56183 43 43 , m_measureFps(false) 44 44 , m_resizesToContents(false) 45 , m_fpsTextItem(0) 45 46 { 46 47 setScene(new QGraphicsScene(this)); … … 78 79 m_updateTimer->setInterval(1000); 79 80 connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateFrameRate())); 81 82 m_fpsTextItem = new GraphicsTextItem("[FPS] average: 0, current: 0", m_item); 83 m_fpsTextItem->setDefaultTextColor(QColor(Qt::red)); 84 m_fpsTextItem->setVisible(false); 80 85 } 81 86 … … 100 105 QRectF rect(QPoint(0, 0), event->size()); 101 106 m_item->setGeometry(rect); 107 108 m_fpsTextItem->setPos(m_item->size().width() - m_fpsTextItem->boundingRect().width() - 20, 109 m_item->size().height() - m_fpsTextItem->boundingRect().height() - 20); 102 110 } 103 111 … … 108 116 m_lastConsultTime = m_startTime = QTime::currentTime(); 109 117 m_updateTimer->start(); 110 } else 118 m_fpsTextItem->setVisible(true); 119 } else { 111 120 m_updateTimer->stop(); 121 m_fpsTextItem->setVisible(false); 122 } 112 123 } 113 124 … … 122 133 int current = interval ? m_numPaintsSinceLastMeasure * 1000 / interval : 0; 123 134 124 qDebug("[FPS] average: %d, current: %d", average, current); 135 QString fpsText; 136 QTextStream text(&fpsText); 137 text << "[FPS] average: " << average << ", current: " << current; 138 m_fpsTextItem->setPlainText(fpsText); 125 139 126 140 m_lastConsultTime = now; -
trunk/WebKitTools/QtLauncher/webview.h
r56179 r56183 65 65 66 66 67 class GraphicsTextItem : public QGraphicsTextItem { 68 Q_OBJECT 69 70 public: 71 GraphicsTextItem(const QString& text, QGraphicsItem* parent = 0) : QGraphicsTextItem(text, parent) {} 72 73 void paint(QPainter *painter, const QStyleOptionGraphicsItem *style, 74 QWidget *widget) 75 { 76 painter->fillRect(boundingRect(), QColor(0, 0, 0, 255)); 77 QGraphicsTextItem::paint(painter, style, widget); 78 } 79 }; 80 81 67 82 class WebViewGraphicsBased : public QGraphicsView { 68 83 Q_OBJECT … … 77 92 78 93 void setFrameRateMeasurementEnabled(bool enabled); 79 bool frameRateMeasurementEnabled() { return m_measureFps; } 94 bool frameRateMeasurementEnabled() { return m_measureFps; } 80 95 81 96 virtual void paintEvent(QPaintEvent* event); 82 97 83 98 void setResizesToContents(bool b); 84 99 … … 119 134 qreal m_yRotation; 120 135 bool m_resizesToContents; 136 GraphicsTextItem* m_fpsTextItem; 121 137 }; 122 138
Note: See TracChangeset
for help on using the changeset viewer.