⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 118580 in webkit


Ignore:
Timestamp:
May 25, 2012, 3:49:35 PM (14 years ago)
Author:
enne@google.com
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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118577 r118580  
     12012-05-25  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Add setting for painting debug info onto tiles
     4        https://bugs.webkit.org/show_bug.cgi?id=75763
     5
     6        Reviewed by James Robinson.
     7
     8        Add a compile-time CCSetting to paint debug information onto tiles. This
     9        can help to understand paint counts and layer indices. This setting is
     10        off by default.
     11
     12        * platform/graphics/chromium/ContentLayerChromium.cpp:
     13        (WebCore::ContentLayerPainter::create):
     14        (WebCore::ContentLayerPainter::paint):
     15        (WebCore::ContentLayerPainter::ContentLayerPainter):
     16        (WebCore::ContentLayerChromium::createTextureUpdater):
     17        * platform/graphics/chromium/TiledLayerChromium.cpp:
     18        (WebCore::UpdatableTile::UpdatableTile):
     19        (WebCore::UpdatableTile::setUpdateFrame):
     20        (WebCore::UpdatableTile::incrementPaintCount):
     21        (WebCore::UpdatableTile::updateFrame):
     22        (WebCore::UpdatableTile::paintCount):
     23        (WebCore::TiledLayerChromium::TiledLayerChromium):
     24        (WebCore::TiledLayerChromium::prepareToUpdateTiles):
     25        (WebCore::TiledLayerChromium::paintDebugTileInfo):
     26        * platform/graphics/chromium/TiledLayerChromium.h:
     27        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     28        (WebCore::CCSettings::CCSettings):
     29
    1302012-05-25  Ami Fischman  <fischman@chromium.org>
    231
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r116142 r118580  
    5050    WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
    5151public:
    52     static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate)
     52    static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate, TiledLayerChromium* layer)
    5353    {
    54         return adoptPtr(new ContentLayerPainter(delegate));
     54        return adoptPtr(new ContentLayerPainter(delegate, layer));
    5555    }
    5656
     
    6060        context.clearRect(contentRect);
    6161        context.clip(contentRect);
    62         m_delegate->paintContents(context, contentRect);
    63         double paintEnd = currentTime();
    64         double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
    65         WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
    66         WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
     62        {
     63            GraphicsContextStateSaver stateSaver(context, m_layer->layerTreeHost()->settings().debugShowTileInfo);
     64
     65            m_delegate->paintContents(context, contentRect);
     66            double paintEnd = currentTime();
     67            double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
     68            WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
     69            WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
     70        }
     71        if (m_layer->layerTreeHost()->settings().debugShowTileInfo)
     72            m_layer->paintDebugTileInfo(context, contentRect);
    6773    }
    6874private:
    69     explicit ContentLayerPainter(ContentLayerDelegate* delegate)
     75    explicit ContentLayerPainter(ContentLayerDelegate* delegate, TiledLayerChromium* layer)
    7076        : m_delegate(delegate)
     77        , m_layer(layer)
    7178    {
    7279    }
    7380
    7481    ContentLayerDelegate* m_delegate;
     82    TiledLayerChromium* m_layer;
    7583};
    7684
     
    127135        return;
    128136    if (layerTreeHost()->settings().acceleratePainting)
    129         m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate));
     137        m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate, this));
    130138    else if (layerTreeHost()->settings().perTilePainting)
    131         m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMapSub);
     139        m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate, this), layerTreeHost()->layerRendererCapabilities().usingMapSub);
    132140    else
    133         m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMapSub);
     141        m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate, this), layerTreeHost()->layerRendererCapabilities().usingMapSub);
    134142    m_textureUpdater->setOpaque(opaque());
    135143
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r118383 r118580  
    3030#include "TiledLayerChromium.h"
    3131
     32#include "FontCache.h"
     33#include "FontDescription.h"
    3234#include "GraphicsContext3D.h"
    3335#include "LayerRendererChromium.h"
    3436#include "ManagedTexture.h"
    3537#include "Region.h"
     38#include "TextRun.h"
    3639#include "TextStream.h"
    3740#include "TraceEvent.h"
     
    7477    bool updated;
    7578    bool isInUseOnImpl;
     79    int lastUpdateFrame;
     80    int totalPaintCount;
    7681private:
    7782    explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture)
     
    7984        , updated(false)
    8085        , isInUseOnImpl(false)
     86        , lastUpdateFrame(0)
     87        , totalPaintCount(0)
    8188        , m_texture(texture)
    8289    {
     
    408415                }
    409416                return;
     417            }
     418
     419            if (tile->isDirty() && layerTreeHost()->settings().debugShowTileInfo) {
     420                // Invalidate the entire tile so that text updates.
     421                tile->dirtyRect = m_tiler->tileRect(tile);
     422                tile->lastUpdateFrame = layerTreeHost()->frameNumber();
     423                tile->totalPaintCount++;
    410424            }
    411425
     
    713727}
    714728
     729void TiledLayerChromium::paintDebugTileInfo(GraphicsContext& context, const IntRect& layerRect)
     730{
     731    FontCachePurgePreventer fontCachePurgePreventer;
     732
     733    // Don't bother writing info onto small tiles.
     734    const int minDimension = 200;
     735    if (m_tiler->tileSize().width() < minDimension || m_tiler->tileSize().height() < minDimension)
     736        return;
     737
     738    if (!m_debugInfoFont) {
     739        FontDescription fontDesc;
     740        fontDesc.setGenericFamily(FontDescription::MonospaceFamily);
     741        fontDesc.setComputedSize(10);
     742        m_debugInfoFont = adoptPtr(new Font(fontDesc, 0, 0));
     743        m_debugInfoFont->update(0);
     744    }
     745
     746    int fontHeight = m_debugInfoFont->fontMetrics().floatHeight() + 2;
     747
     748    int left, top, right, bottom;
     749    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
     750    for (int j = top; j <= bottom; ++j) {
     751        for (int i = left; i <= right; ++i) {
     752            UpdatableTile* tile = tileAt(i, j);
     753            if (!tile)
     754                continue;
     755
     756            IntRect tileRect = m_tiler->tileRect(tile);
     757            String info[] = {
     758                String::format("LayerId(%d)", id()),
     759                String::format("Index(%d, %d)", i, j),
     760                String::format("Tile(%d, %d, %d, %d)", tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height()),
     761                String::format("Frame(%d)", tile->lastUpdateFrame),
     762                String::format("Count(%d)", tile->totalPaintCount),
     763                String::format("Layer(%d, %d)", contentBounds().width(), contentBounds().height()),
     764            };
     765            const size_t lines = sizeof(info) / sizeof(info[0]);
     766            int width[lines];
     767
     768            IntPoint center = m_tiler->tileRect(tile).center();
     769            int currentY = center.y() - fontHeight * lines / 2;
     770
     771            int maxWidth = 0;
     772            for (size_t i = 0; i < lines; ++i) {
     773                width[i] = m_debugInfoFont->width(TextRun(info[i]));
     774                maxWidth = max(width[i], maxWidth);
     775            }
     776
     777            IntRect textRect(IntPoint(center.x() - maxWidth / 2, currentY - fontHeight / 2), IntSize(maxWidth, fontHeight * lines + fontHeight / 2));
     778
     779            context.setFillColor(Color(192, 192, 192, 192), ColorSpaceDeviceRGB);
     780            context.fillRect(FloatRect(textRect));
     781
     782            context.setFillColor(Color(64, 64, 64), ColorSpaceDeviceRGB);
     783
     784            for (size_t i = 0; i < lines; ++i) {
     785                TextRun run(info[i]);
     786                int textWidth = m_debugInfoFont->width(run);
     787                IntPoint textStart(center.x() - textWidth / 2, currentY + fontHeight / 2);
     788                context.drawText(*m_debugInfoFont, run, textStart);
     789                currentY += fontHeight;
     790            }
     791        }
     792    }
     793}
     794
    715795}
    716796#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h

    r118383 r118580  
    2929#if USE(ACCELERATED_COMPOSITING)
    3030
     31#include "Font.h"
    3132#include "LayerChromium.h"
    3233#include "cc/CCLayerTilingData.h"
     
    6566
    6667    virtual Region visibleContentOpaqueRegion() const OVERRIDE;
     68
     69    void paintDebugTileInfo(GraphicsContext&, const IntRect&);
    6770
    6871protected:
     
    128131    TilingOption m_tilingOption;
    129132    OwnPtr<CCLayerTilingData> m_tiler;
     133    OwnPtr<Font> m_debugInfoFont;
    130134};
    131135
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r118525 r118580  
    7878    CCSettings()
    7979            : acceleratePainting(false)
     80            , debugShowTileInfo(false)
    8081            , showFPSCounter(false)
    8182            , showPlatformLayerTree(false)
     
    9495
    9596    bool acceleratePainting;
     97    bool debugShowTileInfo;
    9698    bool showFPSCounter;
    9799    bool showPlatformLayerTree;
Note: See TracChangeset for help on using the changeset viewer.