Title: [118580] trunk/Source/WebCore
Revision
118580
Author
[email protected]
Date
2012-05-25 15:49:35 -0700 (Fri, 25 May 2012)

Log Message

[chromium] Add setting for painting debug info onto tiles
https://bugs.webkit.org/show_bug.cgi?id=75763

Reviewed by James Robinson.

Add a compile-time CCSetting to paint debug information onto tiles. This
can help to understand paint counts and layer indices. This setting is
off by default.

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerPainter::create):
(WebCore::ContentLayerPainter::paint):
(WebCore::ContentLayerPainter::ContentLayerPainter):
(WebCore::ContentLayerChromium::createTextureUpdater):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::UpdatableTile::UpdatableTile):
(WebCore::UpdatableTile::setUpdateFrame):
(WebCore::UpdatableTile::incrementPaintCount):
(WebCore::UpdatableTile::updateFrame):
(WebCore::UpdatableTile::paintCount):
(WebCore::TiledLayerChromium::TiledLayerChromium):
(WebCore::TiledLayerChromium::prepareToUpdateTiles):
(WebCore::TiledLayerChromium::paintDebugTileInfo):
* platform/graphics/chromium/TiledLayerChromium.h:
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCSettings::CCSettings):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118579 => 118580)


--- trunk/Source/WebCore/ChangeLog	2012-05-25 22:45:57 UTC (rev 118579)
+++ trunk/Source/WebCore/ChangeLog	2012-05-25 22:49:35 UTC (rev 118580)
@@ -1,3 +1,32 @@
+2012-05-25  Adrienne Walker  <[email protected]>
+
+        [chromium] Add setting for painting debug info onto tiles
+        https://bugs.webkit.org/show_bug.cgi?id=75763
+
+        Reviewed by James Robinson.
+
+        Add a compile-time CCSetting to paint debug information onto tiles. This
+        can help to understand paint counts and layer indices. This setting is
+        off by default.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerPainter::create):
+        (WebCore::ContentLayerPainter::paint):
+        (WebCore::ContentLayerPainter::ContentLayerPainter):
+        (WebCore::ContentLayerChromium::createTextureUpdater):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::UpdatableTile::UpdatableTile):
+        (WebCore::UpdatableTile::setUpdateFrame):
+        (WebCore::UpdatableTile::incrementPaintCount):
+        (WebCore::UpdatableTile::updateFrame):
+        (WebCore::UpdatableTile::paintCount):
+        (WebCore::TiledLayerChromium::TiledLayerChromium):
+        (WebCore::TiledLayerChromium::prepareToUpdateTiles):
+        (WebCore::TiledLayerChromium::paintDebugTileInfo):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCSettings::CCSettings):
+
 2012-05-25  Ami Fischman  <[email protected]>
 
         [chromium] Default media controls should render only the currentTime-containing buffered range

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (118579 => 118580)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2012-05-25 22:45:57 UTC (rev 118579)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2012-05-25 22:49:35 UTC (rev 118580)
@@ -49,9 +49,9 @@
 class ContentLayerPainter : public LayerPainterChromium {
     WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
 public:
-    static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate)
+    static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate, TiledLayerChromium* layer)
     {
-        return adoptPtr(new ContentLayerPainter(delegate));
+        return adoptPtr(new ContentLayerPainter(delegate, layer));
     }
 
     virtual void paint(GraphicsContext& context, const IntRect& contentRect)
@@ -59,19 +59,27 @@
         double paintStart = currentTime();
         context.clearRect(contentRect);
         context.clip(contentRect);
-        m_delegate->paintContents(context, contentRect);
-        double paintEnd = currentTime();
-        double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
-        WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
-        WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
+        {
+            GraphicsContextStateSaver stateSaver(context, m_layer->layerTreeHost()->settings().debugShowTileInfo);
+
+            m_delegate->paintContents(context, contentRect);
+            double paintEnd = currentTime();
+            double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
+            WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
+            WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
+        }
+        if (m_layer->layerTreeHost()->settings().debugShowTileInfo)
+            m_layer->paintDebugTileInfo(context, contentRect);
     }
 private:
-    explicit ContentLayerPainter(ContentLayerDelegate* delegate)
+    explicit ContentLayerPainter(ContentLayerDelegate* delegate, TiledLayerChromium* layer)
         : m_delegate(delegate)
+        , m_layer(layer)
     {
     }
 
     ContentLayerDelegate* m_delegate;
+    TiledLayerChromium* m_layer;
 };
 
 PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(ContentLayerDelegate* delegate)
@@ -126,11 +134,11 @@
     if (m_textureUpdater)
         return;
     if (layerTreeHost()->settings().acceleratePainting)
-        m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate));
+        m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate, this));
     else if (layerTreeHost()->settings().perTilePainting)
-        m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMapSub);
+        m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate, this), layerTreeHost()->layerRendererCapabilities().usingMapSub);
     else
-        m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMapSub);
+        m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate, this), layerTreeHost()->layerRendererCapabilities().usingMapSub);
     m_textureUpdater->setOpaque(opaque());
 
     GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTextureFormat;

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (118579 => 118580)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2012-05-25 22:45:57 UTC (rev 118579)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2012-05-25 22:49:35 UTC (rev 118580)
@@ -29,10 +29,13 @@
 
 #include "TiledLayerChromium.h"
 
+#include "FontCache.h"
+#include "FontDescription.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
 #include "ManagedTexture.h"
 #include "Region.h"
