5#include "flutter/flow/layers/layer_tree.h"
7#include "flutter/display_list/skia/dl_sk_canvas.h"
8#include "flutter/flow/embedded_views.h"
9#include "flutter/flow/frame_timings.h"
10#include "flutter/flow/layer_snapshot_store.h"
11#include "flutter/flow/layers/layer.h"
12#include "flutter/flow/paint_utils.h"
13#include "flutter/flow/raster_cache.h"
14#include "flutter/flow/raster_cache_item.h"
15#include "flutter/fml/time/time_point.h"
16#include "flutter/fml/trace_event.h"
23 : root_layer_(root_layer), frame_size_(frame_size) {}
30 bool ignore_raster_cache,
35 FML_LOG(
ERROR) <<
"The scene did not specify any layers.";
42 frame.root_surface_transformation());
44 raster_cache_items_.clear();
49 ignore_raster_cache ? nullptr : &
frame.context().raster_cache(),
51 .gr_context =
frame.gr_context(),
52 .view_embedder =
frame.view_embedder(),
53 .state_stack = state_stack,
54 .dst_color_space = sk_ref_sp<SkColorSpace>(color_space),
55 .surface_needs_readback =
false,
56 .raster_time =
frame.context().raster_time(),
57 .ui_time =
frame.context().ui_time(),
58 .texture_registry =
frame.context().texture_registry(),
59 .raster_cached_entries = &raster_cache_items_,
62 root_layer_->Preroll(&context);
69 const std::vector<RasterCacheItem*>& raster_cached_items,
71 bool ignore_raster_cache) {
73 const auto item_size = raster_cached_items.size();
74 while (
i < item_size) {
75 auto* item = raster_cached_items[
i];
76 if (item->need_caching()) {
80 if (item->TryToPrepareRasterCache(*paint_context,
false)) {
82 for (
unsigned j = 0; j < item->child_items(); j++) {
83 auto* child_item = raster_cached_items[
i + j + 1];
84 if (child_item->need_caching()) {
85 child_item->TryToPrepareRasterCache(*paint_context,
true);
88 i += item->child_items() + 1;
98 bool ignore_raster_cache)
const {
102 FML_LOG(
ERROR) <<
"The scene did not specify any layers to paint.";
113 if (enable_leaf_layer_tracing_) {
114 frame.context().snapshot_store().Clear();
115 snapshot_store = &
frame.context().snapshot_store();
122 ignore_raster_cache ? nullptr : &
frame.context().raster_cache();
129 .gr_context =
frame.gr_context(),
130 .dst_color_space =
sk_ref_sp(color_space),
131 .view_embedder =
frame.view_embedder(),
132 .raster_time =
frame.context().raster_time(),
133 .ui_time =
frame.context().ui_time(),
134 .texture_registry =
frame.context().texture_registry(),
136 .raster_cache =
cache,
138 .layer_snapshot_store = snapshot_store,
139 .enable_leaf_layer_tracing = enable_leaf_layer_tracing_,
140 .impeller_enabled = !!
frame.aiks_context(),
141 .aiks_context =
frame.aiks_context(),
147 cache->EvictUnusedCacheEntries();
152 if (root_layer_->needs_painting(context)) {
153 root_layer_->Paint(context);
159 const std::shared_ptr<TextureRegistry>& texture_registry,
173 .raster_cache =
nullptr,
176 .view_embedder =
nullptr,
177 .state_stack = preroll_state_stack,
178 .dst_color_space =
nullptr,
179 .surface_needs_readback =
false,
180 .raster_time = unused_stopwatch,
181 .ui_time = unused_stopwatch,
182 .texture_registry = texture_registry,
192 .gr_context = gr_context,
193 .dst_color_space =
nullptr,
194 .view_embedder =
nullptr,
195 .raster_time = unused_stopwatch,
196 .ui_time = unused_stopwatch,
197 .texture_registry = texture_registry,
199 .raster_cache =
nullptr,
201 .layer_snapshot_store =
nullptr,
202 .enable_leaf_layer_tracing =
false,
209 root_layer_->Preroll(&preroll_context);
212 if (root_layer_->needs_painting(paint_context)) {
213 root_layer_->Paint(paint_context);
sk_sp< T > sk_ref_sp(T *obj)
Developer-facing API for rendering anything within the engine.
virtual SkImageInfo GetImageInfo() const =0
Used for fixed refresh rate cases.
Collects snapshots of layers during frame rasterization.
void set_preroll_delegate(const SkRect &cull_rect, const SkMatrix &matrix)
void set_delegate(DlCanvas *canvas)
bool Preroll(CompositorContext::ScopedFrame &frame, bool ignore_raster_cache=false, SkRect cull_rect=kGiantRect)
LayerTree(const std::shared_ptr< Layer > &root_layer, const SkISize &frame_size)
void Paint(CompositorContext::ScopedFrame &frame, bool ignore_raster_cache=false) const
sk_sp< DisplayList > Flatten(const SkRect &bounds, const std::shared_ptr< TextureRegistry > &texture_registry=nullptr, GrDirectContext *gr_context=nullptr)
static void TryToRasterCache(const std::vector< RasterCacheItem * > &raster_cached_entries, const PaintContext *paint_context, bool ignore_raster_cache=false)
#define FML_LOG(severity)
Optional< SkRect > bounds
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
SkColorSpace * GetColorSpace(DlCanvas *canvas)
SkColorSpace * colorSpace() const
LayerStateStack & state_stack
GrDirectContext * gr_context
bool surface_needs_readback
#define TRACE_EVENT0(category_group, name)