mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
transform bounds to device space before sending to vmservice (flutter/engine#33853)
This commit is contained in:
parent
7977f073a6
commit
d5be7dccbc
@ -12,7 +12,7 @@ namespace flutter {
|
||||
LayerSnapshotData::LayerSnapshotData(int64_t layer_unique_id,
|
||||
const fml::TimeDelta& duration,
|
||||
const sk_sp<SkData>& snapshot,
|
||||
const SkRect& bounds)
|
||||
const SkIRect& bounds)
|
||||
: layer_unique_id_(layer_unique_id),
|
||||
duration_(duration),
|
||||
snapshot_(snapshot),
|
||||
|
||||
@ -26,7 +26,7 @@ class LayerSnapshotData {
|
||||
LayerSnapshotData(int64_t layer_unique_id,
|
||||
const fml::TimeDelta& duration,
|
||||
const sk_sp<SkData>& snapshot,
|
||||
const SkRect& bounds);
|
||||
const SkIRect& bounds);
|
||||
|
||||
~LayerSnapshotData() = default;
|
||||
|
||||
@ -36,13 +36,13 @@ class LayerSnapshotData {
|
||||
|
||||
sk_sp<SkData> GetSnapshot() const { return snapshot_; }
|
||||
|
||||
SkRect GetBounds() const { return bounds_; }
|
||||
SkIRect GetBounds() const { return bounds_; }
|
||||
|
||||
private:
|
||||
const int64_t layer_unique_id_;
|
||||
const fml::TimeDelta duration_;
|
||||
const sk_sp<SkData> snapshot_;
|
||||
const SkRect bounds_;
|
||||
const SkIRect bounds_;
|
||||
};
|
||||
|
||||
/// Collects snapshots of layers during frame rasterization.
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "flutter/display_list/display_list_flags.h"
|
||||
#include "flutter/flow/layer_snapshot_store.h"
|
||||
#include "flutter/flow/layers/offscreen_surface.h"
|
||||
#include "flutter/flow/raster_cache.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@ -139,22 +140,26 @@ void DisplayListLayer::Paint(PaintContext& context) const {
|
||||
auto offscreen_surface =
|
||||
std::make_unique<OffscreenSurface>(context.gr_context, canvas_size);
|
||||
|
||||
const auto& ctm = context.leaf_nodes_canvas->getTotalMatrix();
|
||||
|
||||
const auto start_time = fml::TimePoint::Now();
|
||||
{
|
||||
// render display list to offscreen surface.
|
||||
auto* canvas = offscreen_surface->GetCanvas();
|
||||
SkAutoCanvasRestore save(canvas, true);
|
||||
canvas->clear(SK_ColorTRANSPARENT);
|
||||
canvas->setMatrix(context.leaf_nodes_canvas->getTotalMatrix());
|
||||
canvas->setMatrix(ctm);
|
||||
display_list()->RenderTo(canvas, context.inherited_opacity);
|
||||
canvas->flush();
|
||||
}
|
||||
const fml::TimeDelta offscreen_render_time =
|
||||
fml::TimePoint::Now() - start_time;
|
||||
|
||||
const SkIRect device_bounds =
|
||||
RasterCache::GetDeviceBounds(paint_bounds(), ctm);
|
||||
sk_sp<SkData> raster_data = offscreen_surface->GetRasterData(true);
|
||||
LayerSnapshotData snapshot_data(unique_id(), offscreen_render_time,
|
||||
raster_data, paint_bounds());
|
||||
raster_data, device_bounds);
|
||||
context.layer_snapshot_store->Add(snapshot_data);
|
||||
}
|
||||
|
||||
|
||||
@ -1819,11 +1819,11 @@ static rapidjson::Value SerializeLayerSnapshot(
|
||||
result.AddMember("duration_micros", snapshot.GetDuration().ToMicroseconds(),
|
||||
allocator);
|
||||
|
||||
const SkRect bounds = snapshot.GetBounds();
|
||||
result.AddMember("top", bounds.top() * device_pixel_ratio, allocator);
|
||||
result.AddMember("left", bounds.left() * device_pixel_ratio, allocator);
|
||||
result.AddMember("width", bounds.width() * device_pixel_ratio, allocator);
|
||||
result.AddMember("height", bounds.height() * device_pixel_ratio, allocator);
|
||||
const SkIRect 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<SkData> snapshot_bytes = snapshot.GetSnapshot();
|
||||
if (snapshot_bytes) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user