Changeset 122275 in webkit


Ignore:
Timestamp:
Jul 10, 2012 4:06:16 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] Repaint counter for accelerated compositing
https://bugs.webkit.org/show_bug.cgi?id=90116

Patch by Helder Correia <Helder Correia> on 2012-07-10
Reviewed by Noam Rosenthal.

No new tests, just introducing a debug feature.

For this feature to be enabled, the environment variable
QT_WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS must be set to 1. Once enabled,
both repaint counters and tile borders will be painted.

Important notes:

  • Only WebKit2 is targetted for now.
  • There is no integration with Preferences. That aproach was

taken initially but revealed complex and overkill for such a
debugging-only functionality. Thus, to disable it simply restart with
the environment variable unset or set to some other value.

A Qt-specific drawRepaintCounter() function was added to
TextureMapperGL. A QImage is used as scratch buffer to paint borders and
counters. It is then uploaded to a BitmapTexture acquired from the pool
and finally draw by TextureMapper. The actual compositing happens inside
LayerBackingStore::paintToTextureMapper(). Each LayerBackingStoreTile
now has a repaint counter which gets incremented in
LayerBackingStore::updateTile().

Source/WebCore:

  • platform/graphics/texmap/TextureMapper.h:
  • platform/graphics/texmap/TextureMapperGL.cpp:

(WebCore):
(WebCore::TextureMapperGL::drawRepaintCounter):

  • platform/graphics/texmap/TextureMapperGL.h:
  • platform/graphics/texmap/TextureMapperImageBuffer.h:

Source/WebKit2:

  • UIProcess/texmap/LayerBackingStore.cpp:

(WebKit::LayerBackingStore::updateTile):
(WebKit):
(WebKit::shouldShowTileDebugVisuals):
(WebKit::LayerBackingStore::paintToTextureMapper):

  • UIProcess/texmap/LayerBackingStore.h:

