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() {
m_paintArtifactCompositor->update(
m_paintController->paintArtifact(),
m_paintController->paintChunksRasterInvalidationTrackingMap());
m_paintController->paintChunksRasterInvalidationTrackingMap(),
m_isStoringCompositedLayerDebugInfo);
}
std::unique_ptr<JSONObject> FrameView::compositedLayersAsJSON(
......
......@@ -358,6 +358,10 @@ class CORE_EXPORT FrameView final
static void setInitialTracksPaintInvalidationsForTesting(bool);
void setIsStoringCompositedLayerDebugInfo(bool val) {
m_isStoringCompositedLayerDebugInfo = val;
}
// These methods are for testing.
void setTracksPaintInvalidations(bool);
bool isTrackingPaintInvalidations() const {
......@@ -1146,6 +1150,7 @@ class CORE_EXPORT FrameView final
// For Slimming Paint v2 only.
std::unique_ptr<PaintController> m_paintController;
std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor;
bool m_isStoringCompositedLayerDebugInfo;
};
inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) {
......
......@@ -385,6 +385,9 @@ class Internals final : public GarbageCollected<Internals>,
Vector<String> getReferencedFilePaths() const;
void startStoringCompositedLayerDebugInfo(Document*, ExceptionState&);
void stopStoringCompositedLayerDebugInfo(Document*, ExceptionState&);
void startTrackingRepaints(Document*, ExceptionState&);
void stopTrackingRepaints(Document*, ExceptionState&);
void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(
......
......@@ -233,6 +233,9 @@
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:
// startTrackingRepaints(), repaintRectsAsText(), stopTrackingRepaints().
[RaisesException] void startTrackingRepaints(Document document);
......
......@@ -77,6 +77,11 @@ class PaintArtifactCompositor::ContentLayerClientImpl
}
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
gfx::Rect PaintableRegion() override { return m_paintableRegion; }
scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList(
......@@ -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();
json->setString("name", m_debugName);
IntSize bounds(m_ccPictureLayer->bounds().width(),
......@@ -140,6 +145,14 @@ class PaintArtifactCompositor::ContentLayerClientImpl
json->setBoolean("contentsOpaque", m_ccPictureLayer->contents_opaque());
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(),
json.get());
return json;
......@@ -157,6 +170,7 @@ class PaintArtifactCompositor::ContentLayerClientImpl
scoped_refptr<cc::PictureLayer> m_ccPictureLayer;
scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList;
gfx::Rect m_paintableRegion;
Vector<std::unique_ptr<JSONArray>> m_paintChunkDebugData;
};
PaintArtifactCompositor::PaintArtifactCompositor() {
......@@ -193,7 +207,7 @@ std::unique_ptr<JSONObject> PaintArtifactCompositor::layersAsJSON(
LayerTreeFlags flags) const {
std::unique_ptr<JSONArray> layersJSON = JSONArray::create();
for (const auto& client : m_contentLayerClients) {
layersJSON->pushObject(client->layerAsJSON());
layersJSON->pushObject(client->layerAsJSON(flags));
}
std::unique_ptr<JSONObject> json = JSONObject::create();
json->setArray("layers", std::move(layersJSON));
......@@ -301,7 +315,8 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(
const PaintChunk& paintChunk,
gfx::Vector2dF& layerOffset,
Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
RasterInvalidationTracking* tracking) {
RasterInvalidationTracking* tracking,
bool storeDebugInfo) {
DCHECK(paintChunk.size());
// If the paint chunk is a foreign layer, just return that layer.
......@@ -329,6 +344,16 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(
DCHECK(!tracking ||
tracking->trackedRasterInvalidations.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();
++index) {
IntRect rect(enclosingIntRect(paintChunk.rasterInvalidationRects[index]));
......@@ -768,7 +793,8 @@ void PropertyTreeManager::buildEffectNodesRecursively(
void PaintArtifactCompositor::update(
const PaintArtifact& paintArtifact,
RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations) {
RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations,
bool storeDebugInfo) {
DCHECK(m_rootLayer);
cc::LayerTree* layerTree = m_rootLayer->GetLayerTree();
......@@ -794,7 +820,8 @@ void PaintArtifactCompositor::update(
scoped_refptr<cc::Layer> layer = layerForPaintChunk(
paintArtifact, paintChunk, layerOffset, newContentLayerClients,
rasterChunkInvalidations ? rasterChunkInvalidations->find(&paintChunk)
: nullptr);
: nullptr,
storeDebugInfo);
int transformId = propertyTreeManager.compositorIdForTransformNode(
paintChunk.properties.propertyTreeState.transform());
......
......@@ -48,9 +48,13 @@ class PLATFORM_EXPORT PaintArtifactCompositor {
}
// 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(
const PaintArtifact&,
RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations);
RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations,
bool storeDebugInfo);
// The root layer of the tree managed by this object.
cc::Layer* rootLayer() const { return m_rootLayer.get(); }
......@@ -93,7 +97,8 @@ class PLATFORM_EXPORT PaintArtifactCompositor {
const PaintChunk&,
gfx::Vector2dF& layerOffset,
Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
RasterInvalidationTracking*);
RasterInvalidationTracking*,
bool storeDebugInfo);
// Finds a client among the current vector of clients that matches the paint
// chunk's id, or otherwise allocates a new one.
......
......@@ -94,7 +94,7 @@ class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test {
}
void update(const PaintArtifact& artifact) {
m_paintArtifactCompositor->update(artifact, nullptr);
m_paintArtifactCompositor->update(artifact, nullptr, false);
m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers();
}
......
......@@ -66,7 +66,14 @@ std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON(
#ifndef NDEBUG
StringBuilder stringBuilder;
displayItem.dumpPropertiesAsDebugString(stringBuilder);
if (options & ShownOnlyDisplayItemTypes) {
json->setString("type",
DisplayItem::typeAsDebugString(displayItem.getType()));
} else {
json->setString("properties", stringBuilder.toString());
}
#endif
if (displayItem.hasValidClient()) {
#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
......@@ -77,12 +84,10 @@ std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON(
if (options & ShowClientDebugName) {
#endif
#ifdef NDEBUG
json->setString(
"clientDebugName",
String::format("clientDebugName: \"%s\"",
displayItem.client().debugName().ascii().data()));
#endif
}
#ifndef NDEBUG
if ((options & ShowPictures) && displayItem.isDrawing()) {
......
......@@ -72,8 +72,9 @@ class PLATFORM_EXPORT DisplayItemList
enum JsonOptions {
Default = 0,
ShowPictures = 1,
SkipNonDrawings = 2,
ShowClientDebugName = 4,
SkipNonDrawings = 1 << 1,
ShowClientDebugName = 1 << 2,
ShownOnlyDisplayItemTypes = 1 << 3
};
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