Changeset 56183 in webkit


Ignore:
Timestamp:
Mar 18, 2010 1:07:13 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-18 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.

Add an overlay QGraphicsTextItem to QtLauncher so we can display FPS info
on the launcher and not on the terminal anymore.

[Qt] QtLauncher's FPS info should be displayed on an overlay text item
https://bugs.webkit.org/show_bug.cgi?id=36244

  • QtLauncher/webview.cpp: (WebViewGraphicsBased::WebViewGraphicsBased): (WebViewGraphicsBased::setFrameRateMeasurementEnabled): (WebViewGraphicsBased::updateFrameRate):
  • QtLauncher/webview.h:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56181 r56183  
     12010-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
    1172010-03-18  Adam Barth  <abarth@webkit.org>
    218
  • trunk/WebKitTools/QtLauncher/webview.cpp

    r55979 r56183  
    4343    , m_measureFps(false)
    4444    , m_resizesToContents(false)
     45    , m_fpsTextItem(0)
    4546{
    4647    setScene(new QGraphicsScene(this));
     
    7879    m_updateTimer->setInterval(1000);
    7980    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);
    8085}
    8186
     
    100105    QRectF rect(QPoint(0, 0), event->size());
    101106    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);
    102110}
    103111
     
    108116        m_lastConsultTime = m_startTime = QTime::currentTime();
    109117        m_updateTimer->start();
    110     } else
     118        m_fpsTextItem->setVisible(true);
     119    } else {
    111120        m_updateTimer->stop();
     121        m_fpsTextItem->setVisible(false);
     122    }
    112123}
    113124
     
    122133    int current = interval ? m_numPaintsSinceLastMeasure * 1000 / interval : 0;
    123134
    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);
    125139
    126140    m_lastConsultTime = now;
  • trunk/WebKitTools/QtLauncher/webview.h

    r56179 r56183  
    6565
    6666
     67class GraphicsTextItem : public QGraphicsTextItem {
     68    Q_OBJECT
     69
     70public:
     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
    6782class WebViewGraphicsBased : public QGraphicsView {
    6883    Q_OBJECT
     
    7792
    7893    void setFrameRateMeasurementEnabled(bool enabled);
    79     bool frameRateMeasurementEnabled() { return m_measureFps; } 
     94    bool frameRateMeasurementEnabled() { return m_measureFps; }
    8095
    8196    virtual void paintEvent(QPaintEvent* event);
    82    
     97
    8398    void setResizesToContents(bool b);
    8499
     
    119134    qreal m_yRotation;
    120135    bool m_resizesToContents;
     136    GraphicsTextItem* m_fpsTextItem;
    121137};
    122138
Note: See TracChangeset for help on using the changeset viewer.