Commit 9c39f85e authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Add JSON generators for for debugging

Change-Id: I87fca2b760bb07100a12a02cb25556438cc57fd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072936Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744711}
parent d356e20f
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host.h"
#include "cc/trees/mutator_host.h" #include "cc/trees/mutator_host.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/geometry/geometry_as_json.h"
#include "third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h" #include "third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h" #include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h"
...@@ -60,6 +61,14 @@ void PaintArtifactCompositor::WillBeRemovedFromFrame() { ...@@ -60,6 +61,14 @@ void PaintArtifactCompositor::WillBeRemovedFromFrame() {
root_layer_->RemoveAllChildren(); root_layer_->RemoveAllChildren();
} }
std::unique_ptr<JSONArray> PaintArtifactCompositor::GetPendingLayersAsJSON(
const PaintArtifact* paint_artifact) const {
std::unique_ptr<JSONArray> result = std::make_unique<JSONArray>();
for (const PendingLayer& pending_layer : pending_layers_)
result->PushObject(pending_layer.ToJSON(paint_artifact));
return result;
}
// Get a JSON representation of what layers exist for this PAC. Note that // Get a JSON representation of what layers exist for this PAC. Note that
// |paint_artifact| is only needed for pre-CAP mode. // |paint_artifact| is only needed for pre-CAP mode.
std::unique_ptr<JSONObject> PaintArtifactCompositor::GetLayersAsJSON( std::unique_ptr<JSONObject> PaintArtifactCompositor::GetLayersAsJSON(
...@@ -477,6 +486,30 @@ FloatRect PaintArtifactCompositor::PendingLayer::MapRectKnownToBeOpaque( ...@@ -477,6 +486,30 @@ FloatRect PaintArtifactCompositor::PendingLayer::MapRectKnownToBeOpaque(
return float_clip_rect.IsTight() ? float_clip_rect.Rect() : FloatRect(); return float_clip_rect.IsTight() ? float_clip_rect.Rect() : FloatRect();
} }
std::unique_ptr<JSONObject> PaintArtifactCompositor::PendingLayer::ToJSON(
const PaintArtifact* paint_artifact) const {
std::unique_ptr<JSONObject> result = std::make_unique<JSONObject>();
result->SetArray("bounds", RectAsJSONArray(bounds));
result->SetArray("rect_known_to_be_opaque",
RectAsJSONArray(rect_known_to_be_opaque));
result->SetObject("property_tree_state", property_tree_state.ToJSON());
result->SetArray("offset_of_decomposited_transforms",
PointAsJSONArray(offset_of_decomposited_transforms));
std::unique_ptr<JSONArray> chunks = std::make_unique<JSONArray>();
for (wtf_size_t chunk_index : paint_chunk_indices) {
if (paint_artifact) {
StringBuilder sb;
sb.AppendFormat("index=%i ", chunk_index);
sb.Append(paint_artifact->PaintChunks()[chunk_index].ToString());
chunks->PushString(sb.ToString());
} else {
chunks->PushInteger(chunk_index);
}
}
result->SetArray("paint_chunks", std::move(chunks));
return result;
}
FloatRect PaintArtifactCompositor::PendingLayer::VisualRectForOverlapTesting() FloatRect PaintArtifactCompositor::PendingLayer::VisualRectForOverlapTesting()
const { const {
FloatClipRect visual_rect(bounds); FloatClipRect visual_rect(bounds);
......
...@@ -167,6 +167,9 @@ class PLATFORM_EXPORT PaintArtifactCompositor final ...@@ -167,6 +167,9 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
// going to be removed from its frame. // going to be removed from its frame.
void WillBeRemovedFromFrame(); void WillBeRemovedFromFrame();
std::unique_ptr<JSONArray> GetPendingLayersAsJSON(
const PaintArtifact* = nullptr) const;
std::unique_ptr<JSONObject> GetLayersAsJSON( std::unique_ptr<JSONObject> GetLayersAsJSON(
LayerTreeFlags, LayerTreeFlags,
const PaintArtifact* = nullptr) const; const PaintArtifact* = nullptr) const;
...@@ -252,6 +255,8 @@ class PLATFORM_EXPORT PaintArtifactCompositor final ...@@ -252,6 +255,8 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
const FloatRect&); const FloatRect&);
FloatRect MapRectKnownToBeOpaque(const PropertyTreeState&) const; FloatRect MapRectKnownToBeOpaque(const PropertyTreeState&) const;
std::unique_ptr<JSONObject> ToJSON(const PaintArtifact* = nullptr) const;
FloatRect VisualRectForOverlapTesting() const; FloatRect VisualRectForOverlapTesting() const;
// The rects are in the space of property_tree_state. // The rects are in the space of property_tree_state.
......
...@@ -49,6 +49,14 @@ String PropertyTreeState::ToTreeString() const { ...@@ -49,6 +49,14 @@ String PropertyTreeState::ToTreeString() const {
#endif #endif
std::unique_ptr<JSONObject> PropertyTreeState::ToJSON() const {
std::unique_ptr<JSONObject> result = std::make_unique<JSONObject>();
result->SetObject("transform", transform_->ToJSON());
result->SetObject("clip", clip_->ToJSON());
result->SetObject("effect", effect_->ToJSON());
return result;
}
size_t PropertyTreeState::CacheMemoryUsageInBytes() const { size_t PropertyTreeState::CacheMemoryUsageInBytes() const {
return Clip().CacheMemoryUsageInBytes() + return Clip().CacheMemoryUsageInBytes() +
Transform().CacheMemoryUsageInBytes(); Transform().CacheMemoryUsageInBytes();
......
...@@ -79,6 +79,7 @@ class PLATFORM_EXPORT PropertyTreeState { ...@@ -79,6 +79,7 @@ class PLATFORM_EXPORT PropertyTreeState {
// Dumps the tree from this state up to the root as a string. // Dumps the tree from this state up to the root as a string.
String ToTreeString() const; String ToTreeString() const;
#endif #endif
std::unique_ptr<JSONObject> ToJSON() const;
// Returns memory usage of the transform & clip caches of this state plus // Returns memory usage of the transform & clip caches of this state plus
// ancestors. // ancestors.
......
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