diff --git a/engine/src/flutter/flow/layer_snapshot_store.cc b/engine/src/flutter/flow/layer_snapshot_store.cc index 151302233b..00f0ed9463 100644 --- a/engine/src/flutter/flow/layer_snapshot_store.cc +++ b/engine/src/flutter/flow/layer_snapshot_store.cc @@ -10,20 +10,20 @@ namespace flutter { LayerSnapshotData::LayerSnapshotData(int64_t layer_unique_id, - fml::TimeDelta duration, - sk_sp snapshot) + const fml::TimeDelta& duration, + const sk_sp& snapshot, + const SkRect& bounds) : layer_unique_id_(layer_unique_id), duration_(duration), - snapshot_(snapshot) {} + snapshot_(snapshot), + bounds_(bounds) {} void LayerSnapshotStore::Clear() { layer_snapshots_.clear(); } -void LayerSnapshotStore::Add(int64_t layer_unique_id, - fml::TimeDelta duration, - sk_sp snapshot) { - layer_snapshots_.emplace_back(layer_unique_id, duration, snapshot); +void LayerSnapshotStore::Add(const LayerSnapshotData& data) { + layer_snapshots_.push_back(data); } } // namespace flutter diff --git a/engine/src/flutter/flow/layer_snapshot_store.h b/engine/src/flutter/flow/layer_snapshot_store.h index 78ede0516a..eb444d2dcc 100644 --- a/engine/src/flutter/flow/layer_snapshot_store.h +++ b/engine/src/flutter/flow/layer_snapshot_store.h @@ -24,8 +24,9 @@ namespace flutter { class LayerSnapshotData { public: LayerSnapshotData(int64_t layer_unique_id, - fml::TimeDelta duration, - sk_sp snapshot); + const fml::TimeDelta& duration, + const sk_sp& snapshot, + const SkRect& bounds); ~LayerSnapshotData() = default; @@ -35,10 +36,13 @@ class LayerSnapshotData { sk_sp GetSnapshot() const { return snapshot_; } + SkRect GetBounds() const { return bounds_; } + private: const int64_t layer_unique_id_; const fml::TimeDelta duration_; const sk_sp snapshot_; + const SkRect bounds_; }; /// Collects snapshots of layers during frame rasterization. @@ -55,9 +59,7 @@ class LayerSnapshotStore { /// Adds snapshots for a given layer. `duration` marks the time taken to /// rasterize this one layer. - void Add(int64_t layer_unique_id, - fml::TimeDelta duration, - sk_sp base64_png_snapshot); + void Add(const LayerSnapshotData& data); // Returns the number of snapshots collected. size_t Size() const { return layer_snapshots_.size(); } diff --git a/engine/src/flutter/flow/layers/display_list_layer.cc b/engine/src/flutter/flow/layers/display_list_layer.cc index 7e3e2f4214..b5d58d06d7 100644 --- a/engine/src/flutter/flow/layers/display_list_layer.cc +++ b/engine/src/flutter/flow/layers/display_list_layer.cc @@ -6,6 +6,7 @@ #include "flutter/display_list/display_list_builder.h" #include "flutter/display_list/display_list_flags.h" +#include "flutter/flow/layer_snapshot_store.h" #include "flutter/flow/layers/offscreen_surface.h" namespace flutter { @@ -152,8 +153,9 @@ void DisplayListLayer::Paint(PaintContext& context) const { fml::TimePoint::Now() - start_time; sk_sp raster_data = offscreen_surface->GetRasterData(true); - context.layer_snapshot_store->Add(unique_id(), offscreen_render_time, - raster_data); + LayerSnapshotData snapshot_data(unique_id(), offscreen_render_time, + raster_data, paint_bounds()); + context.layer_snapshot_store->Add(snapshot_data); } if (context.leaf_nodes_builder) { diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index 924eae2bde..6a66f8b243 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -1820,6 +1820,13 @@ static rapidjson::Value SerializeLayerSnapshot( result.AddMember("layer_unique_id", snapshot.GetLayerUniqueId(), allocator); result.AddMember("duration_micros", snapshot.GetDuration().ToMicroseconds(), allocator); + + const SkRect bounds = snapshot.GetBounds(); + result.AddMember("top", bounds.top(), allocator); + result.AddMember("left", bounds.left(), allocator); + result.AddMember("width", bounds.width(), allocator); + result.AddMember("height", bounds.height(), allocator); + sk_sp snapshot_bytes = snapshot.GetSnapshot(); if (snapshot_bytes) { rapidjson::Value image; @@ -1867,6 +1874,11 @@ bool Shell::OnServiceProtocolRenderFrameWithRasterStats( } response->AddMember("snapshots", snapshots, allocator); + + const auto& frame_size = last_layer_tree->frame_size(); + response->AddMember("frame_width", frame_size.width(), allocator); + response->AddMember("frame_height", frame_size.height(), allocator); + return true; } else { const char* error =