Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6105238

Browse files
committed
Remove dead metrics code
1 parent 19de828 commit 6105238

14 files changed

+89
-237
lines changed

flow/layers/fuchsia_layer_unittests.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ std::unique_ptr<TestContext> InitTest() {
275275
// Init SceneUpdateContext.
276276
context->scene_update_context =
277277
std::make_unique<SceneUpdateContext>(context->session.get());
278-
context->scene_update_context->set_metrics(
279-
fidl::MakeOptional(fuchsia::ui::gfx::Metrics{1.f, 1.f, 1.f}));
280278

281279
// Init PrerollContext.
282280
context->preroll_context = std::unique_ptr<PrerollContext>(new PrerollContext{

flow/layers/layer_tree.cc

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace flutter {
1313

14-
LayerTree::LayerTree(const SkISize& frame_size, float frame_device_pixel_ratio)
14+
LayerTree::LayerTree(const SkISize& frame_size, float device_pixel_ratio)
1515
: frame_size_(frame_size),
16-
frame_device_pixel_ratio_(frame_device_pixel_ratio),
16+
device_pixel_ratio_(device_pixel_ratio),
1717
rasterizer_tracing_threshold_(0),
1818
checkerboard_raster_cache_images_(false),
19-
checkerboard_offscreen_layers_(false) {}
19+
checkerboard_offscreen_layers_(false) {
20+
FML_CHECK(device_pixel_ratio_ != 0.0f);
21+
}
2022

2123
void LayerTree::RecordBuildTime(fml::TimePoint build_start,
2224
fml::TimePoint target_time) {
@@ -51,7 +53,7 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
5153
frame.context().ui_time(),
5254
frame.context().texture_registry(),
5355
checkerboard_offscreen_layers_,
54-
frame_device_pixel_ratio_};
56+
device_pixel_ratio_};
5557

5658
root_layer_->Preroll(&context, frame.root_surface_transformation());
5759
return context.surface_needs_readback;
@@ -62,19 +64,8 @@ void LayerTree::UpdateScene(SceneUpdateContext& context,
6264
scenic::ContainerNode& container) {
6365
TRACE_EVENT0("flutter", "LayerTree::UpdateScene");
6466

65-
// Ensure the context is aware of the view metrics.
66-
context.set_dimensions(frame_size_, frame_device_pixel_ratio_);
67-
68-
const auto& metrics = context.metrics();
69-
FML_DCHECK(metrics->scale_x > 0.0f);
70-
FML_DCHECK(metrics->scale_y > 0.0f);
71-
FML_DCHECK(metrics->scale_z > 0.0f);
72-
73-
SceneUpdateContext::Transform transform(context, // context
74-
1.0f / metrics->scale_x, // X
75-
1.0f / metrics->scale_y, // Y
76-
1.0f / metrics->scale_z // Z
77-
);
67+
const float inv_dpr = 1.0f / device_pixel_ratio_;
68+
SceneUpdateContext::Transform transform(context, inv_dpr, inv_dpr, 1.0f);
7869

7970
SceneUpdateContext::Frame frame(
8071
context,
@@ -120,7 +111,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
120111
frame.context().texture_registry(),
121112
ignore_raster_cache ? nullptr : &frame.context().raster_cache(),
122113
checkerboard_offscreen_layers_,
123-
frame_device_pixel_ratio_};
114+
device_pixel_ratio_};
124115

125116
if (root_layer_->needs_painting())
126117
root_layer_->Paint(context);
@@ -144,18 +135,18 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
144135
root_surface_transformation.reset();
145136

146137
PrerollContext preroll_context{
147-
nullptr, // raster_cache (don't consult the cache)
148-
nullptr, // gr_context (used for the raster cache)
149-
nullptr, // external view embedder
150-
unused_stack, // mutator stack
151-
nullptr, // SkColorSpace* dst_color_space
152-
kGiantRect, // SkRect cull_rect
153-
false, // layer reads from surface
154-
unused_stopwatch, // frame time (dont care)
155-
unused_stopwatch, // engine time (dont care)
156-
unused_texture_registry, // texture registry (not supported)
157-
false, // checkerboard_offscreen_layers
158-
frame_device_pixel_ratio_ // ratio between logical and physical
138+
nullptr, // raster_cache (don't consult the cache)
139+
nullptr, // gr_context (used for the raster cache)
140+
nullptr, // external view embedder
141+
unused_stack, // mutator stack
142+
nullptr, // SkColorSpace* dst_color_space
143+
kGiantRect, // SkRect cull_rect
144+
false, // layer reads from surface
145+
unused_stopwatch, // frame time (dont care)
146+
unused_stopwatch, // engine time (dont care)
147+
unused_texture_registry, // texture registry (not supported)
148+
false, // checkerboard_offscreen_layers
149+
device_pixel_ratio_ // ratio between logical and physical
159150
};
160151

161152
SkISize canvas_size = canvas->getBaseLayerSize();
@@ -167,12 +158,12 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
167158
canvas, // canvas
168159
nullptr,
169160
nullptr,
170-
unused_stopwatch, // frame time (dont care)
171-
unused_stopwatch, // engine time (dont care)
172-
unused_texture_registry, // texture registry (not supported)
173-
nullptr, // raster cache
174-
false, // checkerboard offscreen layers
175-
frame_device_pixel_ratio_ // ratio between logical and physical
161+
unused_stopwatch, // frame time (dont care)
162+
unused_stopwatch, // engine time (dont care)
163+
unused_texture_registry, // texture registry (not supported)
164+
nullptr, // raster cache
165+
false, // checkerboard offscreen layers
166+
device_pixel_ratio_ // ratio between logical and physical
176167
};
177168

178169
// Even if we don't have a root layer, we still need to create an empty

flow/layers/layer_tree.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace flutter {
2020

2121
class LayerTree {
2222
public:
23-
LayerTree(const SkISize& frame_size, float frame_device_pixel_ratio);
23+
LayerTree(const SkISize& frame_size, float device_pixel_ratio);
2424

2525
// Perform a preroll pass on the tree and return information about
2626
// the tree that affects rendering this frame.
@@ -49,7 +49,7 @@ class LayerTree {
4949
}
5050

5151
const SkISize& frame_size() const { return frame_size_; }
52-
float frame_device_pixel_ratio() const { return frame_device_pixel_ratio_; }
52+
float device_pixel_ratio() const { return device_pixel_ratio_; }
5353

5454
void RecordBuildTime(fml::TimePoint build_start, fml::TimePoint target_time);
5555
fml::TimePoint build_start() const { return build_start_; }
@@ -76,15 +76,13 @@ class LayerTree {
7676
checkerboard_offscreen_layers_ = checkerboard;
7777
}
7878

79-
double device_pixel_ratio() const { return frame_device_pixel_ratio_; }
80-
8179
private:
8280
std::shared_ptr<Layer> root_layer_;
8381
fml::TimePoint build_start_;
8482
fml::TimePoint build_finish_;
8583
fml::TimePoint target_time_;
8684
SkISize frame_size_ = SkISize::MakeEmpty(); // Physical pixels.
87-
float frame_device_pixel_ratio_ = 1.0f; // Logical / Physical pixels ratio.
85+
const float device_pixel_ratio_; // Logical / Physical pixels ratio.
8886
uint32_t rasterizer_tracing_threshold_;
8987
bool checkerboard_raster_cache_images_;
9088
bool checkerboard_offscreen_layers_;

flow/scene_update_context.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,8 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder {
110110
~SceneUpdateContext() = default;
111111

112112
scenic::Session* session() { return session_; }
113-
114113
Entity* top_entity() { return top_entity_; }
115114

116-
bool has_metrics() const { return !!metrics_; }
117-
void set_metrics(fuchsia::ui::gfx::MetricsPtr metrics) {
118-
metrics_ = std::move(metrics);
119-
}
120-
const fuchsia::ui::gfx::MetricsPtr& metrics() const { return metrics_; }
121-
122-
void set_dimensions(const SkISize& frame_physical_size,
123-
float frame_device_pixel_ratio) {
124-
frame_physical_size_ = frame_physical_size;
125-
frame_device_pixel_ratio_ = frame_device_pixel_ratio;
126-
}
127-
const SkISize& frame_size() const { return frame_physical_size_; }
128-
float frame_device_pixel_ratio() const { return frame_device_pixel_ratio_; }
129-
130115
// The cumulative alpha value based on all the parent OpacityLayers.
131116
void set_alphaf(float alpha) { alpha_ = alpha; }
132117
float alphaf() { return alpha_; }
@@ -183,11 +168,6 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder {
183168

184169
scenic::Session* const session_;
185170

186-
fuchsia::ui::gfx::MetricsPtr metrics_;
187-
SkISize frame_physical_size_;
188-
float frame_device_pixel_ratio_ =
189-
1.0f; // Ratio between logical and physical pixels.
190-
191171
float alpha_ = 1.0f;
192172
float next_elevation_ = 0.0f;
193173

shell/common/engine.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void Engine::Render(std::unique_ptr<flutter::LayerTree> layer_tree) {
448448

449449
// Ensure frame dimensions are sane.
450450
if (layer_tree->frame_size().isEmpty() ||
451-
layer_tree->frame_device_pixel_ratio() <= 0.0f)
451+
layer_tree->device_pixel_ratio() <= 0.0f)
452452
return;
453453

454454
animator_->Render(std::move(layer_tree));

shell/platform/fuchsia/flutter/compositor_context.cc

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
3333

3434
flutter::RasterStatus Raster(flutter::LayerTree& layer_tree,
3535
bool ignore_raster_cache) override {
36-
if (!session_connection_.has_metrics()) {
37-
return flutter::RasterStatus::kSuccess;
38-
}
39-
4036
std::vector<flutter::SceneUpdateContext::PaintTask> frame_paint_tasks;
4137
std::vector<std::unique_ptr<SurfaceProducerSurface>> frame_surfaces;
4238

@@ -109,12 +105,12 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
109105
context().texture_registry(),
110106
&context().raster_cache(),
111107
false,
112-
layer_tree.frame_device_pixel_ratio()};
108+
layer_tree.device_pixel_ratio()};
113109
canvas->restoreToCount(1);
114110
canvas->save();
115111
canvas->clear(task.background_color);
116-
canvas->scale(layer_tree.frame_device_pixel_ratio() * task.scale_x,
117-
layer_tree.frame_device_pixel_ratio() * task.scale_y);
112+
canvas->scale(layer_tree.device_pixel_ratio() * task.scale_x,
113+
layer_tree.device_pixel_ratio() * task.scale_y);
118114
canvas->translate(-task.paint_bounds.left(), -task.paint_bounds.top());
119115
for (flutter::Layer* layer : task.layers) {
120116
layer->Paint(paint_context);
@@ -150,11 +146,6 @@ CompositorContext::CompositorContext(
150146
[](auto) {},
151147
vsync_event_handle) {}
152148

153-
void CompositorContext::OnSessionMetricsDidChange(
154-
const fuchsia::ui::gfx::Metrics& metrics) {
155-
session_connection_.set_metrics(metrics);
156-
}
157-
158149
void CompositorContext::OnWireframeEnabled(bool enabled) {
159150
session_connection_.set_enable_wireframe(enabled);
160151
}

shell/platform/fuchsia/flutter/compositor_context.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class CompositorContext final : public flutter::CompositorContext {
3030

3131
~CompositorContext() override;
3232

33-
void OnSessionMetricsDidChange(const fuchsia::ui::gfx::Metrics& metrics);
3433
void OnWireframeEnabled(bool enabled);
3534
void OnCreateView(int64_t view_id, bool hit_testable, bool focusable);
3635
void OnDestroyView(int64_t view_id);

shell/platform/fuchsia/flutter/engine.cc

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ Engine::Engine(Delegate& delegate,
9393
environment->GetServices(parent_environment_service_provider.NewRequest());
9494
environment.Unbind();
9595

96-
// We need to manually schedule a frame when the session metrics change.
97-
OnMetricsUpdate on_session_metrics_change_callback = std::bind(
98-
&Engine::OnSessionMetricsDidChange, this, std::placeholders::_1);
99-
10096
OnEnableWireframe on_enable_wireframe_callback = std::bind(
10197
&Engine::OnDebugWireframeSettingsChanged, this, std::placeholders::_1);
10298

@@ -137,8 +133,6 @@ Engine::Engine(Delegate& delegate,
137133
session_listener_request = std::move(session_listener_request),
138134
on_session_listener_error_callback =
139135
std::move(on_session_listener_error_callback),
140-
on_session_metrics_change_callback =
141-
std::move(on_session_metrics_change_callback),
142136
on_enable_wireframe_callback =
143137
std::move(on_enable_wireframe_callback),
144138
on_create_view_callback = std::move(on_create_view_callback),
@@ -156,7 +150,6 @@ Engine::Engine(Delegate& delegate,
156150
std::move(parent_environment_service_provider), // services
157151
std::move(session_listener_request), // session listener
158152
std::move(on_session_listener_error_callback),
159-
std::move(on_session_metrics_change_callback),
160153
std::move(on_enable_wireframe_callback),
161154
std::move(on_create_view_callback),
162155
std::move(on_destroy_view_callback),
@@ -478,24 +471,6 @@ void Engine::Terminate() {
478471
// collected this object.
479472
}
480473

481-
void Engine::OnSessionMetricsDidChange(
482-
const fuchsia::ui::gfx::Metrics& metrics) {
483-
if (!shell_) {
484-
return;
485-
}
486-
487-
shell_->GetTaskRunners().GetRasterTaskRunner()->PostTask(
488-
[rasterizer = shell_->GetRasterizer(), metrics]() {
489-
if (rasterizer) {
490-
auto compositor_context =
491-
reinterpret_cast<flutter_runner::CompositorContext*>(
492-
rasterizer->compositor_context());
493-
494-
compositor_context->OnSessionMetricsDidChange(metrics);
495-
}
496-
});
497-
}
498-
499474
void Engine::OnDebugWireframeSettingsChanged(bool enabled) {
500475
if (!shell_) {
501476
return;

shell/platform/fuchsia/flutter/engine.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class Engine final {
7171

7272
void Terminate();
7373

74-
void OnSessionMetricsDidChange(const fuchsia::ui::gfx::Metrics& metrics);
7574
void OnDebugWireframeSettingsChanged(bool enabled);
7675
void OnCreateView(int64_t view_id, bool hit_testable, bool focusable);
7776
void OnDestroyView(int64_t view_id);

0 commit comments

Comments
 (0)