+#include "TextRun.h"
 #include "TextStream.h"
 #include "TraceEvent.h"
 
@@ -73,11 +76,15 @@
     bool partialUpdate;
     bool updated;
     bool isInUseOnImpl;
+    int lastUpdateFrame;
+    int totalPaintCount;
 private:
     explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture)
         : partialUpdate(false)
         , updated(false)
         , isInUseOnImpl(false)
+        , lastUpdateFrame(0)
+        , totalPaintCount(0)
         , m_texture(texture)
     {
     }
@@ -409,6 +416,13 @@
                 return;
             }
 
+            if (tile->isDirty() && layerTreeHost()->settings().debugShowTileInfo) {
+                // Invalidate the entire tile so that text updates.
+                tile->dirtyRect = m_tiler->tileRect(tile);
+                tile->lastUpdateFrame = layerTreeHost()->frameNumber();
+                tile->totalPaintCount++;
+            }
+
             paintRect.unite(tile->dirtyRect);
         }
     }
@@ -712,5 +726,71 @@
     return prepaintRect;
 }
 
+void TiledLayerChromium::paintDebugTileInfo(GraphicsContext& context, const IntRect& layerRect)
+{
+    FontCachePurgePreventer fontCachePurgePreventer;
+
+    // Don't bother writing info onto small tiles.
+    const int minDimension = 200;
+    if (m_tiler->tileSize().width() < minDimension || m_tiler->tileSize().height() < minDimension)
+        return;
+
+    if (!m_debugInfoFont) {
+        FontDescription fontDesc;
+        fontDesc.setGenericFamily(FontDescription::MonospaceFamily);
+        fontDesc.setComputedSize(10);
+        m_debugInfoFont = adoptPtr(new Font(fontDesc, 0, 0));
+        m_debugInfoFont->update(0);
+    }
+
+    int fontHeight = m_debugInfoFont->fontMetrics().floatHeight() + 2;
+
+    int left, top, right, bottom;
+    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
+    for (int j = top; j <= bottom; ++j) {
+        for (int i = left; i <= right; ++i) {
+            UpdatableTile* tile = tileAt(i, j);
+            if (!tile)
+                continue;
+
+            IntRect tileRect = m_tiler->tileRect(tile);
+            String info[] = {
+                String::format("LayerId(%d)", id()),
+                String::format("Index(%d, %d)", i, j),
+                String::format("Tile(%d, %d, %d, %d)", tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height()),
+                String::format("Frame(%d)", tile->lastUpdateFrame),
+                String::format("Count(%d)", tile->totalPaintCount),
+                String::format("Layer(%d, %d)", contentBounds().width(), contentBounds().height()),
+            };
+            const size_t lines = sizeof(info) / sizeof(info[0]);
+            int width[lines];
+
+            IntPoint center = m_tiler->tileRect(tile).center();
+            int currentY = center.y() - fontHeight * lines / 2;
+
+            int maxWidth = 0;
+            for (size_t i = 0; i < lines; ++i) {
+                width[i] = m_debugInfoFont->width(TextRun(info[i]));
+                maxWidth = max(width[i], maxWidth);
+            }
+
+            IntRect textRect(IntPoint(center.x() - maxWidth / 2, currentY - fontHeight / 2), IntSize(maxWidth, fontHeight * lines + fontHeight / 2));
+
+            context.setFillColor(Color(192, 192, 192, 192), ColorSpaceDeviceRGB);
+            context.fillRect(FloatRect(textRect));
+
+            context.setFillColor(Color(64, 64, 64), ColorSpaceDeviceRGB);
+
+            for (size_t i = 0; i < lines; ++i) {
+                TextRun run(info[i]);
+                int textWidth = m_debugInfoFont->width(run);
+                IntPoint textStart(center.x() - textWidth / 2, currentY + fontHeight / 2);
+                context.drawText(*m_debugInfoFont, run, textStart);
+                currentY += fontHeight;
+            }
+        }
+    }
 }
+
+}
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h (118579 => 118580)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2012-05-25 22:45:57 UTC (rev 118579)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2012-05-25 22:49:35 UTC (rev 118580)
@@ -28,6 +28,7 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
+#include "Font.h"
 #include "LayerChromium.h"
 #include "cc/CCLayerTilingData.h"
 #include "cc/CCTiledLayerImpl.h"
@@ -65,6 +66,8 @@
 
     virtual Region visibleContentOpaqueRegion() const OVERRIDE;
 
+    void paintDebugTileInfo(GraphicsContext&, const IntRect&);
+
 protected:
     TiledLayerChromium();
 
@@ -127,6 +130,7 @@
 
     TilingOption m_tilingOption;
     OwnPtr<CCLayerTilingData> m_tiler;
+    OwnPtr<Font> m_debugInfoFont;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (118579 => 118580)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-05-25 22:45:57 UTC (rev 118579)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-05-25 22:49:35 UTC (rev 118580)
@@ -77,6 +77,7 @@
 struct CCSettings {
     CCSettings()
             : acceleratePainting(false)
+            , debugShowTileInfo(false)
             , showFPSCounter(false)
             , showPlatformLayerTree(false)
             , showPaintRects(false)
@@ -93,6 +94,7 @@
     { }
 
     bool acceleratePainting;
+    bool debugShowTileInfo;
     bool showFPSCounter;
     bool showPlatformLayerTree;
     bool showPaintRects;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to