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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_};
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user