Changeset 142524 in webkit


Ignore:
Timestamp:
Feb 11, 2013 3:07:43 PM (11 years ago)
Author:
Bruno de Oliveira Abinader
Message:

[texmap] Implement frames-per-second debug counter
https://bugs.webkit.org/show_bug.cgi?id=107942

Reviewed by Noam Rosenthal.

Adds FPS counter via WEBKIT_SHOW_FPS=<interval> environment variable,
where <interval> is the period in seconds (i.e. =1.5) between FPS
updates on screen. It is measured by counting
CoordinatedGraphicsScene::paintTo* calls and is painted using
drawRepaintCounter() after TextureMapperLayer has finished painting its
contents.

Visual debugging feature, no need for new tests.

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:

(WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene):
(WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext):
(WebCore::CoordinatedGraphicsScene::paintToGraphicsContext):
(WebCore::CoordinatedGraphicsScene::updateFPS):

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142522 r142524  
     12013-02-11  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
     2
     3        [texmap] Implement frames-per-second debug counter
     4        https://bugs.webkit.org/show_bug.cgi?id=107942
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Adds FPS counter via WEBKIT_SHOW_FPS=<interval> environment variable,
     9        where <interval> is the period in seconds (i.e. =1.5) between FPS
     10        updates on screen. It is measured by counting
     11        CoordinatedGraphicsScene::paintTo* calls and is painted using
     12        drawRepaintCounter() after TextureMapperLayer has finished painting its
     13        contents.
     14
     15        Visual debugging feature, no need for new tests.
     16
     17        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
     18        (WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene):
     19        (WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext):
     20        (WebCore::CoordinatedGraphicsScene::paintToGraphicsContext):
     21        (WebCore::CoordinatedGraphicsScene::updateFPS):
     22        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
     23
    1242013-02-11  Eric Seidel  <eric@webkit.org>
    225
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp

    r141543 r142524  
    3333#include <OpenGLShims.h>
    3434#include <wtf/Atomics.h>
     35#include <wtf/CurrentTime.h>
    3536#include <wtf/MainThread.h>
    3637
     
    7778    , m_backgroundColor(Color::white)
    7879    , m_setDrawsBackground(false)
     80    , m_isShowingFPS(false)
     81    , m_fpsInterval(0)
     82    , m_fpsTimestamp(0)
     83    , m_lastFPS(0)
     84    , m_frameCount(0)
    7985{
    8086    ASSERT(isMainThread());
     87
     88    String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
     89    bool ok = false;
     90    m_fpsInterval = showFPSEnvironment.toDouble(&ok);
     91    if (ok && m_fpsInterval) {
     92        m_isShowingFPS = true;
     93        m_fpsTimestamp = WTF::currentTime();
     94    }
    8195}
    8296
     
    125139
    126140    layer->paint();
     141    if (m_isShowingFPS)
     142        updateFPS(clipRect.location(), matrix);
    127143    m_textureMapper->endClip();
    128144    m_textureMapper->endPainting();
     
    172188    m_textureMapper->beginPainting();
    173189
     190    IntRect clipRect = graphicsContext.clipBounds();
    174191    if (m_setDrawsBackground)
    175         m_textureMapper->drawSolidColor(graphicsContext.clipBounds(), TransformationMatrix(), m_backgroundColor);
     192        m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_backgroundColor);
    176193
    177194    layer->paint();
     195    if (m_isShowingFPS)
     196        updateFPS(clipRect.location());
    178197    m_textureMapper->endPainting();
    179198    m_textureMapper->setGraphicsContext(0);
     
    694713}
    695714
     715void CoordinatedGraphicsScene::updateFPS(const FloatPoint& location, const TransformationMatrix& matrix)
     716{
     717    m_frameCount++;
     718    double delta = WTF::currentTime() - m_fpsTimestamp;
     719    if (delta >= m_fpsInterval) {
     720        m_lastFPS = int(m_frameCount / delta);
     721        m_frameCount = 0;
     722        m_fpsTimestamp += delta;
     723    }
     724
     725    // FIXME: drawRepaintCounter() should save a texture and re-use whenever possible.
     726    m_textureMapper->drawRepaintCounter(m_lastFPS, Color::black, location, matrix);
     727}
     728
    696729} // namespace WebCore
    697730
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h

    r142366 r142524  
    175175    void resetBackingStoreSizeToLayerSize(GraphicsLayer*);
    176176
     177    void updateFPS(const FloatPoint&, const TransformationMatrix& = TransformationMatrix());
     178
    177179    FloatSize m_contentsSize;
    178180    FloatRect m_visibleContentsRect;
     
    225227    CustomFilterProgramMap m_customFilterPrograms;
    226228#endif
     229
     230    bool m_isShowingFPS;
     231    double m_fpsInterval;
     232    double m_fpsTimestamp;
     233    int m_lastFPS;
     234    int m_frameCount;
    227235};
    228236
Note: See TracChangeset for help on using the changeset viewer.