From b000f9830c1aae02ea7795e8460914c7188254a8 Mon Sep 17 00:00:00 2001 From: liyuqian Date: Tue, 14 May 2019 14:29:27 -0700 Subject: [PATCH] Rename frame_time and engine_time (flutter/engine#8952) At a quick glance, one could easily think of the "engine_time" as the GPU thread time and the "frame_time" as the UI thread time because the GPU thread time is mainly spent on the engine while the UI thread time is mainly spent on the Dart framework to generate the frame. But it's actually the other way. The "engine_time" is UI thread time and the "frame_time" is the GPU thread time. To avoid the confusion, rename them to "ui_time" and "raster_time" respectively. I avoided the "gpu_time" because the rasterization may be purely on a CPU backed software Skia backend. --- engine/src/flutter/flow/compositor_context.cc | 4 ++-- engine/src/flutter/flow/compositor_context.h | 8 ++++---- engine/src/flutter/flow/instrumentation.cc | 8 ++++---- engine/src/flutter/flow/layers/layer.h | 8 ++++---- engine/src/flutter/flow/layers/layer_tree.cc | 8 ++++---- .../src/flutter/flow/layers/performance_overlay_layer.cc | 6 +++--- engine/src/flutter/flow/raster_cache.cc | 4 ++-- engine/src/flutter/flow/scene_update_context.cc | 4 ++-- engine/src/flutter/shell/common/rasterizer.cc | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/engine/src/flutter/flow/compositor_context.cc b/engine/src/flutter/flow/compositor_context.cc index 363696fa56..bf38894b10 100644 --- a/engine/src/flutter/flow/compositor_context.cc +++ b/engine/src/flutter/flow/compositor_context.cc @@ -17,7 +17,7 @@ void CompositorContext::BeginFrame(ScopedFrame& frame, bool enable_instrumentation) { if (enable_instrumentation) { frame_count_.Increment(); - frame_time_.Start(); + raster_time_.Start(); } } @@ -25,7 +25,7 @@ void CompositorContext::EndFrame(ScopedFrame& frame, bool enable_instrumentation) { raster_cache_.SweepAfterFrame(); if (enable_instrumentation) { - frame_time_.Stop(); + raster_time_.Stop(); } } diff --git a/engine/src/flutter/flow/compositor_context.h b/engine/src/flutter/flow/compositor_context.h index ec5e685718..4266c943d1 100644 --- a/engine/src/flutter/flow/compositor_context.h +++ b/engine/src/flutter/flow/compositor_context.h @@ -79,16 +79,16 @@ class CompositorContext { const Counter& frame_count() const { return frame_count_; } - const Stopwatch& frame_time() const { return frame_time_; } + const Stopwatch& raster_time() const { return raster_time_; } - Stopwatch& engine_time() { return engine_time_; } + Stopwatch& ui_time() { return ui_time_; } private: RasterCache raster_cache_; TextureRegistry texture_registry_; Counter frame_count_; - Stopwatch frame_time_; - Stopwatch engine_time_; + Stopwatch raster_time_; + Stopwatch ui_time_; void BeginFrame(ScopedFrame& frame, bool enable_instrumentation); diff --git a/engine/src/flutter/flow/instrumentation.cc b/engine/src/flutter/flow/instrumentation.cc index ae07bbabc1..19270dc6a4 100644 --- a/engine/src/flutter/flow/instrumentation.cc +++ b/engine/src/flutter/flow/instrumentation.cc @@ -42,13 +42,13 @@ const fml::TimeDelta& Stopwatch::LastLap() const { return laps_[(current_sample_ - 1) % kMaxSamples]; } -static inline constexpr double UnitFrameInterval(double frame_time_ms) { - return frame_time_ms * 60.0 * 1e-3; +static inline constexpr double UnitFrameInterval(double raster_time_ms) { + return raster_time_ms * 60.0 * 1e-3; } -static inline double UnitHeight(double frame_time_ms, +static inline double UnitHeight(double raster_time_ms, double max_unit_interval) { - double unitHeight = UnitFrameInterval(frame_time_ms) / max_unit_interval; + double unitHeight = UnitFrameInterval(raster_time_ms) / max_unit_interval; if (unitHeight > 1.0) unitHeight = 1.0; return unitHeight; diff --git a/engine/src/flutter/flow/layers/layer.h b/engine/src/flutter/flow/layers/layer.h index 095251608f..7400af5468 100644 --- a/engine/src/flutter/flow/layers/layer.h +++ b/engine/src/flutter/flow/layers/layer.h @@ -52,8 +52,8 @@ struct PrerollContext { SkRect cull_rect; // The following allows us to paint in the end of subtree preroll - const Stopwatch& frame_time; - const Stopwatch& engine_time; + const Stopwatch& raster_time; + const Stopwatch& ui_time; TextureRegistry& texture_registry; const bool checkerboard_offscreen_layers; float total_elevation = 0.0f; @@ -83,8 +83,8 @@ class Layer { SkCanvas* leaf_nodes_canvas; GrContext* gr_context; ExternalViewEmbedder* view_embedder; - const Stopwatch& frame_time; - const Stopwatch& engine_time; + const Stopwatch& raster_time; + const Stopwatch& ui_time; TextureRegistry& texture_registry; const RasterCache* raster_cache; const bool checkerboard_offscreen_layers; diff --git a/engine/src/flutter/flow/layers/layer_tree.cc b/engine/src/flutter/flow/layers/layer_tree.cc index 5550824238..70c21604de 100644 --- a/engine/src/flutter/flow/layers/layer_tree.cc +++ b/engine/src/flutter/flow/layers/layer_tree.cc @@ -32,8 +32,8 @@ void LayerTree::Preroll(CompositorContext::ScopedFrame& frame, frame.view_embedder(), color_space, kGiantRect, - frame.context().frame_time(), - frame.context().engine_time(), + frame.context().raster_time(), + frame.context().ui_time(), frame.context().texture_registry(), checkerboard_offscreen_layers_}; @@ -83,8 +83,8 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame, frame.canvas(), frame.gr_context(), frame.view_embedder(), - frame.context().frame_time(), - frame.context().engine_time(), + frame.context().raster_time(), + frame.context().ui_time(), frame.context().texture_registry(), ignore_raster_cache ? nullptr : &frame.context().raster_cache(), checkerboard_offscreen_layers_}; diff --git a/engine/src/flutter/flow/layers/performance_overlay_layer.cc b/engine/src/flutter/flow/layers/performance_overlay_layer.cc index e81dd7f91e..ebb279c966 100644 --- a/engine/src/flutter/flow/layers/performance_overlay_layer.cc +++ b/engine/src/flutter/flow/layers/performance_overlay_layer.cc @@ -84,12 +84,12 @@ void PerformanceOverlayLayer::Paint(PaintContext& context) const { SkAutoCanvasRestore save(context.leaf_nodes_canvas, true); VisualizeStopWatch( - *context.leaf_nodes_canvas, context.frame_time, x, y, width, + *context.leaf_nodes_canvas, context.raster_time, x, y, width, height - padding, options_ & kVisualizeRasterizerStatistics, options_ & kDisplayRasterizerStatistics, "GPU", font_path_); - VisualizeStopWatch(*context.leaf_nodes_canvas, context.engine_time, x, - y + height, width, height - padding, + VisualizeStopWatch(*context.leaf_nodes_canvas, context.ui_time, x, y + height, + width, height - padding, options_ & kVisualizeEngineStatistics, options_ & kDisplayEngineStatistics, "UI", font_path_); } diff --git a/engine/src/flutter/flow/raster_cache.cc b/engine/src/flutter/flow/raster_cache.cc index 4689c21cf7..4ad18adf17 100644 --- a/engine/src/flutter/flow/raster_cache.cc +++ b/engine/src/flutter/flow/raster_cache.cc @@ -168,8 +168,8 @@ void RasterCache::Prepare(PrerollContext* context, canvas, context->gr_context, nullptr, - context->frame_time, - context->engine_time, + context->raster_time, + context->ui_time, context->texture_registry, context->raster_cache, context->checkerboard_offscreen_layers}; diff --git a/engine/src/flutter/flow/scene_update_context.cc b/engine/src/flutter/flow/scene_update_context.cc index 896795df3b..4f07edd43d 100644 --- a/engine/src/flutter/flow/scene_update_context.cc +++ b/engine/src/flutter/flow/scene_update_context.cc @@ -202,8 +202,8 @@ SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) { canvas, frame.gr_context(), nullptr, - frame.context().frame_time(), - frame.context().engine_time(), + frame.context().raster_time(), + frame.context().ui_time(), frame.context().texture_registry(), &frame.context().raster_cache(), false}; diff --git a/engine/src/flutter/shell/common/rasterizer.cc b/engine/src/flutter/shell/common/rasterizer.cc index 07c518c971..fd0296b1c4 100644 --- a/engine/src/flutter/shell/common/rasterizer.cc +++ b/engine/src/flutter/shell/common/rasterizer.cc @@ -178,7 +178,7 @@ bool Rasterizer::DrawToSurface(flutter::LayerTree& layer_tree) { // There is no way for the compositor to know how long the layer tree // construction took. Fortunately, the layer tree does. Grab that time // for instrumentation. - compositor_context_->engine_time().SetLapTime(layer_tree.construction_time()); + compositor_context_->ui_time().SetLapTime(layer_tree.construction_time()); auto* canvas = frame->SkiaCanvas();