Title: [122275] trunk/Source
Revision
122275
Author
[email protected]
Date
2012-07-10 16:06:16 -0700 (Tue, 10 Jul 2012)

Log Message

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

Patch by Helder Correia <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122274 => 122275)


--- trunk/Source/WebCore/ChangeLog	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebCore/ChangeLog	2012-07-10 23:06:16 UTC (rev 122275)
@@ -1,3 +1,38 @@
+2012-07-10  Helder Correia  <[email protected]>
+
+        [Qt] Repaint counter for accelerated compositing
+        https://bugs.webkit.org/show_bug.cgi?id=90116
+
+        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().
+
+        * platform/graphics/texmap/TextureMapper.h:
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore):
+        (WebCore::TextureMapperGL::drawRepaintCounter):
+        * platform/graphics/texmap/TextureMapperGL.h:
+        * platform/graphics/texmap/TextureMapperImageBuffer.h:
+
 2012-07-09  Dana Jansens  <[email protected]>
 
         [chromium] Replace use of ManagedTexture with CCScopedTexture for impl thread and remove implTextureManager from LayerRendererChromium

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h (122274 => 122275)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h	2012-07-10 23:06:16 UTC (rev 122275)
@@ -122,6 +122,7 @@
     };
 
     virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
+    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
     virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, const BitmapTexture* maskTexture = 0, unsigned exposedEdges = AllEdges) = 0;
 
     // makes a surface the target for the following drawTexture calls.

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (122274 => 122275)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-07-10 23:06:16 UTC (rev 122275)
@@ -24,6 +24,7 @@
 #include "GraphicsContext.h"
 #include "GraphicsContext3D.h"
 #include "Image.h"
+#include "NotImplemented.h"
 #include "TextureMapperShaderManager.h"
 #include "Timer.h"
 #include <wtf/HashMap.h>
@@ -360,6 +361,38 @@
     drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha());
 }
 
+void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
+{
+#if PLATFORM(QT)
+    QString counterString = QString::number(value);
+
+    QFont font(QString::fromLatin1("Monospace"), pointSize, QFont::Bold);
+    font.setStyleHint(QFont::TypeWriter);
+
+    QFontMetrics fontMetrics(font);
+    int width = fontMetrics.width(counterString) + 4;
+    int height = fontMetrics.height();
+
+    IntSize size(width, height);
+    IntRect sourceRect(IntPoint::zero(), size);
+    IntRect targetRect(roundedIntPoint(targetPoint), size);
+
+    QImage image(size, QImage::Format_ARGB32_Premultiplied);
+    QPainter painter(&image);
+    painter.fillRect(sourceRect, Qt::blue); // Since we won't swap R+B for speed, this will paint red.
+    painter.setFont(font);
+    painter.setPen(Qt::white);
+    painter.drawText(2, height * 0.85, counterString);
+
+    RefPtr<BitmapTexture> texture = acquireTextureFromPool(size);
+    const uchar* bits = image.bits();
+    texture->updateContents(bits, sourceRect, IntPoint::zero(), image.bytesPerLine());
+    drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
+#else
+    notImplemented();
+#endif
+}
+
 void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* mask, unsigned exposedEdges)
 {
     if (!texture.isValid())

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (122274 => 122275)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2012-07-10 23:06:16 UTC (rev 122275)
@@ -50,6 +50,7 @@
 
     // TextureMapper implementation
     virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
+    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
     virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
     virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h (122274 => 122275)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h	2012-07-10 23:06:16 UTC (rev 122275)
@@ -52,6 +52,7 @@
 
     // TextureMapper implementation
     virtual void drawBorder(const Color& color, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE { };
+    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE { };
     virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
     virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
     virtual void bindSurface(BitmapTexture* surface) OVERRIDE { m_currentSurface = surface;}

Modified: trunk/Source/WebKit2/ChangeLog (122274 => 122275)


--- trunk/Source/WebKit2/ChangeLog	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-10 23:06:16 UTC (rev 122275)
@@ -1,3 +1,42 @@
+2012-07-10  Helder Correia  <[email protected]>
+
+        [Qt] Repaint counter for accelerated compositing
+        https://bugs.webkit.org/show_bug.cgi?id=90116
+
+        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().
+
+        * 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):
+
 2012-07-10  Sudarsana Nagineni  <[email protected]>
 
         [WK2] Add Vibration API support for WebKit2

Modified: trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.cpp (122274 => 122275)


--- trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.cpp	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.cpp	2012-07-10 23:06:16 UTC (rev 122275)
@@ -80,6 +80,7 @@
 {
     HashMap<int, LayerBackingStoreTile>::iterator it = m_tiles.find(id);
     ASSERT(it != m_tiles.end());
+    it->second.incrementRepaintCount();
     it->second.setBackBuffer(targetRect, sourceRect, backBuffer, offset);
 }
 
@@ -95,6 +96,14 @@
     return PassRefPtr<BitmapTexture>();
 }
 
+static bool shouldShowTileDebugVisuals()
+{
+#if PLATFORM(QT)
+    return (qgetenv("QT_WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS") == "1");
+#endif
+    return false;
+}
+
 void LayerBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 {
     Vector<TextureMapperTile*> tilesToPaint;
@@ -126,8 +135,15 @@
     // passing. For now we just "estimate" since LayerBackingStore doesn't keep information about
     // the total tiled surface rect at the moment.
     unsigned edgesExposed = m_tiles.size() > 1 ? TextureMapper::NoEdges : TextureMapper::AllEdges;
-    for (size_t i = 0; i < tilesToPaint.size(); ++i)
-        tilesToPaint[i]->paint(textureMapper, transform, opacity, mask, edgesExposed);
+    for (size_t i = 0; i < tilesToPaint.size(); ++i) {
+        TextureMapperTile* tile = tilesToPaint[i];
+        tile->paint(textureMapper, transform, opacity, mask, edgesExposed);
+        static bool shouldDebug = shouldShowTileDebugVisuals();
+        if (!shouldDebug)
+            continue;
+        textureMapper->drawBorder(QColor(Qt::red), 2, tile->rect(), transform);
+        textureMapper->drawRepaintCounter(static_cast<LayerBackingStoreTile*>(tile)->repaintCount(), 8, tilesToPaint[i]->rect().location(), transform);
+    }
 }
 
 void LayerBackingStore::commitTileOperations(TextureMapper* textureMapper)

Modified: trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.h (122274 => 122275)


--- trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.h	2012-07-10 22:53:58 UTC (rev 122274)
+++ trunk/Source/WebKit2/UIProcess/texmap/LayerBackingStore.h	2012-07-10 23:06:16 UTC (rev 122275)
@@ -35,10 +35,13 @@
     LayerBackingStoreTile(float scale = 1)
         : TextureMapperTile(WebCore::FloatRect())
         , m_scale(scale)
+        , m_repaintCount(0)
     {
     }
 
     inline float scale() const { return m_scale; }
+    inline void incrementRepaintCount() { ++m_repaintCount; }
+    inline int repaintCount() const { return m_repaintCount; }
     void swapBuffers(WebCore::TextureMapper*);
     void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableSurface> buffer, const WebCore::IntPoint&);
 
@@ -48,6 +51,7 @@
     WebCore::IntRect m_targetRect;
     WebCore::IntPoint m_surfaceOffset;
     float m_scale;
+    int m_repaintCount;
 };
 
 class LayerBackingStore : public WebCore::TextureMapperBackingStore {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to