(WebKit::LayerBackingStoreTile::LayerBackingStoreTile):
(LayerBackingStoreTile):
(WebKit::LayerBackingStoreTile::incrementRepaintCount):
(WebKit::LayerBackingStoreTile::repaintCount):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122272 r122275  
     12012-07-10  Helder Correia  <helder.correia@nokia.com>
     2
     3        [Qt] Repaint counter for accelerated compositing
     4        https://bugs.webkit.org/show_bug.cgi?id=90116
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        No new tests, just introducing a debug feature.
     9
     10        For this feature to be enabled, the environment variable
     11        QT_WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS must be set to 1. Once enabled,
     12        both repaint counters and tile borders will be painted.
     13
     14        Important notes:
     15        - Only WebKit2 is targetted for now.
     16        - There is no integration with Preferences. That aproach was
     17        taken initially but revealed complex and overkill for such a
     18        debugging-only functionality. Thus, to disable it simply restart with
     19        the environment variable unset or set to some other value.
     20
     21        A Qt-specific drawRepaintCounter() function was added to
     22        TextureMapperGL. A QImage is used as scratch buffer to paint borders and
     23        counters. It is then uploaded to a BitmapTexture acquired from the pool
     24        and finally draw by TextureMapper. The actual compositing happens inside
     25        LayerBackingStore::paintToTextureMapper(). Each LayerBackingStoreTile
     26        now has a repaint counter which gets incremented in
     27        LayerBackingStore::updateTile().
     28
     29        * platform/graphics/texmap/TextureMapper.h:
     30        * platform/graphics/texmap/TextureMapperGL.cpp:
     31        (WebCore):
     32        (WebCore::TextureMapperGL::drawRepaintCounter):
     33        * platform/graphics/texmap/TextureMapperGL.h:
     34        * platform/graphics/texmap/TextureMapperImageBuffer.h:
     35
    1362012-07-09  Dana Jansens  <danakj@chromium.org>
    237
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h

    r121729 r122275  
    123123
    124124    virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
     125    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
    125126    virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, const BitmapTexture* maskTexture = 0, unsigned exposedEdges = AllEdges) = 0;
    126127
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

    r121793 r122275  
    2525#include "GraphicsContext3D.h"
    2626#include "Image.h"
     27#include "NotImplemented.h"
    2728#include "TextureMapperShaderManager.h"
    2829#include "Timer.h"
     
    359360
    360361    drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha());
     362}
     363
     364void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
     365{
     366#if PLATFORM(QT)
     367    QString counterString = QString::number(value);
     368
     369    QFont font(QString::fromLatin1("Monospace"), pointSize, QFont::Bold);
     370    font.setStyleHint(QFont::TypeWriter);
     371
     372    QFontMetrics fontMetrics(font);
     373    int width = fontMetrics.width(counterString) + 4;
     374    int height = fontMetrics.height();
     375
     376    IntSize size(width, height);
     377    IntRect sourceRect(IntPoint::zero(), size);
     378    IntRect targetRect(roundedIntPoint(targetPoint), size);
     379
     380    QImage image(size, QImage::Format_ARGB32_Premultiplied);
     381    QPainter painter(&image);
     382    painter.fillRect(sourceRect, Qt::blue); // Since we won't swap R+B for speed, this will paint red.
     383    painter.setFont(font);
     384    painter.setPen(Qt::white);
     385    painter.drawText(2, height * 0.85, counterString);
     386
     387    RefPtr<BitmapTexture> texture = acquireTextureFromPool(size);
     388    const uchar* bits = image.bits();
     389    texture->updateContents(bits, sourceRect, IntPoint::zero(), image.bytesPerLine());
     390    drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
     391#else
     392    notImplemented();
     393#endif
    361394}
    362395
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h

    r121729 r122275  
    5151    // TextureMapper implementation
    5252    virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
     53    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
    5354    virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
    5455    virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h

    r121729 r122275  
    5353    // TextureMapper implementation
    5454    virtual void drawBorder(const Color& color, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE { };
     55    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE { };
    5556    virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
    5657    virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
  • trunk/Source/WebKit2/ChangeLog

    r122270 r122275  
     12012-07-10  Helder Correia  <helder.correia@nokia.com>
     2
     3        [Qt] Repaint counter for accelerated compositing
     4        https://bugs.webkit.org/show_bug.cgi?id=90116
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        No new tests, just introducing a debug feature.
     9
     10        For this feature to be enabled, the environment variable
     11        QT_WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS must be set to 1. Once enabled,
     12        both repaint counters and tile borders will be painted.
     13
     14        Important notes:
     15        - Only WebKit2 is targetted for now.
     16        - There is no integration with Preferences. That aproach was
     17        taken initially but revealed complex and overkill for such a
     18        debugging-only functionality. Thus, to disable it simply restart with
     19        the environment variable unset or set to some other value.
     20
     21        A Qt-specific drawRepaintCounter() function was added to
     22        TextureMapperGL. A QImage is used as scratch buffer to paint borders and
     23        counters. It is then uploaded to a BitmapTexture acquired from the pool
     24        and finally draw by TextureMapper. The actual compositing happens inside
     25        LayerBackingStore::paintToTextureMapper(). Each LayerBackingStoreTile
     26        now has a repaint counter which gets incremented in
     27        LayerBackingStore::updateTile().
     28
     29        * UIProcess/texmap/LayerBackingStore.cpp:
     30        (WebKit::LayerBackingStore::updateTile):
     31        (WebKit):
     32        (WebKit::shouldShowTileDebugVisuals):
     33        (WebKit::LayerBackingStore::paintToTextureMapper):
     34        * UIProcess/texmap/LayerBackingStore.h:
     35        (WebKit::LayerBackingStoreTile::LayerBackingStoreTile):
     36        (LayerBackingStoreTile):
     37        (WebKit::LayerBackingStoreTile::incrementRepaintCount):
     38        (WebKit::LayerBackingStoreTile::repaintCount):
     39
    1402012-07-10  Sudarsana Nagineni  <sudarsana.nagineni@linux.intel.com>
    241
  • trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.cpp

    r121729 r122275  
    8181    HashMap<int, LayerBackingStoreTile>::iterator it = m_tiles.find(id);
    8282    ASSERT(it != m_tiles.end());
     83    it->second.incrementRepaintCount();
    8384    it->second.setBackBuffer(targetRect, sourceRect, backBuffer, offset);
    8485}
     
    9495
    9596    return PassRefPtr<BitmapTexture>();
     97}
     98
     99static bool shouldShowTileDebugVisuals()
     100{
     101#if PLATFORM(QT)
     102    return (qgetenv("QT_WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS") == "1");
     103#endif
     104    return false;
    96105}
    97106
     
    127136    // the total tiled surface rect at the moment.
    128137    unsigned edgesExposed = m_tiles.size() > 1 ? TextureMapper::NoEdges : TextureMapper::AllEdges;
    129     for (size_t i = 0; i < tilesToPaint.size(); ++i)
    130         tilesToPaint[i]->paint(textureMapper, transform, opacity, mask, edgesExposed);
     138    for (size_t i = 0; i < tilesToPaint.size(); ++i) {
     139        TextureMapperTile* tile = tilesToPaint[i];
     140        tile->paint(textureMapper, transform, opacity, mask, edgesExposed);
     141        static bool shouldDebug = shouldShowTileDebugVisuals();
     142        if (!shouldDebug)
     143            continue;
     144        textureMapper->drawBorder(QColor(Qt::red), 2, tile->rect(), transform);
     145        textureMapper->drawRepaintCounter(static_cast<LayerBackingStoreTile*>(tile)->repaintCount(), 8, tilesToPaint[i]->rect().location(), transform);
     146    }
    131147}
    132148
  • trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.h

    r121151 r122275  
    3636        : TextureMapperTile(WebCore::FloatRect())
    3737        , m_scale(scale)
     38        , m_repaintCount(0)
    3839    {
    3940    }
    4041
    4142    inline float scale() const { return m_scale; }
     43    inline void incrementRepaintCount() { ++m_repaintCount; }
     44    inline int repaintCount() const { return m_repaintCount; }
    4245    void swapBuffers(WebCore::TextureMapper*);
    4346    void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableSurface> buffer, const WebCore::IntPoint&);
     
    4952    WebCore::IntPoint m_surfaceOffset;
    5053    float m_scale;
     54    int m_repaintCount;
    5155};
    5256
Note: See TracChangeset for help on using the changeset viewer.