Commit 5aa24fc6 authored by chrishtr's avatar chrishtr Committed by Commit bot

Add optional debugging output of what paint chunks go into what layers.

BUG=668342
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2577123002
Cr-Commit-Position: refs/heads/master@{#439151}
parent 7772a050
...@@ -3058,7 +3058,8 @@ void FrameView::pushPaintArtifactToCompositor() { ...@@ -3058,7 +3058,8 @@ void FrameView::pushPaintArtifactToCompositor() {
m_paintArtifactCompositor->update( m_paintArtifactCompositor->update(
m_paintController->paintArtifact(), m_paintController->paintArtifact(),
m_paintController->paintChunksRasterInvalidationTrackingMap()); m_paintController->paintChunksRasterInvalidationTrackingMap(),
m_isStoringCompositedLayerDebugInfo);
} }
std::unique_ptr<JSONObject> FrameView::compositedLayersAsJSON( std::unique_ptr<JSONObject> FrameView::compositedLayersAsJSON(
......
...@@ -358,6 +358,10 @@ class CORE_EXPORT FrameView final ...@@ -358,6 +358,10 @@ class CORE_EXPORT FrameView final
static void setInitialTracksPaintInvalidationsForTesting(bool); static void setInitialTracksPaintInvalidationsForTesting(bool);
void setIsStoringCompositedLayerDebugInfo(bool val) {
m_isStoringCompositedLayerDebugInfo = val;
}
// These methods are for testing. // These methods are for testing.
void setTracksPaintInvalidations(bool); void setTracksPaintInvalidations(bool);
bool isTrackingPaintInvalidations() const { bool isTrackingPaintInvalidations() const {
...@@ -1146,6 +1150,7 @@ class CORE_EXPORT FrameView final ...@@ -1146,6 +1150,7 @@ class CORE_EXPORT FrameView final
// For Slimming Paint v2 only. // For Slimming Paint v2 only.
std::unique_ptr<PaintController> m_paintController; std::unique_ptr<PaintController> m_paintController;
std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor;
bool m_isStoringCompositedLayerDebugInfo;
}; };
inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) { inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) {
......
...@@ -385,6 +385,9 @@ class Internals final : public GarbageCollected<Internals>, ...@@ -385,6 +385,9 @@ class Internals final : public GarbageCollected<Internals>,
Vector<String> getReferencedFilePaths() const; Vector<String> getReferencedFilePaths() const;
void startStoringCompositedLayerDebugInfo(Document*, ExceptionState&);
void stopStoringCompositedLayerDebugInfo(Document*, ExceptionState&);
void startTrackingRepaints(Document*, ExceptionState&); void startTrackingRepaints(Document*, ExceptionState&);
void stopTrackingRepaints(Document*, ExceptionState&); void stopTrackingRepaints(Document*, ExceptionState&);
void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks( void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(
......
...@@ -233,6 +233,9 @@ ...@@ -233,6 +233,9 @@
sequence<DOMString> getReferencedFilePaths(); sequence<DOMString> getReferencedFilePaths();
[RaisesException] void startStoringCompositedLayerDebugInfo(Document document);
[RaisesException] void stopStoringCompositedLayerDebugInfo(Document document);
// These functions both reset the tracked repaint rects. They are intended to be used in the following order: // These functions both reset the tracked repaint rects. They are intended to be used in the following order:
// startTrackingRepaints(), repaintRectsAsText(), stopTrackingRepaints(). // startTrackingRepaints(), repaintRectsAsText(), stopTrackingRepaints().
[RaisesException] void startTrackingRepaints(Document document); [RaisesException] void startTrackingRepaints(Document document);
......
...@@ -77,6 +77,11 @@ class PaintArtifactCompositor::ContentLayerClientImpl ...@@ -77,6 +77,11 @@ class PaintArtifactCompositor::ContentLayerClientImpl
} }
void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; } void SetPaintableRegion(gfx::Rect region) { m_paintableRegion = region; }
void addPaintChunkDebugData(std::unique_ptr<JSONArray> json) {
m_paintChunkDebugData.append(std::move(json));
}
void clearPaintChunkDebugData() { m_paintChunkDebugData.clear(); }
// cc::ContentLayerClient // cc::ContentLayerClient
gfx::Rect PaintableRegion() override { return m_paintableRegion; } gfx::Rect PaintableRegion() override { return m_paintableRegion; }
scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList(
...@@ -130,7 +135,7 @@ class PaintArtifactCompositor::ContentLayerClientImpl ...@@ -130,7 +135,7 @@ class PaintArtifactCompositor::ContentLayerClientImpl
} }
} }
std::unique_ptr<JSONObject> layerAsJSON() { std::unique_ptr<JSONObject> layerAsJSON(LayerTreeFlags flags) {
std::unique_ptr<JSONObject> json = JSONObject::create(); std::unique_ptr<JSONObject> json = JSONObject::create();
json->setString("name", m_debugName); json->setString("name", m_debugName);
IntSize bounds(m_ccPictureLayer->bounds().width(), IntSize bounds(m_ccPictureLayer->bounds().width(),
...@@ -140,6 +145,14 @@ class PaintArtifactCompositor::ContentLayerClientImpl ...@@ -140,6 +145,14 @@ class PaintArtifactCompositor::ContentLayerClientImpl
json->setBoolean("contentsOpaque", m_ccPictureLayer->contents_opaque()); json->setBoolean("contentsOpaque", m_ccPictureLayer->contents_opaque());
json->setBoolean("drawsContent", m_ccPictureLayer->DrawsContent()); json->setBoolean("drawsContent", m_ccPictureLayer->DrawsContent());
if (flags & LayerTreeIncludesDebugInfo) {
std::unique_ptr<JSONArray> paintChunkContentsArray = JSONArray::create();
for (const auto& debugData : m_paintChunkDebugData) {
paintChunkContentsArray->pushValue(debugData->clone());
}
json->setArray("paintChunkContents", std::move(paintChunkContentsArray));
}
ccLayersRasterInvalidationTrackingMap().asJSON(m_ccPictureLayer.get(), ccLayersRasterInvalidationTrackingMap().asJSON(m_ccPictureLayer.get(),
json.get()); json.get());
return json; return json;
...@@ -157,6 +170,7 @@ class PaintArtifactCompositor::ContentLayerClientImpl ...@@ -157,6 +170,7 @@ class PaintArtifactCompositor::ContentLayerClientImpl
scoped_refptr<cc::PictureLayer> m_ccPictureLayer; scoped_refptr<cc::PictureLayer> m_ccPictureLayer;
scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList;
gfx::Rect m_paintableRegion; gfx::Rect m_paintableRegion;
Vector<std::unique_ptr<JSONArray>> m_paintChunkDebugData;
}; };
PaintArtifactCompositor::PaintArtifactCompositor() { PaintArtifactCompositor::PaintArtifactCompositor() {
...@@ -193,7 +207,7 @@ std::unique_ptr<JSONObject> PaintArtifactCompositor::layersAsJSON( ...@@ -193,7 +207,7 @@ std::unique_ptr<JSONObject> PaintArtifactCompositor::layersAsJSON(
LayerTreeFlags flags) const { LayerTreeFlags flags) const {
std::unique_ptr<JSONArray> layersJSON = JSONArray::create(); std::unique_ptr<JSONArray> layersJSON = JSONArray::create();
for (const auto& client : m_contentLayerClients) { for (const auto& client : m_contentLayerClients) {
layersJSON->pushObject(client->layerAsJSON()); layersJSON->pushObject(client->layerAsJSON(flags));
} }
std::unique_ptr<JSONObject> json = JSONObject::create(); std::unique_ptr<JSONObject> json = JSONObject::create();
json->setArray("layers", std::move(layersJSON)); json->setArray("layers", std::move(layersJSON));
...@@ -301,7 +315,8 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk( ...@@ -301,7 +315,8 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(
const PaintChunk& paintChunk, const PaintChunk& paintChunk,
gfx::Vector2dF& layerOffset, gfx::Vector2dF& layerOffset,
Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
RasterInvalidationTracking* tracking) { RasterInvalidationTracking* tracking,
bool storeDebugInfo) {
DCHECK(paintChunk.size()); DCHECK(paintChunk.size());
// If the paint chunk is a foreign layer, just return that layer. // If the paint chunk is a foreign layer, just return that layer.
...@@ -329,6 +344,16 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk( ...@@ -329,6 +344,16 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(
DCHECK(!tracking || DCHECK(!tracking ||
tracking->trackedRasterInvalidations.size() == tracking->trackedRasterInvalidations.size() ==
paintChunk.rasterInvalidationRects.size()); paintChunk.rasterInvalidationRects.size());
contentLayerClient->clearPaintChunkDebugData();
if (storeDebugInfo) {
contentLayerClient->addPaintChunkDebugData(
paintArtifact.getDisplayItemList().subsequenceAsJSON(
paintChunk.beginIndex, paintChunk.endIndex,
DisplayItemList::SkipNonDrawings |
DisplayItemList::ShownOnlyDisplayItemTypes));
}
for (unsigned index = 0; index < paintChunk.rasterInvalidationRects.size(); for (unsigned index = 0; index < paintChunk.rasterInvalidationRects.size();
++index) { ++index) {
IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index])); IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index]));
...@@ -768,7 +793,8 @@ void PropertyTreeManager::buildEffectNodesRecursively( ...@@ -768,7 +793,8 @@ void PropertyTreeManager::buildEffectNodesRecursively(
void PaintArtifactCompositor::update( void PaintArtifactCompositor::update(
const PaintArtifact& paintArtifact, const PaintArtifact& paintArtifact,
RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations) { RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations,
bool storeDebugInfo) {
DCHECK(m_rootLayer); DCHECK(m_rootLayer);
cc::LayerTree* layerTree = m_rootLayer->GetLayerTree(); cc::LayerTree* layerTree = m_rootLayer->GetLayerTree();
...@@ -794,7 +820,8 @@ void PaintArtifactCompositor::update( ...@@ -794,7 +820,8 @@ void PaintArtifactCompositor::update(
scoped_refptr<cc::Layer> layer = layerForPaintChunk( scoped_refptr<cc::Layer> layer = layerForPaintChunk(
paintArtifact, paintChunk, layerOffset, newContentLayerClients, paintArtifact, paintChunk, layerOffset, newContentLayerClients,
rasterChunkInvalidations ? rasterChunkInvalidations->find(&paintChunk) rasterChunkInvalidations ? rasterChunkInvalidations->find(&paintChunk)
: nullptr); : nullptr,
storeDebugInfo);
int transformId = propertyTreeManager.compositorIdForTransformNode( int transformId = propertyTreeManager.compositorIdForTransformNode(
paintChunk.properties.propertyTreeState.transform()); paintChunk.properties.propertyTreeState.transform());
......
...@@ -48,9 +48,13 @@ class PLATFORM_EXPORT PaintArtifactCompositor { ...@@ -48,9 +48,13 @@ class PLATFORM_EXPORT PaintArtifactCompositor {
} }
// Updates the layer tree to match the provided paint artifact. // Updates the layer tree to match the provided paint artifact.
// If |storeDebugInfo| is true, stores detailed debugging information in
// the layers that will be output as part of a call to layersAsJSON
// (if LayerTreeIncludesDebugInfo is specified).
void update( void update(
const PaintArtifact&, const PaintArtifact&,
RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations); RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations,
bool storeDebugInfo);
// The root layer of the tree managed by this object. // The root layer of the tree managed by this object.
cc::Layer* rootLayer() const { return m_rootLayer.get(); } cc::Layer* rootLayer() const { return m_rootLayer.get(); }
...@@ -93,7 +97,8 @@ class PLATFORM_EXPORT PaintArtifactCompositor { ...@@ -93,7 +97,8 @@ class PLATFORM_EXPORT PaintArtifactCompositor {
const PaintChunk&, const PaintChunk&,
gfx::Vector2dF& layerOffset, gfx::Vector2dF& layerOffset,
Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
RasterInvalidationTracking*); RasterInvalidationTracking*,
bool storeDebugInfo);
// Finds a client among the current vector of clients that matches the paint // Finds a client among the current vector of clients that matches the paint
// chunk's id, or otherwise allocates a new one. // chunk's id, or otherwise allocates a new one.
......
...@@ -94,7 +94,7 @@ class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test { ...@@ -94,7 +94,7 @@ class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test {
} }
void update(const PaintArtifact& artifact) { void update(const PaintArtifact& artifact) {
m_paintArtifactCompositor->update(artifact, nullptr); m_paintArtifactCompositor->update(artifact, nullptr, false);
m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers(); m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers();
} }
......
...@@ -66,7 +66,14 @@ std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON( ...@@ -66,7 +66,14 @@ std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON(
#ifndef NDEBUG #ifndef NDEBUG
StringBuilder stringBuilder; StringBuilder stringBuilder;
displayItem.dumpPropertiesAsDebugString(stringBuilder); displayItem.dumpPropertiesAsDebugString(stringBuilder);
json->setString("properties", stringBuilder.toString());
if (options & ShownOnlyDisplayItemTypes) {
json->setString("type",
DisplayItem::typeAsDebugString(displayItem.getType()));
} else {
json->setString("properties", stringBuilder.toString());
}
#endif #endif
if (displayItem.hasValidClient()) { if (displayItem.hasValidClient()) {
#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
...@@ -77,12 +84,10 @@ std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON( ...@@ -77,12 +84,10 @@ std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON(
if (options & ShowClientDebugName) { if (options & ShowClientDebugName) {
#endif #endif
#ifdef NDEBUG
json->setString( json->setString(
"clientDebugName", "clientDebugName",
String::format("clientDebugName: \"%s\"", String::format("clientDebugName: \"%s\"",
displayItem.client().debugName().ascii().data())); displayItem.client().debugName().ascii().data()));
#endif
} }
#ifndef NDEBUG #ifndef NDEBUG
if ((options & ShowPictures) && displayItem.isDrawing()) { if ((options & ShowPictures) && displayItem.isDrawing()) {
......
...@@ -72,8 +72,9 @@ class PLATFORM_EXPORT DisplayItemList ...@@ -72,8 +72,9 @@ class PLATFORM_EXPORT DisplayItemList
enum JsonOptions { enum JsonOptions {
Default = 0, Default = 0,
ShowPictures = 1, ShowPictures = 1,
SkipNonDrawings = 2, SkipNonDrawings = 1 << 1,
ShowClientDebugName = 4, ShowClientDebugName = 1 << 2,
ShownOnlyDisplayItemTypes = 1 << 3
}; };
typedef unsigned JsonFlags; typedef unsigned JsonFlags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment